當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。