devel_wizard-2.x-dev/src/Plugin/DevelWizard/Spell/BlockContentTypeUserRoleSpell.php
src/Plugin/DevelWizard/Spell/BlockContentTypeUserRoleSpell.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_block_content_type_user_role',
category: new TranslatableMarkup('Block type'),
label: new TranslatableMarkup('Block type - User Role'),
description: new TranslatableMarkup('Creates a new user role which grants full control over a specific Block type.'),
tags: [
'bundle' => new TranslatableMarkup('Bundle'),
'config_entity' => new TranslatableMarkup('Config entity'),
'block_content_type' => new TranslatableMarkup('Block type'),
'site_build' => new TranslatableMarkup('Site build'),
'user_role' => new TranslatableMarkup('User role'),
],
)]
class BlockContentTypeUserRoleSpell extends ConfigEntityUserRoleSpellBase {
protected string $provider = 'block_content';
protected string $configEntityTypeId = 'block_content_type';
protected string $contentEntityTypeId = 'block_content';
public function getRequiredPackagesProd(): array {
$packages = parent::getRequiredPackagesProd();
$packages['drupal/block_content_permissions'] = '^1.0';
return $packages;
}
public function getRequiredModules(): array {
$modules = parent::getRequiredModules();
$modules['block_content_permissions'] = TRUE;
return $modules;
}
/**
* {@inheritdoc}
*/
protected function getDefaultPermissions(): array {
$machineName = $this->configuration['machine_name'];
return [
'access administration pages' => TRUE,
'view the administration theme' => TRUE,
"create $machineName block content" => TRUE,
"delete any $machineName block content" => TRUE,
"delete any $machineName block content revisions" => TRUE,
"edit any $machineName block content" => TRUE,
"revert any $machineName block content revisions" => TRUE,
"view any $machineName block content history" => TRUE,
];
}
}
