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


PHP FieldItemBase::setValue方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($values, $notify = TRUE)
 {
     // Treat the values as property value of the language property, if no array
     // is given as this handles language codes and objects.
     if (isset($values) && !is_array($values)) {
         $this->set('language', $values, $notify);
     } else {
         // Make sure that the 'language' property gets set as 'value'.
         if (isset($values['value']) && !isset($values['language'])) {
             $values['language'] = $values['value'];
         }
         parent::setValue($values, $notify);
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:17,代码来源:LanguageItem.php

示例5: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($values, $notify = TRUE)
 {
     // Treat the values as property value of the language property, if no array
     // is given as this handles language codes and objects.
     if (isset($values) && !is_array($values)) {
         // Directly update the property instead of invoking the parent, so that
         // the language property can take care of updating the language code
         // property.
         $this->properties['language']->setValue($values, $notify);
         // If notify was FALSE, ensure the value property gets synched.
         if (!$notify) {
             $this->set('value', $this->properties['language']->getTargetIdentifier(), FALSE);
         }
     } else {
         // Make sure that the 'language' property gets set as 'value'.
         if (isset($values['value']) && !isset($values['language'])) {
             $values['language'] = $values['value'];
         }
         parent::setValue($values, $notify);
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:LanguageItem.php

示例6: 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

示例7: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($values, $notify = TRUE)
 {
     // Treat the values as property value of the main property, if no array is
     // given.
     if (isset($values) && !is_array($values)) {
         $values = [static::mainPropertyName() => $values];
     }
     if (isset($values)) {
         $values += ['options' => []];
     }
     // Unserialize the values.
     // @todo The storage controller should take care of this, see
     //   SqlContentEntityStorage::loadFieldItems, see
     //   https://www.drupal.org/node/2414835
     if (is_string($values['options'])) {
         $values['options'] = unserialize($values['options']);
     }
     parent::setValue($values, $notify);
 }
开发者ID:DrupalCamp-NYC,项目名称:dcnyc16,代码行数:22,代码来源:LinkItem.php

示例8: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($values, $notify = TRUE)
 {
     if (isset($values) && !is_array($values)) {
         // If either a scalar or an object was passed as the value for the item,
         // assign it to the 'entity' property since that works for both cases.
         $this->set('entity', $values, $notify);
     } else {
         parent::setValue($values, FALSE);
         // Support setting the field item with only one property, but make sure
         // values stay in sync if only property is passed.
         if (isset($values['target_id']) && !isset($values['entity'])) {
             $this->onChange('target_id', FALSE);
         } elseif (!isset($values['target_id']) && isset($values['entity'])) {
             $this->onChange('entity', FALSE);
         } elseif (isset($values['target_id']) && isset($values['entity'])) {
             // If both properties are passed, verify the passed values match. The
             // only exception we allow is when we have a new entity: in this case
             // its actual id and target_id will be different, due to the new entity
             // marker.
             $entity_id = $this->get('entity')->getTargetIdentifier();
             if ($entity_id != $values['target_id'] && ($values['target_id'] != static::$NEW_ENTITY_MARKER || !$this->entity->isNew())) {
                 throw new \InvalidArgumentException('The target id and entity passed to the entity reference item do not match.');
             }
         }
         // Notify the parent if necessary.
         if ($notify && $this->parent) {
             $this->parent->onChange($this->getName());
         }
     }
 }
开发者ID:brstde,项目名称:gap1,代码行数:33,代码来源:EntityReferenceItem.php

示例9: setValue

 /**
  * {@inheritdoc}
  */
 public function setValue($values, $notify = TRUE)
 {
     if (isset($values) && !is_array($values)) {
         // If either a scalar or an object was passed as the value for the item,
         // assign it to the 'entity' property since that works for both cases.
         $this->set('entity', $values, $notify);
     } else {
         parent::setValue($values, FALSE);
         // Support setting the field item with only one property, but make sure
         // values stay in sync if only property is passed.
         // NULL is a valid value, so we use array_key_exists().
         if (is_array($values) && array_key_exists('target_id', $values) && !isset($values['entity'])) {
             $this->onChange('target_id', FALSE);
         } elseif (is_array($values) && !array_key_exists('target_id', $values) && isset($values['entity'])) {
             $this->onChange('entity', FALSE);
         } elseif (is_array($values) && array_key_exists('target_id', $values) && isset($values['entity'])) {
             // If both properties are passed, verify the passed values match. The
             // only exception we allow is when we have a new entity: in this case
             // its actual id and target_id will be different, due to the new entity
             // marker.
             $entity_id = $this->get('entity')->getTargetIdentifier();
             // If the entity has been saved and we're trying to set both the
             // target_id and the entity values with a non-null target ID, then the
             // value for target_id should match the ID of the entity value.
             if (!$this->entity->isNew() && $values['target_id'] !== NULL && $entity_id !== $values['target_id']) {
                 throw new \InvalidArgumentException('The target id and entity passed to the entity reference item do not match.');
             }
         }
         // Notify the parent if necessary.
         if ($notify && $this->parent) {
             $this->parent->onChange($this->getName());
         }
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:37,代码来源:EntityReferenceItem.php


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