本文整理汇总了PHP中Drupal\Core\Config\Entity\ConfigEntityBase::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigEntityBase::__construct方法的具体用法?PHP ConfigEntityBase::__construct怎么用?PHP ConfigEntityBase::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Entity\ConfigEntityBase
的用法示例。
在下文中一共展示了ConfigEntityBase::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* {@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;
}
示例2: __construct
/**
* {@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);
}
}
示例3: __construct
/**
* 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);
}
示例4: __construct
/**
* 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);
}
示例5: __construct
/**
* 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();
}
示例6: __construct
/**
* {@inheritdoc}
*/
public function __construct(array $values, $entity_type)
{
parent::__construct($values, $entity_type);
$plugin = $this->editorPluginManager()->createInstance($this->editor);
$this->settings += $plugin->getDefaultSettings();
}
示例7: __construct
/**
* {@inheritdoc}
*/
public function __construct(array $values, $entity_type)
{
parent::__construct($values, $entity_type);
}
示例8: __construct
/**
* {@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);
}
示例9: __construct
/**
* 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);
}
}
示例10: __construct
/**
* {@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);
}
示例11: __construct
/**
* 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;
}
示例12: __construct
/**
* 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);
}
示例13: __construct
/**
* {@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);
}
示例14: __construct
/**
* {@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);
}
示例15: __construct
/**
* {@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();
}