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


PHP EntityManagerInterface::onFieldStorageDefinitionCreate方法代碼示例

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


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

示例1: applyUpdates

 /**
  * {@inheritdoc}
  */
 public function applyUpdates()
 {
     foreach ($this->getChangeList() as $entity_type_id => $change_list) {
         // Process entity type definition changes.
         if (!empty($change_list['entity_type']) && $change_list['entity_type'] == static::DEFINITION_UPDATED) {
             $entity_type = $this->entityManager->getDefinition($entity_type_id);
             $original = $this->entityManager->getLastInstalledDefinition($entity_type_id);
             $this->entityManager->onEntityTypeUpdate($entity_type, $original);
         }
         // 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:anyforsoft,項目名稱:csua_d8,代碼行數:32,代碼來源:EntityDefinitionUpdateManager.php

示例2: updateDefinitions

 /**
  * Executes field storage definition updates if needed.
  *
  * @param array $entity_types
  *   A list of entity type definitions to be processed.
  */
 public function updateDefinitions(array $entity_types)
 {
     // Handle field storage definition creation, if needed.
     // @todo Generalize this code in https://www.drupal.org/node/2346013.
     // @todo Handle initial values in https://www.drupal.org/node/2346019.
     if ($this->updateManager->needsUpdates()) {
         foreach ($entity_types as $entity_type_id => $entity_type) {
             $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
             $installed_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id);
             foreach (array_diff_key($storage_definitions, $installed_storage_definitions) as $storage_definition) {
                 /** @var $storage_definition \Drupal\Core\Field\FieldStorageDefinitionInterface */
                 if ($storage_definition->getProvider() == 'content_translation') {
                     $this->entityManager->onFieldStorageDefinitionCreate($storage_definition);
                 }
             }
         }
     }
 }
開發者ID:nsp15,項目名稱:Drupal8,代碼行數:24,代碼來源:ContentTranslationUpdatesManager.php

示例3: doFieldUpdate

 /**
  * Performs a field storage definition update.
  *
  * @param string $op
  *   The operation to perform, possible values are static::DEFINITION_CREATED,
  *   static::DEFINITION_UPDATED or static::DEFINITION_DELETED.
  * @param array|null $storage_definition
  *   The new field storage definition.
  * @param array|null $original_storage_definition
  *   The original field storage definition.
  */
 protected function doFieldUpdate($op, $storage_definition = NULL, $original_storage_definition = NULL)
 {
     switch ($op) {
         case static::DEFINITION_CREATED:
             $this->entityManager->onFieldStorageDefinitionCreate($storage_definition);
             break;
         case static::DEFINITION_UPDATED:
             $this->entityManager->onFieldStorageDefinitionUpdate($storage_definition, $original_storage_definition);
             break;
         case static::DEFINITION_DELETED:
             $this->entityManager->onFieldStorageDefinitionDelete($original_storage_definition);
             break;
     }
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:25,代碼來源:EntityDefinitionUpdateManager.php

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

示例5: onFieldStorageDefinitionCreate

 /**
  * {@inheritdoc}
  */
 public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition)
 {
     $this->entityManager->onFieldStorageDefinitionCreate($storage_definition);
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:7,代碼來源:EntityManagerWrapper.php


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