本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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'];
}
}
示例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;
}