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


PHP EntityManagerInterface::clearCachedDefinitions方法代码示例

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


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

示例1: testVariousTableUpdatesForRevisionView

 /**
  * Tests some possible entity table updates for a revision view.
  */
 public function testVariousTableUpdatesForRevisionView()
 {
     // base + revision <-> base + translation + revision
     $this->updateEntityTypeToRevisionable();
     // Multiple changes, so we have to invalidate the caches, otherwise
     // the second update will revert the first.
     $this->entityManager->clearCachedDefinitions();
     list($view, $display) = $this->getUpdatedViewAndDisplay(TRUE);
     $this->assertEqual('entity_test_update_revision', $view->get('base_table'));
     $this->assertEqual('entity_test_update_revision', $display['display_options']['fields']['id']['table']);
     $this->assertEqual('entity_test_update_revision', $display['display_options']['fields']['name']['table']);
     $this->updateEntityTypeToTranslatable();
     $this->entityDefinitionUpdateManager->applyUpdates();
     list($view, $display) = $this->getUpdatedViewAndDisplay(TRUE);
     $this->assertEqual('entity_test_update_revision', $view->get('base_table'));
     $this->assertEqual('entity_test_update_revision', $display['display_options']['fields']['id']['table']);
     $this->assertEqual('entity_test_update_revision_data', $display['display_options']['fields']['name']['table']);
     $this->updateEntityTypeToNotTranslatable();
     $this->entityDefinitionUpdateManager->applyUpdates();
     list($view, $display) = $this->getUpdatedViewAndDisplay(TRUE);
     $this->assertEqual('entity_test_update_revision', $view->get('base_table'));
     $this->assertEqual('entity_test_update_revision', $display['display_options']['fields']['id']['table']);
     $this->assertEqual('entity_test_update_revision', $display['display_options']['fields']['name']['table']);
     $this->resetEntityType();
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:28,代码来源:ViewsEntitySchemaSubscriberIntegrationTest.php

示例2: getChangeList

 /**
  * Returns a list of changes to entity type and field storage definitions.
  *
  * @return array
  *   An associative array keyed by entity type id of change descriptors. Every
  *   entry is an associative array with the following optional keys:
  *   - entity_type: a scalar having only the DEFINITION_UPDATED value.
  *   - field_storage_definitions: an associative array keyed by field name of
  *     scalars having one value among:
  *     - DEFINITION_CREATED
  *     - DEFINITION_UPDATED
  *     - DEFINITION_DELETED
  */
 protected function getChangeList()
 {
     $this->entityManager->clearCachedDefinitions();
     $change_list = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         $original = $this->entityManager->getLastInstalledDefinition($entity_type_id);
         // Only manage changes to already installed entity types. Entity type
         // installation is handled elsewhere (e.g.,
         // \Drupal\Core\Extension\ModuleHandler::install()).
         if (!$original) {
             continue;
         }
         // @todo Support non-storage-schema-changing definition updates too:
         //   https://www.drupal.org/node/2336895.
         if ($this->requiresEntityStorageSchemaChanges($entity_type, $original)) {
             $change_list[$entity_type_id]['entity_type'] = static::DEFINITION_UPDATED;
         }
         if ($this->entityManager->getStorage($entity_type_id) instanceof DynamicallyFieldableEntityStorageInterface) {
             $field_changes = array();
             $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
             $original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id);
             // Detect created field storage definitions.
             foreach (array_diff_key($storage_definitions, $original_storage_definitions) as $field_name => $storage_definition) {
                 $field_changes[$field_name] = static::DEFINITION_CREATED;
             }
             // Detect deleted field storage definitions.
             foreach (array_diff_key($original_storage_definitions, $storage_definitions) as $field_name => $original_storage_definition) {
                 $field_changes[$field_name] = static::DEFINITION_DELETED;
             }
             // Detect updated field storage definitions.
             foreach (array_intersect_key($storage_definitions, $original_storage_definitions) as $field_name => $storage_definition) {
                 // @todo Support non-storage-schema-changing definition updates too:
                 //   https://www.drupal.org/node/2336895. So long as we're checking
                 //   based on schema change requirements rather than definition
                 //   equality, skip the check if the entity type itself needs to be
                 //   updated, since that can affect the schema of all fields, so we
                 //   want to process that update first without reporting false
                 //   positives here.
                 if (!isset($change_list[$entity_type_id]['entity_type']) && $this->requiresFieldStorageSchemaChanges($storage_definition, $original_storage_definitions[$field_name])) {
                     $field_changes[$field_name] = static::DEFINITION_UPDATED;
                 }
             }
             if ($field_changes) {
                 $change_list[$entity_type_id]['field_storage_definitions'] = $field_changes;
             }
         }
     }
     return array_filter($change_list);
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:62,代码来源:EntityDefinitionUpdateManager.php

