• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Entity\ConfigEntityInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: formBuilderCallback

 /**
  * Form builder callback.
  *
  * @todo I don't know why this needs to be separate from the form() method.
  * It was in the form_alter version but we should see if we can just fold
  * it into the method above.
  *
  * @param $entity_type
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $bundle
  * @param array $form
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  */
 public function formBuilderCallback($entity_type, ConfigEntityInterface $bundle, &$form, FormStateInterface $form_state)
 {
     // @todo write a test for this.
     $bundle->setThirdPartySetting('workbench_moderation', 'enabled', $form_state->getValue('enable_moderation_state'));
     $bundle->setThirdPartySetting('workbench_moderation', 'allowed_moderation_states', array_keys(array_filter($form_state->getValue('allowed_moderation_states'))));
     $bundle->setThirdPartySetting('workbench_moderation', 'default_moderation_state', $form_state->getValue('default_moderation_state'));
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:19,代码来源:BundleModerationConfigurationForm.php


示例2: sort

 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     if ($a->isLocked() == $b->isLocked()) {
         $a_label = $a->label();
         $b_label = $b->label();
         return strnatcasecmp($a_label, $b_label);
     }
     return $a->isLocked() ? 1 : -1;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:12,代码来源:DateFormat.php


示例3: sort

 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     /** @var \Drupal\Core\Entity\EntityDisplayModeInterface $a */
     /** @var \Drupal\Core\Entity\EntityDisplayModeInterface $b */
     // Sort by the type of entity the view mode is used for.
     $a_type = $a->getTargetType();
     $b_type = $b->getTargetType();
     $type_order = strnatcasecmp($a_type, $b_type);
     return $type_order != 0 ? $type_order : parent::sort($a, $b);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:13,代码来源:EntityDisplayModeBase.php


示例4: getConfigNamesToDelete

 /**
  * {@inheritdoc}
  */
 protected function getConfigNamesToDelete(ConfigEntityInterface $entity)
 {
     /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
     $field_storage = $entity->getFieldStorageDefinition();
     $config_names = [$entity->getConfigDependencyName()];
     // If there is only one bundle left for this field storage, it will be
     // deleted too, notify the user about dependencies.
     if (count($field_storage->getBundles()) <= 1) {
         $config_names[] = $field_storage->getConfigDependencyName();
     }
     return $config_names;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:FieldConfigDeleteForm.php


示例5: assertConfigEntityImport

 /**
  * Asserts that a config entity can be imported without changing it.
  *
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
  *   The config entity to test importing.
  */
 public function assertConfigEntityImport(ConfigEntityInterface $entity)
 {
     // Save original config information.
     $entity_uuid = $entity->uuid();
     $entity_type_id = $entity->getEntityTypeId();
     $original_data = $entity->toArray();
     // Copy everything to sync.
     $this->copyConfig(\Drupal::service('config.storage'), \Drupal::service('config.storage.sync'));
     // Delete the configuration from active. Don't worry about side effects of
     // deleting config like fields cleaning up field storages. The coming import
     // should recreate everything as necessary.
     $entity->delete();
     $this->configImporter()->reset()->import();
     $imported_entity = \Drupal::entityManager()->loadEntityByUuid($entity_type_id, $entity_uuid);
     $this->assertIdentical($original_data, $imported_entity->toArray());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:22,代码来源:AssertConfigEntityImportTrait.php


示例6: sort

 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     /** @var $a \Drupal\search\SearchPageInterface */
     /** @var $b \Drupal\search\SearchPageInterface */
     $a_status = (int) $a->status();
     $b_status = (int) $b->status();
     if ($a_status != $b_status) {
         return $a_status > $b_status ? -1 : 1;
     }
     return parent::sort($a, $b);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:14,代码来源:SearchPage.php


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


示例8: addContextDefinitionsFrom

 /**
  * Adds the configured context definitions from the config entity.
  *
  * Example: for a reaction rule config all context definitions of the event
  * will be added.
  *
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $rules_config
  *   The config entity.
  *
  * @return $this
  */
 public function addContextDefinitionsFrom(ConfigEntityInterface $rules_config)
 {
     if ($rules_config instanceof ReactionRuleConfig) {
         $event_name = $rules_config->getEvent();
         // @todo Use setter injection for the service.
         $event_definition = \Drupal::service('plugin.manager.rules_event')->getDefinition($event_name);
         foreach ($event_definition['context'] as $context_name => $context_definition) {
             $this->addContextDefinition($context_name, $context_definition);
         }
     }
     return $this;
 }
开发者ID:DrupalTV,项目名称:DrupalTV,代码行数:23,代码来源:RulesComponent.php


示例9: sort

 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     // Sort the entities using the entity class's sort() method.
     // See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
     /* @var $a WorkflowTransitionInterface */
     /* @var $b WorkflowTransitionInterface */
     if (!$a->getFromSid() || !$b->getFromSid()) {
         return 0;
     }
     // First sort on From-State.
     $from_state_a = $a->getFromState();
     $from_state_b = $b->getFromState();
     if ($from_state_a->weight < $from_state_b->weight) {
         return -1;
     }
     if ($from_state_a->weight > $from_state_b->weight) {
         return +1;
     }
     // Then sort on To-State.
     $to_state_a = $a->getToState();
     $to_state_b = $b->getToState();
     if ($to_state_a->weight < $to_state_b->weight) {
         return -1;
     }
     if ($to_state_a->weight > $to_state_b->weight) {
         return +1;
     }
     return 0;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:32,代码来源:WorkflowConfigTransition.php


示例10: sort

 /**
  * Sorts active blocks by weight; sorts inactive blocks by name.
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     // Separate enabled from disabled.
     $status = $b->get('status') - $a->get('status');
     if ($status) {
         return $status;
     }
     // Sort by weight, unless disabled.
     if ($a->get('region') != static::BLOCK_REGION_NONE) {
         $weight = $a->get('weight') - $b->get('weight');
         if ($weight) {
             return $weight;
         }
     }
     // Sort by label.
     return strcmp($a->label(), $b->label());
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:20,代码来源:Block.php


示例11: sort

 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     $a_status = (int) $a->status();
     $b_status = (int) $b->status();
     if ($a_status != $b_status) {
         return $a_status > $b_status ? -1 : 1;
     }
     return parent::sort($a, $b);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:12,代码来源:Country.php


示例12: getConfigNamesToDelete

 /**
  * Returns config names to delete for the deletion confirmation form.
  *
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
  *   The entity being deleted.
  *
  * @return string[]
  *   A list of configuration names that will be deleted by this form.
  */
 protected function getConfigNamesToDelete(ConfigEntityInterface $entity)
 {
     return [$entity->getConfigDependencyName()];
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:EntityDeleteForm.php


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


示例14: overviewRow

 /**
  * Builds a table row for overview form.
  *
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
  *   Data needed to build the list row.
  *
  * @return array
  *   A single table row for the overview.
  */
 public function overviewRow(ConfigEntityInterface $entity)
 {
     $label = $entity->label() ?: $this->t('@type: @id', array('@type' => $entity->getEntityTypeId(), '@id' => $entity->id()));
     // Get current job items for the entity to determine translation statuses.
     $source_lang = $entity->language()->getId();
     $current_job_items = tmgmt_job_item_load_latest('config', $entity->getEntityTypeId(), $entity->getConfigDependencyName(), $source_lang);
     $row['id'] = $entity->id();
     $definition = \Drupal::entityTypeManager()->getDefinition($entity->bundle());
     $row['config_id'] = $definition->getConfigPrefix() . '.' . $entity->id();
     if ($entity->hasLinkTemplate('edit-form')) {
         $row['title'] = $entity->toLink($label, 'edit-form');
     } else {
         // If the entity doesn't have a link we display a label.
         $row['title'] = $label;
     }
     // Load entity translation specific data.
     foreach (\Drupal::languageManager()->getLanguages() as $langcode => $language) {
         $translation_status = 'current';
         if ($langcode == $source_lang) {
             $translation_status = 'original';
         } elseif (!$this->isTranslated($langcode, $entity->getConfigDependencyName())) {
             $translation_status = 'missing';
         }
         // @todo Find a way to support marking configuration translations as outdated.
         $build = $this->buildTranslationStatus($translation_status, isset($current_job_items[$langcode]) ? $current_job_items[$langcode] : NULL);
         $row['langcode-' . $langcode] = ['data' => \Drupal::service('renderer')->render($build), 'class' => array('langstatus-' . $langcode)];
     }
     return $row;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:38,代码来源:ConfigSourcePluginUi.php


示例15: sort

 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     /* @var $a WorkflowState */
     /* @var $b WorkflowState */
     $a_wid = $a->wid;
     $b_wid = $b->wid;
     if ($a_wid == $b_wid) {
         $a_weight = $a->getWeight();
         $b_weight = $b->getWeight();
         return $a_weight < $b_weight ? -1 : 1;
     }
     return $a_wid < $b_wid ? -1 : 1;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:16,代码来源:WorkflowState.php


示例16: sort

 /**
  * Sorts active blocks by weight; sorts inactive blocks by name.
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     // Separate enabled from disabled.
     $status = (int) $b->status() - (int) $a->status();
     if ($status !== 0) {
         return $status;
     }
     // Sort by weight, unless disabled.
     if ($a->getRegion() != static::BLOCK_REGION_NONE) {
         $weight = $a->getWeight() - $b->getWeight();
         if ($weight) {
             return $weight;
         }
     }
     // Sort by label.
     return strcmp($a->label(), $b->label());
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:20,代码来源:Block.php


示例17: createEntity

 /**
  * Creates an event entity.
  *
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface
  *   An entity type.
  * @param array $settings
  *   Additional settings for the new entity.
  *
  * @return \Drupal\Core\Entity\EntityInterface
  *   An event.
  */
 function createEntity(ConfigEntityInterface $entity_type, $settings = [])
 {
     // @todo change to custom entity
     $entity = $this->drupalCreateNode(['type' => $entity_type->id()] + $settings);
     return $entity;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:17,代码来源:RNGTestBase.php


示例18: sort

 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     /** @var \Drupal\system\ActionConfigEntityInterface $a */
     /** @var \Drupal\system\ActionConfigEntityInterface $b */
     $a_type = $a->getType();
     $b_type = $b->getType();
     if ($a_type != $b_type) {
         return strnatcasecmp($a_type, $b_type);
     }
     return parent::sort($a, $b);
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:14,代码来源:Action.php


示例19: callOnDependencyRemoval

 /**
  * Calls an entity's onDependencyRemoval() method.
  *
  * A helper method to call onDependencyRemoval() with the correct list of
  * affected entities. This list should only contain dependencies on the
  * entity. Configuration and content entity dependencies will be converted
  * into entity objects.
  *
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
  *   The entity to call onDependencyRemoval() on.
  * @param \Drupal\Core\Config\Entity\ConfigEntityInterface[] $dependent_entities
  *   The list of dependent configuration entities.
  * @param string $type
  *   The type of dependency being checked. Either 'module', 'theme', 'config'
  *   or 'content'.
  * @param array $names
  *   The specific names to check. If $type equals 'module' or 'theme' then it
  *   should be a list of module names or theme names. In the case of 'config'
  *   or 'content' it should be a list of configuration dependency names.
  *
  * @return bool
  *   TRUE if the entity has changed as a result of calling the
  *   onDependencyRemoval() method, FALSE if not.
  */
 protected function callOnDependencyRemoval(ConfigEntityInterface $entity, array $dependent_entities, $type, array $names)
 {
     $entity_dependencies = $entity->getDependencies();
     if (empty($entity_dependencies)) {
         // No dependent entities nothing to do.
         return FALSE;
     }
     $affected_dependencies = array('config' => array(), 'content' => array(), 'module' => array(), 'theme' => array());
     // Work out if any of the entity's dependencies are going to be affected.
     if (isset($entity_dependencies[$type])) {
         // Work out which dependencies the entity has in common with the provided
         // $type and $names.
         $affected_dependencies[$type] = array_intersect($entity_dependencies[$type], $names);
         // If the dependencies are entities we need to convert them into objects.
         if ($type == 'config' || $type == 'content') {
             $affected_dependencies[$type] = array_map(function ($name) use($type) {
                 if ($type == 'config') {
                     return $this->loadConfigEntityByName($name);
                 } else {
                     // Ignore the bundle.
                     list($entity_type_id, , $uuid) = explode(':', $name);
                     return $this->entityManager->loadEntityByConfigTarget($entity_type_id, $uuid);
                 }
             }, $affected_dependencies[$type]);
         }
     }
     // Merge any other configuration entities into the list of affected
     // dependencies if necessary.
     if (isset($entity_dependencies['config'])) {
         foreach ($dependent_entities as $dependent_entity) {
             if (in_array($dependent_entity->getConfigDependencyName(), $entity_dependencies['config'])) {
                 $affected_dependencies['config'][] = $dependent_entity;
             }
         }
     }
     // Key the entity arrays by config dependency name to make searching easy.
     foreach (['config', 'content'] as $dependency_type) {
         $affected_dependencies[$dependency_type] = array_combine(array_map(function ($entity) {
             return $entity->getConfigDependencyName();
         }, $affected_dependencies[$dependency_type]), $affected_dependencies[$dependency_type]);
     }
     // Inform the entity.
     return $entity->onDependencyRemoval($affected_dependencies);
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:68,代码来源:ConfigManager.php


示例20: sort

 /**
  * Helper callback for uasort() to sort configuration entities by weight and label.
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     $a_weight = isset($a->weight) ? $a->weight : 0;
     $b_weight = isset($b->weight) ? $b->weight : 0;
     if ($a_weight == $b_weight) {
         $a_label = $a->label();
         $b_label = $b->label();
         return strnatcasecmp($a_label, $b_label);
     }
     return $a_weight < $b_weight ? -1 : 1;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:14,代码来源:ConfigEntityBase.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Entity\ConfigEntityListBuilder类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\ConfigEntityBase类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap