Skip to content

Commit

Permalink
ACMS-4373: Make Acquia CMS Toolbar and Tour work independent.
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshreeputra committed Dec 20, 2024
1 parent 8cee154 commit 4c627c9
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 38 deletions.
11 changes: 5 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions modules/acquia_cms_toolbar/acquia_cms_toolbar.install
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@

use Drupal\user\Entity\Role;

/**
* Implements hook_install().
*/
function acquia_cms_toolbar_install($is_syncing) {
if (!$is_syncing) {
$roles = Role::loadMultiple();
foreach ($roles as $role) {
switch ($role->id()) {
case 'content_administrator':
case 'content_author':
case 'content_editor':
case 'developer':
case 'site_builder':
case 'user_administrator':
user_role_grant_permissions($role->id(), ['access toolbar']);
break;
}
}
}
}

/**
* Update role permission handler.
*/
Expand Down
10 changes: 5 additions & 5 deletions modules/acquia_cms_toolbar/acquia_cms_toolbar.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

use Acquia\DrupalEnvironmentDetector\AcquiaDrupalEnvironmentDetector as Environment;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
use Drupal\user\RoleInterface;

/**
* Implements hook_preprocess_HOOK().
Expand Down Expand Up @@ -102,17 +102,17 @@ function _acquia_cms_toolbar_get_environment_indicator_color_config(): array {
}

/**
* Implements hook_content_model_role_presave_alter().
* Implements hook_entity_insert().
*/
function acquia_cms_toolbar_content_model_role_presave_alter(RoleInterface &$role) {
switch ($role->id()) {
function acquia_cms_toolbar_entity_insert(EntityInterface $entity) {
switch ($entity->id()) {
case 'content_administrator':
case 'content_author':
case 'content_editor':
case 'developer':
case 'site_builder':
case 'user_administrator':
$role->grantPermission('access toolbar');
user_role_grant_permissions($entity->id(), ['access toolbar']);
break;
}
}
1 change: 0 additions & 1 deletion modules/acquia_cms_toolbar/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"license": "GPL-2.0-or-later",
"type": "drupal-module",
"require": {
"drupal/acquia_cms_common": "^1.9 || ^2.1 || ^3.1",
"drupal/admin_toolbar": "^3.3"
},
"conflict": {
Expand Down
2 changes: 0 additions & 2 deletions modules/acquia_cms_tour/acquia_cms_tour.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ package: "Acquia CMS"
description: "Provides a tour page for Acquia CMS."
type: module
core_version_requirement: ^9.4 || ^10 || ^11
dependencies:
- acquia_cms_common:acquia_cms_common
12 changes: 12 additions & 0 deletions modules/acquia_cms_tour/acquia_cms_tour.install
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@

use Drupal\user\Entity\Role;

/**
* Implements hook_install().
*/
function acquia_cms_tour_install($is_syncing) {
if (!$is_syncing) {
$role = Role::load('content_administrator');
if ($role) {
user_role_grant_permissions('content_administrator', ['access acquia cms tour dashboard']);
}
}
}

/**
* Add state key for existing sites with Acquia CMS profile.
*/
Expand Down
10 changes: 5 additions & 5 deletions modules/acquia_cms_tour/acquia_cms_tour.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Contains hook implementations for the acquia_cms_tour module.
*/

use Drupal\user\RoleInterface;
use Drupal\Core\Entity\EntityInterface;

/**
* Implements hook_menu_links_discovered_alter().
Expand Down Expand Up @@ -57,12 +57,12 @@ function acquia_cms_tour_modules_uninstalled(array $modules) {
}

/**
* Implements hook_content_model_role_presave_alter().
* Implements hook_cms_tour_entity_insert().
*/
function acquia_cms_tour_content_model_role_presave_alter(RoleInterface &$role) {
switch ($role->id()) {
function acquia_cms_tour_entity_insert(EntityInterface $entity) {
switch ($entity->id()) {
case 'content_administrator':
$role->grantPermission('access acquia cms tour dashboard');
user_role_grant_permissions('content_administrator', ['access acquia cms tour dashboard']);
break;
}
}
4 changes: 2 additions & 2 deletions modules/acquia_cms_tour/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"license": "GPL-2.0-or-later",
"type": "drupal-module",
"require": {
"drupal/acquia_cms_common": "^1.9 || ^2.1 || ^3.1",
"drupal/checklistapi": "^2.1"
},
"require-dev": {
"drupal/acquia_cms_place": "^1",
"drupal/geocoder": "^3.35 || ^4.10",
"drupal/google_tag": "^2",
"drupal/recaptcha": "^3"
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion modules/acquia_cms_tour/css/acquia_cms_tour_dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
padding: 0;
margin: 0;
}
.acms-dashboard-form-wrapper .js-form-wrapper .js-form-wrapper .fieldset__wrapper{
.acms-dashboard-form-wrapper .js-form-wrapper .js-form-wrapper .fieldset__wrapper {
margin-left: 0;
}
.section-top {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Drupal\acquia_cms_tour\Controller;

use Drupal\acquia_cms_tour\AcquiaCmsTourManager;
use Drupal\acquia_cms_tour\Services\StarterKitService;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ClassResolverInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Url;
use Drupal\acquia_cms_tour\AcquiaCmsTourManager;
use Drupal\acquia_cms_tour\Services\StarterKitService;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Drupal\acquia_cms_tour\Form;

use Drupal\acquia_cms_tour\AcquiaCmsTourManager;
use Drupal\Core\DependencyInjection\ClassResolverInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Renderer;
use Drupal\Core\State\StateInterface;
use Drupal\acquia_cms_tour\AcquiaCmsTourManager;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Drupal\acquia_cms_tour\Form;

use Drupal\acquia_cms_tour\AcquiaCmsStarterKitManager;
use Drupal\Core\DependencyInjection\ClassResolverInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Renderer;
use Drupal\Core\State\StateInterface;
use Drupal\acquia_cms_tour\AcquiaCmsStarterKitManager;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Drupal\acquia_cms_tour\Plugin\AcquiaCmsStarterKit;

use Drupal\acquia_cms_tour\Form\AcquiaCmsStarterKitBase;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Form\FormStateInterface;
use Drupal\acquia_cms_tour\Form\AcquiaCmsStarterKitBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Drupal\acquia_cms_tour\Plugin\AcquiaCmsStarterKit;

use Drupal\acquia_cms_tour\Form\AcquiaCmsStarterKitBase;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Form\FormStateInterface;
use Drupal\acquia_cms_tour\Form\AcquiaCmsStarterKitBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Drupal\acquia_cms_tour\Plugin\AcquiaCmsTour;

use Drupal\acquia_cms_tour\Form\AcquiaCmsDashboardBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\acquia_cms_tour\Form\AcquiaCmsDashboardBase;
use Drupal\geocoder\GeocoderProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Drupal\acquia_cms_tour\Plugin\AcquiaCmsTour;

use Drupal\acquia_cms_tour\Form\AcquiaCmsDashboardBase;
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\acquia_cms_tour\Form\AcquiaCmsDashboardBase;
use Drupal\google_tag\Entity\TagContainer;

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
if ($accounts === []) {
$config_name = 'google_tag.container.' . $account_default_value;
$entity_accounts = $this->config($config_name)->get('tag_container_ids');
if ($entity_accounts){
if ($entity_accounts) {
foreach ($entity_accounts as $index => $account) {
$accounts[$index]['value'] = $account;
$accounts[$index]['weight'] = $index;
Expand Down Expand Up @@ -242,7 +242,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$config->set('tag_container_ids', array_values($tag_container_ids));
$config->save();
}
if($this->configFactory->getEditable('google_tag.settings')->get('default_google_tag_entity') !== NULL) {
if ($this->configFactory->getEditable('google_tag.settings')->get('default_google_tag_entity') !== NULL) {
$this->configFactory->getEditable('google_tag.settings')->set('default_google_tag_entity', $config_id)->save();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Drupal\acquia_cms_tour\Plugin\AcquiaCmsTour;

use Drupal\acquia_cms_tour\Form\AcquiaCmsDashboardBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\acquia_cms_tour\Form\AcquiaCmsDashboardBase;

/**
* Plugin implementation of the acquia_cms_tour.
Expand Down
6 changes: 3 additions & 3 deletions modules/acquia_cms_tour/src/Services/StarterKitService.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(
* @param string $content_model
* Variable holding the content model option selected.
*/
public function enableModules(string $starter_kit, string $demo_question = NULL, string $content_model = NULL) {
public function enableModules(string $starter_kit, ?string $demo_question = NULL, ?string $content_model = NULL) {
$starter_kits = [
'acquia_cms_enterprise_low_code' => 'Acquia CMS Enterprise low-code',
'acquia_cms_community' => 'Acquia CMS Community',
Expand Down Expand Up @@ -144,7 +144,7 @@ public static function enableSingleModule(string $module) {
* @param string $content_model
* Variable holding the content model option selected.
*/
public function getModulesAndThemes(string $starter_kit, string $demo_question = NULL, string $content_model = NULL) {
public function getModulesAndThemes(string $starter_kit, ?string $demo_question = NULL, ?string $content_model = NULL) {
$enableModules = $enableThemes = [];
switch ($starter_kit) {
case 'acquia_cms_enterprise_low_code':
Expand Down Expand Up @@ -227,7 +227,7 @@ public function getModulesAndThemes(string $starter_kit, string $demo_question =
* @param string $content_model
* Variable holding the content model option selected.
*/
public function getMissingModules(string $starter_kit, string $demo_question = NULL, string $content_model = NULL) {
public function getMissingModules(string $starter_kit, ?string $demo_question = NULL, ?string $content_model = NULL) {
$modulesAndThemes = $this->getModulesAndThemes($starter_kit, $demo_question, $content_model);
$modules = $modulesAndThemes['enableModules'];
$moduleList = array_keys($this->moduleExtensionList->getList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Drupal\Tests\acquia_cms_tour\Functional;

use Drupal\geocoder\Entity\GeocoderProvider;
use Drupal\Tests\BrowserTestBase;
use Drupal\geocoder\Entity\GeocoderProvider;

/**
* Tests the Acquia CMS Tour module's integration with Google Maps.
Expand All @@ -24,7 +24,7 @@ class AcquiaGoogleMapsTest extends BrowserTestBase {
*/
protected static $modules = [
'acquia_cms_tour',
'acquia_cms_place',
'geocoder',
];

/**
Expand Down

0 comments on commit 4c627c9

Please sign in to comment.