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


PHP ConfigFactoryInterface::rename方法代码示例

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


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

示例1: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, EntityInterface $entity)
 {
     $is_new = $entity->isNew();
     $prefix = $this->getPrefix();
     $config_name = $prefix . $entity->id();
     if ($id !== $entity->id()) {
         // Renaming a config object needs to cater for:
         // - Storage needs to access the original object.
         // - The object needs to be renamed/copied in ConfigFactory and reloaded.
         // - All instances of the object need to be renamed.
         $this->configFactory->rename($prefix . $id, $config_name);
     }
     $config = $this->configFactory->getEditable($config_name);
     // Retrieve the desired properties and set them in config.
     $config->setData($this->mapToStorageRecord($entity));
     $config->save($entity->hasTrustedData());
     // Update the entity with the values stored in configuration. It is possible
     // that configuration schema has casted some of the values.
     if (!$entity->hasTrustedData()) {
         $data = $this->mapFromStorageRecords(array($config->get()));
         $updated_entity = current($data);
         foreach (array_keys($config->get()) as $property) {
             $value = $updated_entity->get($property);
             $entity->set($property, $value);
         }
     }
     return $is_new ? SAVED_NEW : SAVED_UPDATED;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:31,代码来源:ConfigEntityStorage.php

示例2: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, EntityInterface $entity)
 {
     $is_new = $entity->isNew();
     $prefix = $this->getPrefix();
     if ($id !== $entity->id()) {
         // Renaming a config object needs to cater for:
         // - Storage needs to access the original object.
         // - The object needs to be renamed/copied in ConfigFactory and reloaded.
         // - All instances of the object need to be renamed.
         $config = $this->configFactory->rename($prefix . $id, $prefix . $entity->id());
     } else {
         $config = $this->configFactory->get($prefix . $id);
     }
     // Retrieve the desired properties and set them in config.
     $config->setData($this->mapToStorageRecord($entity));
     $config->save();
     return $is_new ? SAVED_NEW : SAVED_UPDATED;
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:21,代码来源:ConfigEntityStorage.php


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