/**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = array();

    foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
      if ($entity_type_id == 'scheduled_update') {
        continue;
      }
      if ($entity_type->get('field_ui_base_route')) {
        $this->derivatives["scheduled_update_field_add_$entity_type_id"] = array(
          'route_name' => "entity.scheduled_update_type.add_form.field.$entity_type_id",
          'title' => $this->t('Add Update field'),
          'appears_on' => array("entity.$entity_type_id.field_ui_fields"),
          'query' => ['entity_type_id' => $entity_type_id],
          'route_parameters' => ['entity_type_id' => $entity_type_id],
          'defaults' => ['mode' => 'embedded'],
        );
      }
    }

    foreach ($this->derivatives as &$entry) {
      $entry += $base_plugin_definition;
    }

    return $this->derivatives;
  }
 /**
  * Adds content entity types checkboxes.
  */
 protected function setContentTypeSelect(&$form, $defaults, $type, $exclude_has_config_bundles = TRUE)
 {
     $entity_types = $this->entityManager->getDefinitions();
     $has_config_bundle = array();
     foreach ($entity_types as $definition) {
         if ($entity_type_id = $definition->getBundleOf()) {
             $has_config_bundle[] = $entity_type_id;
         }
     }
     $options = array();
     foreach ($entity_types as $entity_type_id => $entity_type) {
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         if ($exclude_has_config_bundles && in_array($entity_type_id, $has_config_bundle)) {
             continue;
         }
         $options[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
     }
     // Sort the entity types by label.
     uasort($options, 'strnatcasecmp');
     if (!isset($form['types'])) {
         $form['types'] = array('#type' => 'container', '#tree' => TRUE);
     }
     $form['types']['content'] = array('#type' => 'checkboxes', '#title' => $this->t('Content entity types'), '#description' => $this->t('Select content entity types that should be considered @type types.', array('@type' => $type)), '#options' => $options, '#default_value' => $defaults);
 }
 /**
  * Returns an array of content translation permissions.
  *
  * @return array
  */
 public function contentPermissions()
 {
     $permission = [];
     // Create a translate permission for each enabled entity type and (optionally)
     // bundle.
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($permission_granularity = $entity_type->getPermissionGranularity()) {
             $t_args = ['@entity_label' => $entity_type->getLowercaseLabel()];
             switch ($permission_granularity) {
                 case 'bundle':
                     foreach ($this->entityManager->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
                         if ($this->contentTranslationManager->isEnabled($entity_type_id, $bundle)) {
                             $t_args['%bundle_label'] = isset($bundle_info['label']) ? $bundle_info['label'] : $bundle;
                             $permission["translate {$bundle} {$entity_type_id}"] = ['title' => $this->t('Translate %bundle_label @entity_label', $t_args)];
                         }
                     }
                     break;
                 case 'entity_type':
                     if ($this->contentTranslationManager->isEnabled($entity_type_id)) {
                         $permission["translate {$entity_type_id}"] = ['title' => $this->t('Translate @entity_label', $t_args)];
                     }
                     break;
             }
         }
     }
     return $permission;
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $comment_type = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $comment_type->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $comment_type->id(), '#machine_name' => array('exists' => '\\Drupal\\comment\\Entity\\CommentType::load'), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$comment_type->isNew());
     $form['description'] = array('#type' => 'textarea', '#default_value' => $comment_type->getDescription(), '#description' => t('Describe this comment type. The text will be displayed on the <em>Comment types</em> administration overview page.'), '#title' => t('Description'));
     if ($comment_type->isNew()) {
         $options = array();
         foreach ($this->entityManager->getDefinitions() as $entity_type) {
             // Only expose entities that have field UI enabled, only those can
             // get comment fields added in the UI.
             if ($entity_type->get('field_ui_base_route')) {
                 $options[$entity_type->id()] = $entity_type->getLabel();
             }
         }
         $form['target_entity_type_id'] = array('#type' => 'select', '#default_value' => $comment_type->getTargetEntityTypeId(), '#title' => t('Target entity type'), '#options' => $options, '#description' => t('The target entity type can not be changed after the comment type has been created.'));
     } else {
         $form['target_entity_type_id_display'] = array('#type' => 'item', '#markup' => $this->entityManager->getDefinition($comment_type->getTargetEntityTypeId())->getLabel(), '#title' => t('Target entity type'));
     }
     if ($this->moduleHandler->moduleExists('content_translation')) {
         $form['language'] = array('#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings');
         $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('comment', $comment_type->id());
         $form['language']['language_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'comment', 'bundle' => $comment_type->id()), '#default_value' => $language_configuration);
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     /** @var \Drupal\rng\EventTypeInterface $event_type */
     $event_type = $this->entity;
     if (!$event_type->isNew()) {
         $form['#title'] = $this->t('Edit event type %label configuration', array('%label' => $event_type->label()));
     }
     if ($event_type->isNew()) {
         $bundle_options = [];
         // Generate a list of fieldable bundles which are not events.
         foreach ($this->entityManager->getDefinitions() as $entity_type) {
             if ($entity_type->isSubclassOf('\\Drupal\\Core\\Entity\\ContentEntityInterface')) {
                 foreach ($this->entityManager->getBundleInfo($entity_type->id()) as $bundle => $bundle_info) {
                     if (!$this->eventManager->eventType($entity_type->id(), $bundle)) {
                         $bundle_options[(string) $entity_type->getLabel()][$entity_type->id() . '.' . $bundle] = $bundle_info['label'];
                     }
                 }
             }
         }
         if ($this->moduleHandler->moduleExists('node')) {
             $form['#attached']['library'][] = 'rng/rng.admin';
             $form['entity_type'] = ['#type' => 'radios', '#options' => NULL, '#title' => $this->t('Event entity type'), '#required' => TRUE];
             $form['entity_type']['node']['radio'] = ['#type' => 'radio', '#title' => $this->t('Create a new content type'), '#description' => $this->t('Create a content type to use as an event type.'), '#return_value' => "node", '#parents' => array('entity_type'), '#default_value' => 'node'];
             $form['entity_type']['existing']['radio'] = ['#type' => 'radio', '#title' => $this->t('Use existing bundle'), '#description' => $this->t('Use an existing entity/bundle combination.'), '#return_value' => "existing", '#parents' => array('entity_type'), '#default_value' => ''];
             $form['entity_type']['existing']['container'] = ['#type' => 'container', '#attributes' => ['class' => ['rng-radio-indent']]];
         }
         $form['entity_type']['existing']['container']['bundle'] = array('#type' => 'select', '#title' => $this->t('Bundle'), '#options' => $bundle_options, '#default_value' => $event_type->id(), '#disabled' => !$event_type->isNew(), '#empty_option' => $bundle_options ? NULL : t('No Bundles Available'));
     }
     $form['settings'] = array('#type' => 'fieldset', '#title' => $this->t('Settings'));
     // Mirror permission.
     $form['access']['mirror_update'] = array('#group' => 'settings', '#type' => 'checkbox', '#title' => t('Mirror manage registrations with update permission'), '#description' => t('Allow users to <strong>manage registrations</strong> if they have <strong>update</strong> permission on an event entity.'), '#default_value' => (bool) ($event_type->getEventManageOperation() !== NULL ? $event_type->getEventManageOperation() : TRUE));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('xmlsitemap.settings');
     $entity_types = $this->entityManager->getDefinitions();
     $labels = array();
     $default = array();
     $anonymous_user = new AnonymousUserSession();
     $bundles = $this->entityManager->getAllBundleInfo();
     foreach ($entity_types as $entity_type_id => $entity_type) {
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         $labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
     }
     asort($labels);
     $form = array('#labels' => $labels);
     $form['entity_types'] = array('#title' => $this->t('Custom sitemap entities settings'), '#type' => 'checkboxes', '#options' => $labels, '#default_value' => $default);
     $form['settings'] = array('#tree' => TRUE);
     foreach ($labels as $entity_type_id => $label) {
         $entity_type = $entity_types[$entity_type_id];
         $form['settings'][$entity_type_id] = array('#type' => 'container', '#entity_type' => $entity_type_id, '#bundle_label' => $entity_type->getBundleLabel() ? $entity_type->getBundleLabel() : $label, '#title' => $entity_type->getBundleLabel() ? $entity_type->getBundleLabel() : $label, '#states' => array('visible' => array(':input[name="entity_types[' . $entity_type_id . ']"]' => array('checked' => TRUE))), 'types' => array('#type' => 'table', '#tableselect' => TRUE, '#default_value' => array(), '#header' => array(array('data' => $entity_type->getBundleLabel() ? $entity_type->getBundleLabel() : $label, 'class' => array('bundle')), array('data' => $this->t('Sitemap settings'), 'class' => array('operations'))), '#empty' => $this->t('No content available.')));
         foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
             $form['settings'][$entity_type_id][$bundle]['settings'] = array('#type' => 'item', '#label' => $bundle_info['label']);
             $form['settings'][$entity_type_id]['types'][$bundle] = array('bundle' => array('#markup' => SafeMarkup::checkPlain($bundle_info['label'])), 'operations' => ['#type' => 'operations', '#links' => ['configure' => ['title' => $this->t('Configure'), 'url' => Url::fromRoute('xmlsitemap.admin_settings_bundle', array('entity' => $entity_type_id, 'bundle' => $bundle, 'query' => drupal_get_destination()))]]]);
             $form['settings'][$entity_type_id]['types']['#default_value'][$bundle] = xmlsitemap_link_bundle_check_enabled($entity_type_id, $bundle);
             if (xmlsitemap_link_bundle_check_enabled($entity_type_id, $bundle)) {
                 $default[$entity_type_id] = $entity_type_id;
             }
         }
     }
     $form['entity_types']['#default_value'] = $default;
     $form = parent::buildForm($form, $form_state);
     $form['actions']['submit']['#value'] = $this->t('Save');
     return $form;
 }
 /**
  * Listener for the ConfigImporter import event.
  */
 public function onConfigImporterImport()
 {
     $entity_types = array_filter($this->entityManager->getDefinitions(), function (EntityTypeInterface $entity_type) {
         return $entity_type->isTranslatable();
     });
     $this->updateDefinitions($entity_types);
 }
 /**
  * Gets a list of participating entity types.
  *
  * The list consists of all content entity types with a delete-multiple-form
  * link template.
  *
  * @return \Drupal\Core\Entity\EntityTypeInterface[]
  *   The participating entity types, keyed by entity type id.
  */
 protected function getParticipatingEntityTypes()
 {
     $entity_types = $this->entityTypeManager->getDefinitions();
     $entity_types = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
         return $entity_type->isSubclassOf(ContentEntityInterface::class) && $entity_type->hasLinkTemplate('delete-multiple-form');
     });
     return $entity_types;
 }
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $entity_types = $this->entityManager->getDefinitions();
     $this->derivatives = array();
     foreach ($entity_types as $entity_type_id => $entity_type) {
         $this->derivatives[$entity_type_id] = array('id' => 'entity:' . $entity_type_id, 'provider' => 'views', 'title' => $entity_type->getLabel(), 'help' => $this->t('Validate @label', array('@label' => $entity_type->getLabel())), 'entity_type' => $entity_type_id, 'class' => $base_plugin_definition['class']);
     }
     return $this->derivatives;
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         $this->derivatives[$entity_type_id] = $base_plugin_definition;
         $this->derivatives[$entity_type_id]['entity_types'] = array($entity_type_id);
         $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', array('@entity_type' => $entity_type->getLabel()));
         $this->derivatives[$entity_type_id]['base_plugin_label'] = (string) $base_plugin_definition['label'];
     }
     return parent::getDerivativeDefinitions($base_plugin_definition);
 }
 /**
  * Listener for migration imports.
  */
 public function onMigrateImport(MigrateImportEvent $event)
 {
     $migration = $event->getMigration();
     $configuration = $migration->getDestinationConfiguration();
     $entity_types = NestedArray::getValue($configuration, ['content_translation_update_definitions']);
     if ($entity_types) {
         $entity_types = array_intersect_key($this->entityManager->getDefinitions(), array_flip($entity_types));
         $this->updateDefinitions($entity_types);
     }
 }
 /**
  * Returns an array of auto_entitylabel permissions
  *
  * @return array
  */
 public function autoEntityLabelPermissions()
 {
     $permissions = [];
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Create a permission for each fieldable entity to manage
         // the entity labels.
         $permissions['administer ' . $entity_type_id . ' labels'] = ['title' => $this->t('%entity_label: Administer Entity Labels', ['%entity_label' => $entity_type->getLabel()]), 'restrict access' => TRUE];
     }
     return $permissions;
 }
 /**
  * {@inheritdoc}
  */
 public function getSupportedEntityTypes()
 {
     $supported_types = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($this->isSupported($entity_type_id)) {
             $supported_types[$entity_type_id] = $entity_type;
         }
     }
     return $supported_types;
 }
