devel_wizard-2.x-dev/src/Plugin/DevelWizard/Spell/TaxonomyVocabularyUserRoleSpell.php
src/Plugin/DevelWizard/Spell/TaxonomyVocabularyUserRoleSpell.php
<?php
declare(strict_types=1);
namespace Drupal\devel_wizard\Plugin\DevelWizard\Spell;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\devel_wizard\Attribute\DevelWizardSpell;
#[DevelWizardSpell(
id: 'devel_wizard_taxonomy_vocabulary_user_role',
category: new TranslatableMarkup('Taxonomy'),
label: new TranslatableMarkup('Taxonomy vocabulary - User role'),
description: new TranslatableMarkup('Creates a new user role which grants full control over a specific Taxonomy vocabulary.'),
tags: [
'bundle' => new TranslatableMarkup('Bundle'),
'config_entity' => new TranslatableMarkup('Config entity'),
'taxonomy_vocabulary' => new TranslatableMarkup('Taxonomy vocabulary'),
'site_build' => new TranslatableMarkup('Site build'),
'user_role' => new TranslatableMarkup('User role'),
],
)]
class TaxonomyVocabularyUserRoleSpell extends ConfigEntityUserRoleSpellBase {
protected string $provider = 'taxonomy';
protected string $configEntityTypeId = 'taxonomy_vocabulary';
protected string $contentEntityTypeId = 'taxonomy_term';
public function getRequiredPackagesProd(): array {
$packages = parent::getRequiredPackagesProd();
$packages['drupal/taxonomy_access_fix'] = '^4.0';
return $packages;
}
public function getRequiredModules(): array {
$modules = parent::getRequiredModules();
$modules['taxonomy_access_fix'] = TRUE;
return $modules;
}
/**
* {@inheritdoc}
*/
protected function getDefaultPermissions(): array {
$machineName = $this->configuration['machine_name'];
return [
'access administration pages' => TRUE,
'view the administration theme' => TRUE,
"create terms in $machineName" => TRUE,
"edit terms in $machineName" => TRUE,
"delete terms in $machineName" => TRUE,
"reorder terms in $machineName" => TRUE,
"reset $machineName" => TRUE,
"view terms in $machineName" => TRUE,
"view unpublished terms in $machineName" => TRUE,
"view vocabulary name of $machineName" => TRUE,
"view term names in $machineName" => TRUE,
"view terms in $machineName" => TRUE,
];
}
}
