Example #1
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     parent::__construct($values, $entity_type);
     $plugin = $this->editorPluginManager()->createInstance($this->editor);
     // Initialize settings, merging module-provided defaults.
     $default_settings = $plugin->getDefaultSettings();
     $default_settings += \Drupal::moduleHandler()->invokeAll('editor_default_settings', array($this->editor));
     \Drupal::moduleHandler()->alter('editor_default_settings', $default_settings, $this->editor);
     $this->settings += $default_settings;
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     parent::__construct($values, $entity_type);
     // The config entity id looks like the plugin id but uses __ instead of :
     // because : is not valid for config entities.
     if (!isset($this->plugin_id) && isset($this->id)) {
         // Generate plugin_id on first entity creation.
         $this->plugin_id = str_replace('.', ':', $this->id);
     }
 }
 /**
  * Constructs a ContentLanguageSettings object.
  *
  * In most cases, Field entities are created via
  * entity_create('field_config', $values), where $values is the same
  * parameter as in this constructor.
  *
  * @param array $values
  *   An array of the referring entity bundle with:
  *   - target_entity_type_id: The entity type.
  *   - target_bundle: The bundle.
  *   Other array elements will be used to set the corresponding properties on
  *   the class; see the class property documentation for details.
  *
  * @see entity_create()
  */
 public function __construct(array $values, $entity_type = 'language_content_settings')
 {
     if (empty($values['target_entity_type_id'])) {
         throw new ContentLanguageSettingsException('Attempt to create content language settings without a target_entity_type_id.');
     }
     if (empty($values['target_bundle'])) {
         throw new ContentLanguageSettingsException('Attempt to create content language settings without a target_bundle.');
     }
     parent::__construct($values, $entity_type);
 }
Example #4
0
 /**
  * Constructs a FieldStorageConfig object.
  *
  * @param array $values
  *   An array of field properties, keyed by property name. Most array
  *   elements will be used to set the corresponding properties on the class;
  *   see the class property documentation for details. Some array elements
  *   have special meanings and a few are required. Special elements are:
  *   - name: required. As a temporary Backwards Compatibility layer right now,
  *     a 'field_name' property can be accepted in place of 'id'.
  *   - entity_type: required.
  *   - type: required.
  *
  * In most cases, Field entities are created via
  * entity_create('field_storage_config', $values)), where $values is the same
  * parameter as in this constructor.
  *
  * @see entity_create()
  */
 public function __construct(array $values, $entity_type = 'field_storage_config')
 {
     // Check required properties.
     if (empty($values['field_name'])) {
         throw new FieldException('Attempt to create a field storage without a field name.');
     }
     if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['field_name'])) {
         throw new FieldException("Attempt to create a field storage {$values['field_name']} with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character");
     }
     if (empty($values['type'])) {
         throw new FieldException("Attempt to create a field storage {$values['field_name']} with no type.");
     }
     if (empty($values['entity_type'])) {
         throw new FieldException("Attempt to create a field storage {$values['field_name']} with no entity_type.");
     }
     parent::__construct($values, $entity_type);
 }
Example #5
0
 /**
  * Constructor.
  *
  * @param array $values
  * @param string $entityType
  *   The name of the new State. If '(creation)', a CreationState is generated.
  */
 public function __construct(array $values = array(), $entityType = 'workflow_state')
 {
     // Please be aware that $entity_type and $entityType are different things!
     $id = isset($values['id']) ? $values['id'] : '';
     // Keep official name and external name equal. Both are required.
     // @todo: still needed? test import, manual creation, programmatic creation, etc.
     if (!isset($values['label']) && $id) {
         $values['label'] = $id;
     }
     // Set default values for '(creation)' state.
     if ($id == WORKFLOW_CREATION_STATE_NAME) {
         $values['id'] = '';
         // Clear ID; will be set in save().
         $values['sysid'] = WORKFLOW_CREATION_STATE;
         $values['weight'] = WORKFLOW_CREATION_DEFAULT_WEIGHT;
         $values['label'] = '(creation)';
         // machine_name;
     }
     parent::__construct($values, $entityType);
     // Reset cache.
     self::$states = array();
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     parent::__construct($values, $entity_type);
     $plugin = $this->editorPluginManager()->createInstance($this->editor);
     $this->settings += $plugin->getDefaultSettings();
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     parent::__construct($values, $entity_type);
 }
Example #8
0
 /**
  * {@inheritdoc}
  *
  * @throws \Drupal\breakpoint\InvalidBreakpointNameException
  *   Exception thrown if $values['name'] is empty.
  */
 public function __construct(array $values, $entity_type = 'breakpoint_group')
 {
     // Check required properties.
     if (empty($values['name'])) {
         throw new InvalidBreakpointNameException('Attempt to create an unnamed breakpoint group.');
     }
     parent::__construct($values, $entity_type);
 }