Example #14
0
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Just add support for entity types which have a views integration.
         if (($base_table = $entity_type->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityManager->hasHandler($entity_type_id, 'view_builder')) {
             $this->derivatives[$entity_type_id] = array('id' => 'entity:' . $entity_type_id, 'provider' => 'views', 'title' => $entity_type->getLabel(), 'help' => t('Display the @label', array('@label' => $entity_type->getLabel())), 'base' => array($entity_type->getDataTable() ?: $entity_type->getBaseTable()), 'entity_type' => $entity_type_id, 'display_types' => array('normal'), 'class' => $base_plugin_definition['class']);
         }
     }
     return $this->derivatives;
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->hasViewBuilderClass()) {
             $this->derivatives[$entity_type_id] = $base_plugin_definition;
             $this->derivatives[$entity_type_id]['admin_label'] = $this->t('Entity view (@label)', ['@label' => $entity_type->getLabel()]);
             $this->derivatives[$entity_type_id]['context'] = ['entity' => new ContextDefinition('entity:' . $entity_type_id)];
         }
     }
     return $this->derivatives;
 }
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Only allow content entities and ignore configuration entities.
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         $this->derivatives[$entity_type_id] = ['label' => $this->t('After updating @entity_type', ['@entity_type' => $entity_type->getLowercaseLabel()]), 'category' => $entity_type->getLabel(), 'entity_type_id' => $entity_type_id, 'context' => [$entity_type_id => ['type' => "entity:{$entity_type_id}", 'label' => $entity_type->getLabel()]]] + $base_plugin_definition;
     }
     return $this->derivatives;
 }
 /**
  * Returns an array of better formats permissions.
  *
  * @return array
  */
 public function permissions()
 {
     $permissions = [];
     // Generate permissions for each entity type.
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->get('field_ui_base_route')) {
             $permissions['hide format selection for ' . $entity_type_id] = ['title' => $this->t('Hide format selection for @label', ['@label' => $entity_type->getLabel()])];
         }
     }
     return $permissions;
 }
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Only allow content entities and ignore configuration entities.
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         $this->derivatives["entity:{$entity_type_id}"] = ['label' => $this->t('Create @entity_type path alias', ['@entity_type' => $entity_type->getLowercaseLabel()]), 'category' => $this->t('Path'), 'entity_type_id' => $entity_type_id, 'context' => ['entity' => new ContextDefinition("entity:{$entity_type_id}", $entity_type->getLabel(), $this->t('The @entity_type for which to create a path alias.', ['@entity_type' => $entity_type->getLowercaseLabel()])), 'alias' => new ContextDefinition('string', $this->t('Path alias'), $this->t("Specify an alternative path by which the content can be accessed. For example, 'about' for an about page. Use a relative path and do not add a trailing slash."))], 'provides' => []] + $base_plugin_definition;
     }
     return $this->derivatives;
 }
 /**
  * {@inheritdoc}
  */
 public function validate($module)
 {
     $entity_types = $this->entityManager->getDefinitions();
     $reasons = [];
     foreach ($entity_types as $entity_type) {
         if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
             $reasons[] = $this->t('There is content for the entity type: @entity_type. <a href=":url">Remove @entity_type_plural</a>.', ['@entity_type' => $entity_type->getLabel(), '@entity_type_plural' => $entity_type->getPluralLabel(), ':url' => Url::fromRoute('system.prepare_modules_entity_uninstall', ['entity_type_id' => $entity_type->id()])->toString()]);
         }
     }
     return $reasons;
 }
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         $this->derivatives["{$entity_type_id}.auto_label_tab"] = array('route_name' => "entity.{$entity_type_id}.auto_label", 'title' => 'Auto Label', 'base_route' => "entity.{$entity_type_id}.edit_form", 'weight' => 100);
     }
     foreach ($this->derivatives as &$entry) {
         $entry += $base_plugin_definition;
     }
     return $this->derivatives;
 }
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = array();
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         if (!($route_name = $entity_type->get('field_ui_base_route'))) {
             continue;
         }
         $this->derivatives["entity_layout_{$entity_type_id}_block_add"] = ['route_name' => "entity_layout.{$entity_type_id}.layout", 'title' => $this->t('Add block'), 'appears_on' => "entity_layout.{$entity_type_id}.layout"] + $base_plugin_definition;
     }
     return $this->derivatives;
 }
 /**
  * {@inheritdoc}
  */
 public function validate($module)
 {
     $entity_types = $this->entityManager->getDefinitions();
     $reasons = array();
     foreach ($entity_types as $entity_type) {
         if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
             $reasons[] = $this->t('There is content for the entity type: @entity_type', array('@entity_type' => $entity_type->getLabel()));
         }
     }
     return $reasons;
 }
