當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ConfigEntityInterface::set方法代碼示例

本文整理匯總了PHP中Drupal\Core\Config\Entity\ConfigEntityInterface::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConfigEntityInterface::set方法的具體用法?PHP ConfigEntityInterface::set怎麽用?PHP ConfigEntityInterface::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Config\Entity\ConfigEntityInterface的用法示例。


在下文中一共展示了ConfigEntityInterface::set方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSaveRename

 /**
  * @covers ::save
  * @covers ::doSave
  *
  * @depends testSaveInsert
  */
 public function testSaveRename(ConfigEntityInterface $entity)
 {
     $config_object = $this->getMockBuilder('Drupal\\Core\\Config\\Config')->disableOriginalConstructor()->getMock();
     $config_object->expects($this->atLeastOnce())->method('isNew')->will($this->returnValue(FALSE));
     $config_object->expects($this->exactly(1))->method('setData');
     $config_object->expects($this->once())->method('save');
     $config_object->expects($this->atLeastOnce())->method('get')->willReturn([]);
     $this->cacheTagsInvalidator->expects($this->once())->method('invalidateTags')->with(array($this->entityTypeId . '_list'));
     $this->configFactory->expects($this->once())->method('rename')->willReturn($this->configFactory);
     $this->configFactory->expects($this->exactly(1))->method('getEditable')->with('the_config_prefix.bar')->will($this->returnValue($config_object));
     $this->configFactory->expects($this->exactly(2))->method('loadMultiple')->with(array('the_config_prefix.foo'))->will($this->returnValue(array()));
     $this->configFactory->expects($this->once())->method('get')->with('the_config_prefix.foo')->will($this->returnValue($config_object));
     // Performing a rename does not change the original ID until saving.
     $this->assertSame('foo', $entity->getOriginalId());
     $entity->set('id', 'bar');
     $this->assertSame('foo', $entity->getOriginalId());
     $this->entityQuery->expects($this->once())->method('condition')->with('uuid', 'bar')->will($this->returnSelf());
     $this->entityQuery->expects($this->once())->method('execute')->will($this->returnValue(array($entity->id())));
     $return = $this->entityStorage->save($entity);
     $this->assertSame(SAVED_UPDATED, $return);
     $this->assertSame('bar', $entity->getOriginalId());
 }
開發者ID:318io,項目名稱:318-io,代碼行數:28,代碼來源:ConfigEntityStorageTest.php

示例2: updateFromStorageRecord

 /**
  * {@inheritdoc}
  */
 public function updateFromStorageRecord(ConfigEntityInterface $entity, array $values)
 {
     $entity->original = clone $entity;
     $data = $this->mapFromStorageRecords(array($values));
     $updated_entity = current($data);
     foreach (array_keys($values) as $property) {
         $value = $updated_entity->get($property);
         $entity->set($property, $value);
     }
     return $entity;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:14,代碼來源:ConfigEntityStorage.php


注:本文中的Drupal\Core\Config\Entity\ConfigEntityInterface::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。