当前位置: 首页>>代码示例>>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;未经允许,请勿转载。