devel_wizard-2.x-dev/templates/spell/entity_type_group/plugin-group-relation-handler-permission-provider.php.twig

templates/spell/entity_type_group/plugin-group-relation-handler-permission-provider.php.twig
<?php

declare(strict_types=1);

namespace {{ groupPermissionProvider.classNamespace }};

use Drupal\group\Plugin\Group\RelationHandler\PermissionProviderInterface;
use Drupal\group\Plugin\Group\RelationHandler\PermissionProviderTrait;

/**
 * This is a plugin but the plugin discovery does not use annotations.
 *
 * @see \Drupal\group\Plugin\Group\Relation\GroupRelationTypeManager::createHandlerInstance
 */
class {{ groupPermissionProvider.class }} implements PermissionProviderInterface {

  use PermissionProviderTrait;

  public function __construct(PermissionProviderInterface $parent) {
    $this->parent = $parent;
  }

  /**
   * {@inheritdoc}
   */
  public function getPermission($operation, $target, $scope = 'any') {
    if (in_array($operation, ['edit', 'delete'])) {
      $operation .= ".$scope";
    }

    $bundleId = $this->groupRelationType->getEntityBundle();

    return "{{ contentEntityType.definition.provider }}.{{ contentEntityType.id }}.$bundleId.$operation";
    //return $this->parent->getPermission($operation, $target, $scope);
  }

}

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

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