Skip to content

Commit

Permalink
ACMS-1976: Update staterkit_name when installed using UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshreeputra committed Dec 12, 2023
1 parent 868c3b1 commit d66bb6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function testIfTelemetryDataShouldSend(): void {

$method = $this->getAcqauiaCmsTelemetryMethod("shouldSendTelemetryData");
$state_service = $this->container->get("state");
$datetime_service = $this->container->get('datetime.time');

$shouldSendData = $method->invoke($this->acquiaCmsTelemetry);
$this->assertFalse($shouldSendData, "Should not send telemetry data on Non Acquia environment.");
Expand All @@ -95,16 +96,16 @@ public function testIfTelemetryDataShouldSend(): void {
$shouldSendData = $method->invoke($this->acquiaCmsTelemetry);
$this->assertTrue($shouldSendData, "Should send telemetry data on Acquia environment.");

$this->container->get("state")->set(
$state_service->set(
"acquia_cms_common.telemetry.timestamp",
$this->container->get('datetime.time')->getCurrentTime()
$datetime_service->getCurrentTime()
);
$shouldSendData = $method->invoke($this->acquiaCmsTelemetry);
$this->assertFalse($shouldSendData, "Should not send telemetry data, if data send recently.");

$this->container->get("state")->set(
$state_service->set(
"acquia_cms_common.telemetry.timestamp",
$this->container->get('datetime.time')->getCurrentTime() - 86401,
$datetime_service->getCurrentTime() - 86401,
);
$shouldSendData = $method->invoke($this->acquiaCmsTelemetry);
$this->assertTrue($shouldSendData, "Should send telemetry data, if data sent before a day.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ class StarterKitConfigForm extends AcquiaCmsStarterKitBase {
*/
protected $starterKitService;

/**
* Starterkit service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
/** @var static $instance */
$instance = parent::create($container);
$instance->starterKitService = $container->get('acquia_cms_tour.starter_kit');

$instance->configFactory = $container->get('config.factory');
return $instance;
}

Expand Down Expand Up @@ -214,6 +221,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$missing_modules = $this->starterKitService->getMissingModules($starter_kit, $starter_kit_demo, $starter_kit_content_model);
if (!$missing_modules) {
$this->state->set('show_starter_kit_modal', FALSE);
$this->configFactory->getEditable('acquia_cms_common.settings')->set('starter_kit_name', $starter_kit)->save();
$this->state->set('starter_kit_wizard_completed', TRUE);
$this->starterKitService->enableModules($starter_kit, $starter_kit_demo, $starter_kit_content_model);
$this->messenger()->addStatus($this->t('The %starter_kit starter kit has been installed. Also, the related modules & themes have been enabled.', [
Expand Down

0 comments on commit d66bb6a

Please sign in to comment.