当前位置: 首页>>代码示例>>PHP>>正文


PHP Drupal::typedDataManager方法代码示例

本文整理汇总了PHP中Drupal::typedDataManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Drupal::typedDataManager方法的具体用法?PHP Drupal::typedDataManager怎么用?PHP Drupal::typedDataManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal的用法示例。


在下文中一共展示了Drupal::typedDataManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints = parent::getConstraints();
     $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('TestField' => array('value' => -1, 'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1))))));
     return $constraints;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:TestItem.php

示例2: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints = parent::getConstraints();
     $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('Regex' => array('pattern' => '/^[+-]?((\\d+(\\.\\d*)?)|(\\.\\d+))$/i'))));
     return $constraints;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:10,代码来源:DecimalItem.php

示例3: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints = parent::getConstraints();
     $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('Length' => array('max' => Email::EMAIL_MAX_LENGTH, 'maxMessage' => t('%name: the email address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH))))));
     return $constraints;
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:10,代码来源:EmailItem.php

示例4: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints = parent::getConstraints();
     $constraints[] = $manager->create('ComplexData', ['amount' => ['Regex' => ['pattern' => '/^[+-]?((\\d+(\\.\\d*)?)|(\\.\\d+))$/i']]]);
     return $constraints;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:10,代码来源:Price.php

示例5: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraints = parent::getConstraints();
     $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints[] = $constraint_manager->create('ComplexData', array('name' => array('Length' => array('max' => 64, 'maxMessage' => t('%name: may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => 64))))));
     return $constraints;
 }
开发者ID:novaFTL,项目名称:quiz-drupal8,代码行数:10,代码来源:MultipleChoice.php

示例6: getTypedDataManager

 /**
  * Gets the typed data manager.
  *
  * @return \Drupal\Core\TypedData\TypedDataManagerInterface
  *   The typed data manager.
  */
 public function getTypedDataManager()
 {
     if (empty($this->typedDataManager)) {
         $this->typedDataManager = \Drupal::typedDataManager();
     }
     return $this->typedDataManager;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:TypedDataTrait.php

示例7: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints = parent::getConstraints();
     $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('Length' => array('max' => static::COUNTRY_ISO2_MAXLENGTH, 'maxMessage' => t('%name: the country iso-2 code may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => static::COUNTRY_ISO2_MAXLENGTH))))));
     return $constraints;
 }
开发者ID:C4AProjects,项目名称:c4apage,代码行数:10,代码来源:CountryItem.php

示例8: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($value, $notify = TRUE)
 {
     $this->target = \Drupal::typedDataManager()->create($this->definition->getTargetDefinition(), $value);
     // Notify the parent of any changes.
     if ($notify && isset($this->parent)) {
         $this->parent->onChange($this->name);
     }
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:11,代码来源:DataReferenceBase.php

示例9: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $field_definition = BaseFieldDefinition::create('plugin:plugin_test_helper_mock');
     /** @var \Drupal\Core\Field\FieldItemListInterface $field_item_list */
     $field_item_list = \Drupal::typedDataManager()->create($field_definition);
     $field_item_list->appendItem();
     $this->fieldItem = $field_item_list->first();
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:12,代码来源:PluginCollectionItemBaseTest.php

示例10: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints = parent::getConstraints();
     if ($max_length = $this->getSetting('max_length')) {
         $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('Length' => array('max' => $max_length, 'maxMessage' => t('%name: the text may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length))))));
     }
     return $constraints;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:12,代码来源:TextItem.php

示例11: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraints = parent::getConstraints();
     // If this is an unsigned integer, add a validation constraint for the
     // integer to be positive.
     if ($this->getSetting('unsigned')) {
         $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
         $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('Range' => array('min' => 0, 'minMessage' => t('%name: The integer must be larger or equal to %min.', array('%name' => $this->getFieldDefinition()->getLabel(), '%min' => 0))))));
     }
     return $constraints;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:14,代码来源:IntegerItem.php

示例12: setConfig

 /**
  * Sets the value of a particular configuration option.
  *
  * @param string $name
  *   The name of the configuration option to set.
  * @param mixed $value
  *   The value to set.
  *
  * @todo This doesn't belong here. Move this into a new base class in
  *   https://www.drupal.org/node/1764380.
  * @todo This does not set a value in \Drupal::config(), so the name is confusing.
  *
  * @return \Drupal\Core\Executable\ExecutablePluginBase.
  *   The executable object for chaining.
  */
 public function setConfig($key, $value)
 {
     if ($definition = $this->getConfigDefinition($key)) {
         $typed_data = \Drupal::typedDataManager()->create($definition, $value);
         if ($typed_data->validate()->count() > 0) {
             throw new PluginException("The provided configuration value does not pass validation.");
         }
     }
     $this->configuration[$key] = $value;
     return $this;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:26,代码来源:ExecutablePluginBase.php

示例13: __construct

 /**
  * {@inheritdoc}
  */
 public function __construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL)
 {
     parent::__construct($definition, $name, $parent);
     // Initialize computed properties by default, such that they get cloned
     // with the whole item.
     foreach ($this->definition->getPropertyDefinitions() as $name => $definition) {
         if ($definition->isComputed()) {
             $this->properties[$name] = \Drupal::typedDataManager()->getPropertyInstance($this, $name);
         }
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:14,代码来源:FieldItemBase.php

示例14: getClass

 /**
  * {@inheritdoc}
  */
 public function getClass()
 {
     $class = isset($this->definition['class']) ? $this->definition['class'] : NULL;
     if (!empty($class)) {
         return $class;
     } else {
         // If a list definition is used but no class has been specified, derive
         // the default list class from the item type.
         $item_type_definition = \Drupal::typedDataManager()->getDefinition($this->getItemDefinition()->getDataType());
         if (!$item_type_definition) {
             throw new \LogicException("An invalid data type '{$this->getItemDefinition()->getDataType()}' has been specified for list items");
         }
         return $item_type_definition['list_class'];
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:18,代码来源:ListDataDefinition.php

示例15: getConstraints

 /**
  * {@inheritdoc}
  */
 public function getConstraints()
 {
     $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
     $constraints = parent::getConstraints();
     $settings = $this->getSettings();
     $label = $this->getFieldDefinition()->getLabel();
     if (!empty($settings['min'])) {
         $min = $settings['min'];
         $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('Range' => array('min' => $min, 'minMessage' => t('%name: the value may be no less than %min.', array('%name' => $label, '%min' => $min))))));
     }
     if (!empty($settings['max'])) {
         $max = $settings['max'];
         $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('Range' => array('max' => $max, 'maxMessage' => t('%name: the value may be no greater than %max.', array('%name' => $label, '%max' => $max))))));
     }
     return $constraints;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:19,代码来源:NumericItemBase.php


注:本文中的Drupal::typedDataManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。