devel_wizard-2.x-dev/src/Plugin/DevelWizard/Spell/BlockContentTypeAdminViewSpell.php

src/Plugin/DevelWizard/Spell/BlockContentTypeAdminViewSpell.php
<?php

declare(strict_types=1);

namespace Drupal\devel_wizard\Plugin\DevelWizard\Spell;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\devel_wizard\Attribute\DevelWizardSpell;

/**
 * @todo Validate that a views.view with the same name does not exists.
 */
#[DevelWizardSpell(
  id: 'devel_wizard_block_content_type_admin_view',
  category: new TranslatableMarkup('Block type'),
  label: new TranslatableMarkup('Block type - admin view'),
  description: new TranslatableMarkup('Creates a view for administrators for an existing Block type.'),
  tags: [
    'bundle' => new TranslatableMarkup('Bundle'),
    'config_entity' => new TranslatableMarkup('Config entity'),
    'block_content_type' => new TranslatableMarkup('Block type'),
    'admin' => new TranslatableMarkup('Admin'),
  ],
)]
class BlockContentTypeAdminViewSpell extends ConfigEntityAdminViewSpellBase {

  /**
   * {@inheritdoc}
   */
  protected string $provider = 'block_content';

  protected string $configEntityTypeId = 'block_content_type';

  protected string $contentEntityTypeId = 'block_content';

  protected string $bundleIdInConfigTemplate = 'basic';

  protected string $primaryTabPath = 'admin/content/block-content';

  protected function getMainTabView(): ?array {
    return NULL;
  }

  protected function getSecondaryTaskView(): ?array {
    $configuration = $this->getConfiguration();
    $machineName = $configuration['machine_name'];

    $data = parent::getSecondaryTaskView();
    $data['display']['overview']['display_options']['path'] = "{$this->primaryTabPath}/{$machineName}";
    $data['display']['default']['display_options']['access']['options']['perm'] = "delete any $machineName block content";

    return $data;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc