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


PHP Entity\ConfigEntityInterface类代码示例

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


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


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