protected function getConfigTypes()
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type => $definition) {
         if ($definition->isSubclassOf('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface')) {
             $this->definitions[$entity_type] = $definition;
         }
     }
     $entity_types = array_map(function ($definition) {
         return $definition->getLabel();
     }, $this->definitions);
     uasort($entity_types, 'strnatcasecmp');
     $config_types = array('system.simple' => $this->trans('commands.config.export.single.options.simple-configuration')) + $entity_types;
     return $config_types;
 }
  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = [];

    /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
    foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
      $has_clone_path = $entity_type->hasLinkTemplate('clone-form');
      $has_canonical_path = $entity_type->hasLinkTemplate('canonical');

      if ($has_clone_path) {
        $this->derivatives["$entity_type_id.clone_tab"] = array(
          'route_name' => "entity.$entity_type_id.clone_form",
          'title' => $this->translationManager->translate('Clone'),
          'base_route' => "entity.$entity_type_id." . ($has_canonical_path ? "canonical" : "edit_form"),
          'weight' => 100,
        );
      }
    }

    return $this->derivatives;
  }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $field_key = '')
 {
     // Initialize field.
     $field = array();
     // Fetch field if it already exists.
     if (!empty($field_key)) {
         $field = $this->config('ds.field.' . $field_key)->get();
     }
     // Save the field for future reuse.
     $this->field = $field;
     $form['name'] = array('#title' => t('Label'), '#type' => 'textfield', '#default_value' => isset($field['label']) ? $field['label'] : '', '#description' => t('The human-readable label of the field.'), '#maxlength' => 128, '#required' => TRUE, '#size' => 30);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => isset($field['id']) ? $field['id'] : '', '#maxlength' => 32, '#description' => t('The machine-readable name of this field. This name must contain only lowercase letters and underscores. This name must be unique.'), '#disabled' => !empty($field['id']), '#machine_name' => array('exists' => array($this, 'uniqueFieldName'), 'source' => array('name')));
     $entity_options = array();
     $entities = $this->entityTypeManager->getDefinitions();
     foreach ($entities as $entity_type => $entity_info) {
         if ($entity_info->get('field_ui_base_route') || $entity_type == 'ds_views') {
             $entity_options[$entity_type] = Unicode::ucfirst(str_replace('_', ' ', $entity_type));
         }
     }
     $form['entities'] = array('#title' => t('Entities'), '#description' => t('Select the entities for which this field will be made available.'), '#type' => 'checkboxes', '#required' => TRUE, '#options' => $entity_options, '#default_value' => isset($field['entities']) ? $field['entities'] : array());
     $form['ui_limit'] = array('#title' => t('Limit field'), '#description' => t('Limit this field on field UI per bundles and/or view modes. The values are in the form of $bundle|$view_mode, where $view_mode may be either a view mode set to use custom settings, or \'default\'. You may use * to select all, e.g article|*, *|full or *|*. Enter one value per line.'), '#type' => 'textarea', '#default_value' => isset($field['ui_limit']) ? $field['ui_limit'] : '');
     $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 100);
     return $form;
 }