Example #9
0
 /**
  * Constructs a new Importer object.
  */
 public function __construct(array $values, $entity_type)
 {
     // Move plugin configuration separately from values.
     foreach ($this->getPluginTypes() as $type) {
         if (isset($values[$type])) {
             $this->plugins[$type] = $values[$type];
             unset($values[$type]);
         }
     }
     parent::__construct($values, $entity_type);
     // Prepare plugin bags. This has to be done after all configuration is done.
     foreach ($this->getPluginTypes() as $type) {
         $this->initPluginBag($type);
     }
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     parent::__construct($values, $entity_type);
     // Merge in default options.
     // @todo Use a dedicated method, like defaultConfiguration() for plugins?
     //   And/or, better still, do this in postCreate() (and preSave()?) and not
     //   on every load.
     $this->options += array('cron_limit' => \Drupal::config('search_api.settings')->get('default_cron_limit'), 'index_directly' => TRUE);
 }
 /**
  * Entity class functions.
  */
 public function __construct(array $values = array(), $entityType = NULL)
 {
     // Please be aware that $entity_type and $entityType are different things!
     $result = parent::__construct($values, $entity_type = 'workflow_config_transition');
     return $result;
 }
Example #12
0
 /**
  * Constructs a FieldInstanceConfig object.
  *
  * In most cases, Field instance entities are created via
  * entity_create('field_instance_config', $values), where $values is the same
  * parameter as in this constructor.
  *
  * @param array $values
  *   An array of field instance properties, keyed by property name. The
  *   storage associated to the instance can be specified either with:
  *   - field_storage: the FieldStorageConfigInterface object,
  *   or by referring to an existing field storage in the current configuration
  *   with:
  *   - field_name: The field name.
  *   - entity_type: The entity type.
  *   Additionally, a 'bundle' property is required to indicate the entity
  *   bundle to which the instance is attached to. Other array elements will be
  *   used to set the corresponding properties on the class; see the class
  *   property documentation for details.
  *
  * @see entity_create()
  */
 public function __construct(array $values, $entity_type = 'field_instance_config')
 {
     // Allow either an injected FieldStorageConfig object, or a field_name and
     // entity_type.
     if (isset($values['field_storage'])) {
         if (!$values['field_storage'] instanceof FieldStorageConfigInterface) {
             throw new FieldException('Attempt to create a configurable field instance for a non-configurable field storage.');
         }
         $field_storage = $values['field_storage'];
         $values['field_name'] = $field_storage->getName();
         $values['entity_type'] = $field_storage->getTargetEntityTypeId();
         $this->fieldStorage = $field_storage;
     } else {
         if (empty($values['field_name'])) {
             throw new FieldException('Attempt to create a field instance without a field_name.');
         }
         if (empty($values['entity_type'])) {
             throw new FieldException(String::format('Attempt to create a field instance @field_name without an entity_type.', array('@field_name' => $values['field_name'])));
         }
     }
     // 'bundle' is required in either case.
     if (empty($values['bundle'])) {
         throw new FieldException(String::format('Attempt to create a field instance @field_name without a bundle.', array('@field_name' => $values['field_name'])));
     }
     // Discard the 'field_type' entry that is added in config records to ease
     // schema generation and mapping settings from storage.
     // @see Drupal\field\Entity\FieldInstanceConfig::toArray().
     unset($values['field_type']);
     parent::__construct($values, $entity_type);
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     if (isset($values['usages'])) {
         $usages_data = $values['usages'];
         $values['usages'] = [];
         foreach ($usages_data as $usage_data) {
             $usage = new Usage();
             $usage->setStart($usage_data['start'])->setEnd($usage_data['end'])->setCountryCode($usage_data['countryCode']);
             $values['usages'][] = $usage;
         }
     }
     parent::__construct($values, $entity_type);
 }
Example #14
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     parent::__construct($values, $entity_type);
     $this->tipsCollection = new TipsPluginCollection(\Drupal::service('plugin.manager.tour.tip'), $this->tips);
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type)
 {
     if (!isset($values['targetEntityType']) || !isset($values['bundle'])) {
         throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.');
     }
     if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
         throw new \InvalidArgumentException('EntityDisplay entities can only handle fieldable entity types.');
     }
     $this->renderer = \Drupal::service('renderer');
     // A plugin manager and a context type needs to be set by extending classes.
     if (!isset($this->pluginManager)) {
         throw new \RuntimeException('Missing plugin manager.');
     }
     if (!isset($this->displayContext)) {
         throw new \RuntimeException('Missing display context type.');
     }
     parent::__construct($values, $entity_type);
     $this->originalMode = $this->mode;
     $this->init();
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values, $entity_type_id = 'responsive_image_style')
 {
     parent::__construct($values, $entity_type_id);
 }
 /**
  * Overrides Drupal\config\ConfigEntityBase::__construct().
  */
 public function __construct(array $values, $entity_type)
 {
     parent::__construct($values, $entity_type);
     $this->loadBreakpointGroup();
     $this->loadAllMappings();
 }