Skip to content

Commit fc1835b

Browse files
committed
feat: ask to add cache to project configuration when creating cache
1 parent 3765c54 commit fc1835b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/Command/Cache/CreateCacheCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ protected function perform(InputInterface $input, ConsoleOutput $output)
6767
$this->apiClient->createCache($name, (int) $network->get('id'), $type);
6868

6969
$output->infoWithDelayWarning('Cache cluster created');
70+
71+
if ($this->projectConfiguration->exists() && $output->confirm('Would you like to add the cache cluster to your project configuration?')) {
72+
$this->projectConfiguration->addOptionsToEnvironments(['cache' => $name]);
73+
}
7074
}
7175

7276
/**

src/ProjectConfiguration.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ public function addEnvironment(string $name, ?array $options = null)
7676
$this->configuration['environments'][$name] = $options;
7777
}
7878

79+
/**
80+
* Add the given options to all project environments.
81+
*/
82+
public function addOptionsToEnvironments(array $options)
83+
{
84+
foreach ($this->configuration['environments'] as $name => $environment) {
85+
$this->configuration['environments'][$name] = array_merge((array) $environment, $options);
86+
}
87+
}
88+
7989
/**
8090
* Creates a new configuration from the given project.
8191
*

0 commit comments

Comments
 (0)