Example #23
0
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->get('field_ui_base_route')) {
             $this->derivatives["field_storage_config_add_{$entity_type_id}"] = array('route_name' => "field_ui.field_storage_config_add_{$entity_type_id}", 'title' => $this->t('Add field'), 'appears_on' => array("entity.{$entity_type_id}.field_ui_fields"));
         }
     }
     foreach ($this->derivatives as &$entry) {
         $entry += $base_plugin_definition;
     }
     return $this->derivatives;
 }
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->hasLinkTemplate('version-history')) {
             $this->derivatives[$entity_type_id] = array('route_name' => "entity.{$entity_type_id}.version_history", 'title' => $this->t('Revisions'), 'base_route' => "entity.{$entity_type_id}.canonical", 'weight' => 20);
         }
     }
     foreach ($this->derivatives as &$derivative) {
         $derivative += $base_plugin_definition;
     }
     return $this->derivatives;
 }
 /**
  * {@inheritdoc}
  */
 public function getCompatibleEntities()
 {
     // If the entities are yet to be populated, get the entity definitions from
     // the entity manager.
     if (empty($this->compatibleEntities)) {
         foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_definition) {
             // If this entity has a render controller, it has a printable version.
             if ($entity_definition->hasHandlerClass('view_builder')) {
                 $this->compatibleEntities[$entity_type] = $entity_definition;
             }
         }
     }
     return $this->compatibleEntities;
 }
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         $has_export_path = $entity_type->hasLinkTemplate('rdf-export');
         if ($has_export_path) {
             $this->derivatives["{$entity_type_id}.rdf_export_tab"] = array('route_name' => "entity.{$entity_type_id}.rdf_export", 'title' => $this->t('Metadata'), 'base_route' => "entity.{$entity_type_id}.canonical", 'weight' => 100);
         }
     }
     foreach ($this->derivatives as &$entry) {
         $entry += $base_plugin_definition;
     }
     return $this->derivatives;
 }
