本文整理汇总了PHP中Drupal\Core\Field\FieldItemBase类的典型用法代码示例。如果您正苦于以下问题:PHP FieldItemBase类的具体用法?PHP FieldItemBase怎么用?PHP FieldItemBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FieldItemBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setValue
/**
* Overrides \Drupal\Core\TypedData\FieldItemBase::setValue().
*
* @param array|null $values
* An array of property values.
*/
public function setValue($values, $notify = TRUE)
{
parent::setValue($values);
$this->populateComputedValues();
}
开发者ID:seongbae,项目名称:drumo-distribution,代码行数:11,代码来源:GeofieldItem.php
示例2: 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
示例3: 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
示例4: 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
示例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: 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
示例7: onChange
/**
* {@inheritdoc}
*/
public function onChange($property_name)
{
parent::onChange($property_name);
// Enforce that the computed date is recalculated.
if ($property_name == 'value') {
$this->date = NULL;
}
}
开发者ID:alnutile,项目名称:drunatra,代码行数:11,代码来源:DateTimeItem.php
示例8: fieldSettingsForm
/**
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state)
{
$element = parent::fieldSettingsForm($form, $form_state);
$range = $this->getSetting('range');
$element['range'] = array('#type' => 'textfield', '#title' => t('Range'), '#description' => t('The range of weights available to select. For
example, a range of 20 will allow you to select a weight between -20
and 20.'), '#default_value' => $range, '#size' => 5);
return $element;
}
开发者ID:k-zafar,项目名称:barney_river,代码行数:12,代码来源:WeightItem.php
示例9: setValue
/**
* {@inheritdoc}
*/
public function setValue($values, $notify = TRUE)
{
if (empty($values['data'])) {
$values['data'] = NULL;
} else {
$deserialized_data = unserialize((string) $values['data']);
$values['data'] = is_array($deserialized_data) ? $deserialized_data : NULL;
}
parent::setValue($values, $notify);
}
开发者ID:pedrocones,项目名称:geolocation,代码行数:13,代码来源:GeolocationItem.php
示例10: setValue
/**
* {@inheritdoc}
*/
public function setValue($values, $notify = TRUE)
{
// Unserialize the values.
// @todo The storage controller should take care of this, see
// SqlContentEntityStorage::loadFieldItems, see
// https://www.drupal.org/node/2414835
if (isset($values['query']) && is_string($values['query'])) {
$values['query'] = unserialize($values['query']);
}
parent::setValue($values, $notify);
}
开发者ID:aakb,项目名称:cfia,代码行数:14,代码来源:RedirectSourceItem.php
示例11: onChange
/**
* {@inheritdoc}
*/
public function onChange($property_name, $notify = TRUE)
{
// Unset processed properties that are affected by the change.
foreach ($this->definition->getPropertyDefinitions() as $property => $definition) {
if ($definition->getClass() == '\\Drupal\\text\\TextProcessed') {
if ($property_name == 'format' || $definition->getSetting('text source') == $property_name) {
$this->writePropertyValue($property, NULL);
}
}
}
parent::onChange($property_name, $notify);
}
开发者ID:nstielau,项目名称:drops-8,代码行数:15,代码来源:TextItemBase.php
示例12: setValue
/**
* {@inheritdoc}
*/
public function setValue($values, $notify = TRUE)
{
// Treat the values as property value of the first property, if no array is
// given.
if (is_string($values)) {
$values = unserialize($values);
if (!is_array($values)) {
$values = array();
}
}
$values = array('value' => $values);
parent::setValue($values, $notify);
}
开发者ID:alnutile,项目名称:drunatra,代码行数:16,代码来源:SerializedItem.php
示例13: 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
示例14: preSave
/**
* {@inheritdoc}
*/
public function preSave()
{
parent::preSave();
// Merge field defaults on top of global ones.
$default_tags = metatag_get_default_tags();
// Get the value about to be saved.
$current_value = $this->value;
$current_tags = unserialize($current_value);
// Only include values that differ from the default.
// @TODO: When site defaults are added, account for those.
$tags_to_save = [];
foreach ($current_tags as $tag_id => $tag_value) {
if (!isset($default_tags[$tag_id]) || $tag_value != $default_tags[$tag_id]) {
$tags_to_save[$tag_id] = $tag_value;
}
}
// Update the value to only save overridden tags.
$this->value = serialize($tags_to_save);
}
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:22,代码来源:MetatagFieldItem.php
示例15: preSave
/**
* {@inheritdoc}
*/
public function preSave()
{
parent::preSave();
// Get the field's default values.
$field_default_tags_value = $this->getFieldDefaults();
$field_default_tags = unserialize($field_default_tags_value[0]['value']);
// Get the value about to be saved.
$current_value = $this->value;
$current_tags = unserialize($current_value);
// Only include values that differ from the default.
// @TODO: When site defaults are added, account for those.
$tags_to_save = array();
foreach ($current_tags as $tag_id => $tag_value) {
if ($tag_value != $field_default_tags[$tag_id]) {
$tags_to_save[$tag_id] = $tag_value;
}
}
// Update the value to only save overridden tags.
$this->value = serialize($tags_to_save);
}
开发者ID:dmyerson,项目名称:d8ecs,代码行数:23,代码来源:MetatagFieldItem.php
示例16: getConstraints
/**
* {@inheritdoc}
*/
public function getConstraints()
{
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
$settings = $this->getSettings();
$label = $this->getFieldDefinition()->getLabel();
if (!empty($settings['opacity'])) {
$min = 0;
$constraints[] = $constraint_manager->create('ComplexData', array('opacity' => array('Range' => array('min' => $min, 'minMessage' => t('%name: the opacity may be no less than %min.', array('%name' => $label, '%min' => $min))))));
$max = 1;
$constraints[] = $constraint_manager->create('ComplexData', array('opacity' => array('Range' => array('max' => $max, 'maxMessage' => t('%name: the opacity may be no greater than %max.', array('%name' => $label, '%max' => $max))))));
}
// @todo: Adapt constraint based on storage.
//$constraints[] = $constraint_manager->create('ComplexData', array(
// 'color' => array(
// 'Regex' => array(
// 'pattern' => '/^#(\d+)$/i',
// )
// ),
//));
return $constraints;
}
开发者ID:zindont,项目名称:emormapping,代码行数:25,代码来源:ColorFieldType.php
示例17: delete
public function delete()
{
$field_collection_item = $this->getFieldCollectionItem();
// Set a flag to remember that the host entity is being deleted. See
// \Drupal\field_collection\Entity\FieldCollectionItem::deleteHostEntityReference().
if ($field_collection_item !== NULL) {
$field_collection_item->field_collection_deleting = TRUE;
$field_collection_item->delete();
}
parent::delete();
}
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:11,代码来源:FieldCollection.php
示例18:
/**
* {@inheritdoc}
*/
function __construct($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL, $provider_manager)
{
parent::__construct($definition, $name, $parent);
$this->providerManager = $provider_manager;
}
开发者ID:robertfoleyjr,项目名称:robertfoleyjr-d8,代码行数:8,代码来源:VideoEmbedField.php
示例19: defaultStorageSettings
/**
* {@inheritdoc}
*/
public static function defaultStorageSettings()
{
return array('foreign_key_name' => 'shape') + parent::defaultStorageSettings();
}
开发者ID:sarahwillem,项目名称:OD8,代码行数:7,代码来源:ShapeItem.php
示例20: preSave
/**
* {@inheritdoc}
*/
public function preSave()
{
parent::preSave();
$choices = $this->value;
mailchimp_lists_process_subscribe_form_choices($choices, $this, $this->getEntity());
}
开发者ID:rafavergara,项目名称:ddv8,代码行数:9,代码来源:MailchimpListsSubscription.php
注:本文中的Drupal\Core\Field\FieldItemBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论