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


PHP EntityManagerInterface::loadEntityByUuid方法代碼示例

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


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

示例1: process

 /**
  * {@inheritdoc}
  */
 public function process($text, $langcode)
 {
     $result = new FilterProcessResult($text);
     if (stristr($text, 'data-entity-type="file"') !== FALSE) {
         $dom = Html::load($text);
         $xpath = new \DOMXPath($dom);
         $processed_uuids = array();
         foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
             $uuid = $node->getAttribute('data-entity-uuid');
             // If there is a 'src' attribute, set it to the file entity's current
             // URL. This ensures the URL works even after the file location changes.
             if ($node->hasAttribute('src')) {
                 $file = $this->entityManager->loadEntityByUuid('file', $uuid);
                 if ($file) {
                     $node->setAttribute('src', file_url_transform_relative(file_create_url($file->getFileUri())));
                 }
             }
             // Only process the first occurrence of each file UUID.
             if (!isset($processed_uuids[$uuid])) {
                 $processed_uuids[$uuid] = TRUE;
                 $file = $this->entityManager->loadEntityByUuid('file', $uuid);
                 if ($file) {
                     $result->addCacheTags($file->getCacheTags());
                 }
             }
         }
         $result->setProcessedText(Html::serialize($dom));
     }
     return $result;
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:33,代碼來源:EditorFileReference.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $name = '')
 {
     $this->page = $page;
     $this->staticContext = $this->page->getStaticContext($name);
     // Allow the condition to add to the form.
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#default_value' => isset($this->staticContext['label']) ? $this->staticContext['label'] : '', '#required' => TRUE];
     $form['machine_name'] = ['#type' => 'machine_name', '#maxlength' => 64, '#required' => TRUE, '#machine_name' => ['exists' => [$this, 'contextExists'], 'source' => ['label']], '#default_value' => $name];
     $form['entity_type'] = ['#type' => 'select', '#title' => $this->t('Entity type'), '#options' => $this->entityManager->getEntityTypeLabels(TRUE), '#limit_validation_errors' => array(array('entity_type')), '#submit' => ['::rebuildSubmit'], '#executes_submit_callback' => TRUE, '#ajax' => array('callback' => '::updateEntityType', 'wrapper' => 'add-static-context-wrapper', 'method' => 'replace')];
     $entity = NULL;
     if ($form_state->hasValue('entity_type')) {
         $entity_type = $form_state->getValue('entity_type');
         if ($this->staticContext['value']) {
             $entity = $this->entityManager->loadEntityByUuid($entity_type, $this->staticContext['value']);
         }
     } elseif (!empty($this->staticContext['type'])) {
         list(, $entity_type) = explode(':', $this->staticContext['type']);
         $entity = $this->entityManager->loadEntityByUuid($entity_type, $this->staticContext['value']);
     } elseif ($this->entityManager->hasDefinition('node')) {
         $entity_type = 'node';
     } else {
         $entity_type = 'user';
     }
     $form['entity_type']['#default_value'] = $entity_type;
     $form['selection'] = ['#type' => 'entity_autocomplete', '#prefix' => '<div id="add-static-context-wrapper">', '#suffix' => '</div>', '#required' => TRUE, '#target_type' => $entity_type, '#default_value' => $entity, '#title' => $this->t('Select entity')];
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = ['#type' => 'submit', '#value' => $this->submitButtonText(), '#button_type' => 'primary'];
     return $form;
 }
開發者ID:pulibrary,項目名稱:recap,代碼行數:31,代碼來源:StaticContextFormBase.php

示例3: getContextValue

 /**
  * {@inheritdoc}
  */
 public function getContextValue()
 {
     if (!$this->contextValue) {
         $entity_type_id = substr($this->contextDefinition->getDataType(), 7);
         $this->contextValue = $this->entityManager->loadEntityByUuid($entity_type_id, $this->uuid);
     }
     return $this->contextValue;
 }
開發者ID:pulibrary,項目名稱:recap,代碼行數:11,代碼來源:EntityLazyLoadContext.php

示例4: resolve

 /**
  * {@inheritdoc}
  */
 public function resolve(NormalizerInterface $normalizer, $data, $entity_type)
 {
     // The normalizer is what knows the specification of the data being
     // deserialized. If it can return a UUID from that data, and if there's an
     // entity with that UUID, then return its ID.
     if ($normalizer instanceof UuidReferenceInterface && ($uuid = $normalizer->getUuid($data))) {
         if ($entity = $this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
             return $entity->id();
         }
     }
     return NULL;
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:15,代碼來源:UuidResolver.php

示例5: getEntity

 /**
  * Loads the block content entity of the block.
  *
  * @return \Drupal\block_content\BlockContentInterface|null
  *   The block content entity.
  */
 protected function getEntity()
 {
     $uuid = $this->getDerivativeId();
     if (!isset($this->blockContent)) {
         $this->blockContent = $this->entityManager->loadEntityByUuid('block_content', $uuid);
     }
     return $this->blockContent;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:14,代碼來源:BlockContentBlock.php

示例6: build

 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $uuid = $this->getDerivativeId();
     if ($block = $this->entityManager->loadEntityByUuid('block_content', $uuid)) {
         return $this->entityManager->getViewBuilder($block->getEntityTypeId())->view($block, $this->configuration['view_mode']);
     } else {
         return array('#markup' => $this->t('Block with uuid %uuid does not exist. <a href="!url">Add custom block</a>.', array('%uuid' => $uuid, '!url' => $this->urlGenerator->generate('block_content.add_page'))), '#access' => $this->account->hasPermission('administer blocks'));
     }
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:12,代碼來源:BlockContentBlock.php

示例7: process

 /**
  * {@inheritdoc}
  */
 public function process($text, $langcode)
 {
     $result = new FilterProcessResult($text);
     if (stristr($text, 'data-entity-type="file"') !== FALSE) {
         $dom = Html::load($text);
         $xpath = new \DOMXPath($dom);
         $processed_uuids = array();
         foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
             $uuid = $node->getAttribute('data-entity-uuid');
             // Only process the first occurrence of each file UUID.
             if (!isset($processed_uuids[$uuid])) {
                 $processed_uuids[$uuid] = TRUE;
                 $file = $this->entityManager->loadEntityByUuid('file', $uuid);
                 if ($file) {
                     $result->addCacheTags($file->getCacheTags());
                 }
             }
         }
     }
     return $result;
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:24,代碼來源:EditorFileReference.php

示例8: findMissingContentDependencies

 /**
  * {@inheritdoc}
  */
 public function findMissingContentDependencies()
 {
     $content_dependencies = array();
     $missing_dependencies = array();
     foreach ($this->activeStorage->readMultiple($this->activeStorage->listAll()) as $config_data) {
         if (isset($config_data['dependencies']['content'])) {
             $content_dependencies = array_merge($content_dependencies, $config_data['dependencies']['content']);
         }
     }
     foreach (array_unique($content_dependencies) as $content_dependency) {
         // Format of the dependency is entity_type:bundle:uuid.
         list($entity_type, $bundle, $uuid) = explode(':', $content_dependency, 3);
         if (!$this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
             $missing_dependencies[$uuid] = array('entity_type' => $entity_type, 'bundle' => $bundle, 'uuid' => $uuid);
         }
     }
     return $missing_dependencies;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:21,代碼來源:ConfigManager.php

示例9: loadEntityByUuid

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


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