Example #27
0
 /**
  * Returns an array of field UI permissions.
  *
  * @return array
  */
 public function fieldPermissions()
 {
     $permissions = [];
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->get('field_ui_base_route')) {
             // Create a permission for each fieldable entity to manage
             // the fields and the display.
             $permissions['administer ' . $entity_type_id . ' fields'] = ['title' => $this->t('%entity_label: Administer fields', ['%entity_label' => $entity_type->getLabel()]), 'restrict access' => TRUE];
             $permissions['administer ' . $entity_type_id . ' form display'] = ['title' => $this->t('%entity_label: Administer form display', ['%entity_label' => $entity_type->getLabel()])];
             $permissions['administer ' . $entity_type_id . ' display'] = ['title' => $this->t('%entity_label: Administer display', ['%entity_label' => $entity_type->getLabel()])];
         }
     }
     return $permissions;
 }
  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
      $has_canonical = $entity_type->hasLinkTemplate('canonical');

      if ($has_canonical) {
        $this->derivatives[$entity_type_id] = $base_plugin_definition;
        $this->derivatives[$entity_type_id]['id'] = $base_plugin_definition['id'] . ':' . $entity_type_id;
        $this->derivatives[$entity_type_id]['label'] = $entity_type->getLabel();
        $this->derivatives[$entity_type_id]['target_entity'] = $entity_type_id;
        $this->derivatives[$entity_type_id]['base_plugin_label'] = (string) $base_plugin_definition['label'];
      }
    }

    return parent::getDerivativeDefinitions($base_plugin_definition);
  }
Example #29
0
 /**
  * Sets up and returns the entity definitions list.
  */
 public function listTypes()
 {
     if (count($this->definitions)) {
         return $this->definitions;
     }
     foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
         if ($definition->isSubclassOf('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
             $this->definitions[$entity_type] = $definition;
             $prefix = $definition->getConfigPrefix();
             $this->typesByPrefix[$prefix] = $entity_type;
         }
     }
     ksort($this->definitions);
     return $this->definitions;
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp($import_test_views = TRUE)
 {
     parent::setUp();
     $this->eventDispatcher = $this->container->get('event_dispatcher');
     $this->eventSubscriber = $this->container->get('views.entity_schema_subscriber');
     $this->entityDefinitionUpdateManager = $this->container->get('entity.definition_update_manager');
     $this->entityManager = $this->container->get('entity.manager');
     $this->state = $this->container->get('state');
     $this->database = $this->container->get('database');
     // Install every entity type's schema that wasn't installed in the parent
     // method.
     foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(array('user', 'entity_test'))) as $entity_type_id => $entity_type) {
         $this->installEntitySchema($entity_type_id);
     }
 }