示例3: applyUpdates

 /**
  * {@inheritdoc}
  */
 public function applyUpdates()
 {
     $change_list = $this->getChangeList();
     if ($change_list) {
         // getChangeList() only disables the cache and does not invalidate.
         // In case there are changes, explicitly invalidate caches.
         $this->entityManager->clearCachedDefinitions();
     }
     foreach ($change_list as $entity_type_id => $change_list) {
         // Process entity type definition changes before storage definitions ones
         // this is necessary when you change an entity type from non-revisionable
         // to revisionable and at the same time add revisionable fields to the
         // entity type.
         if (!empty($change_list['entity_type'])) {
             $entity_type = $this->entityManager->getDefinition($entity_type_id);
             switch ($change_list['entity_type']) {
                 case static::DEFINITION_CREATED:
                     $this->entityManager->onEntityTypeCreate($entity_type);
                     break;
                 case static::DEFINITION_UPDATED:
                     $original = $this->entityManager->getLastInstalledDefinition($entity_type_id);
                     $this->entityManager->onEntityTypeUpdate($entity_type, $original);
                     break;
             }
         }
         // Process field storage definition changes.
         if (!empty($change_list['field_storage_definitions'])) {
             $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
             $original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id);
             foreach ($change_list['field_storage_definitions'] as $field_name => $change) {
                 switch ($change) {
                     case static::DEFINITION_CREATED:
                         $this->entityManager->onFieldStorageDefinitionCreate($storage_definitions[$field_name]);
                         break;
                     case static::DEFINITION_UPDATED:
                         $this->entityManager->onFieldStorageDefinitionUpdate($storage_definitions[$field_name], $original_storage_definitions[$field_name]);
                         break;
                     case static::DEFINITION_DELETED:
                         $this->entityManager->onFieldStorageDefinitionDelete($original_storage_definitions[$field_name]);
                         break;
                 }
             }
         }
     }
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:48,代码来源:EntityDefinitionUpdateManager.php

示例4: applyFieldUpdate

 /**
  * {@inheritdoc}
  */
 public function applyFieldUpdate($op, $entity_type_id, $field_name, $reset_cached_definitions = TRUE)
 {
     $change_list = $this->getChangeList();
     if (!isset($change_list[$entity_type_id]['field_storage_definitions']) || $change_list[$entity_type_id]['field_storage_definitions'][$field_name] !== $op) {
         return FALSE;
     }
     if ($reset_cached_definitions) {
         // self::getChangeList() only disables the cache and does not invalidate.
         // In case there are changes, explicitly invalidate caches.
         $this->entityManager->clearCachedDefinitions();
     }
     $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
     $original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id);
     $storage_definition = isset($storage_definitions[$field_name]) ? $storage_definitions[$field_name] : NULL;
     $original_storage_definition = isset($original_storage_definitions[$field_name]) ? $original_storage_definitions[$field_name] : NULL;
     $this->doFieldUpdate($op, $storage_definition, $original_storage_definition);
     return TRUE;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:21,代码来源:EntityDefinitionUpdateManager.php

示例5: uninstallFieldStorageDefinition

 /**
  * {@inheritdoc}
  */
 public function uninstallFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition)
 {
     $this->entityManager->clearCachedDefinitions();
     $this->entityManager->onFieldStorageDefinitionDelete($storage_definition);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:8,代码来源:EntityDefinitionUpdateManager.php

示例6: clearCachedDefinitions

 /**
  * {@inheritdoc}
  */
 public function clearCachedDefinitions()
 {
     $this->entityManager->clearCachedDefinitions();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:7,代码来源:EntityManagerWrapper.php


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