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


PHP EntityInterface::uuid方法代码示例

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


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

示例1: buildForm

 /**
  * Form constructor.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  * @param \Drupal\Core\Entity\EntityInterface $node
  *   The node being previews
  *
  * @return array
  *   The form structure.
  */
 public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $node = NULL)
 {
     $view_mode = $node->preview_view_mode;
     $query_options = $node->isNew() ? array('query' => array('uuid' => $node->uuid())) : array();
     $form['backlink'] = array('#type' => 'link', '#title' => $this->t('Back to content editing'), '#url' => $node->isNew() ? Url::fromRoute('node.add', ['node_type' => $node->bundle()]) : $node->urlInfo('edit-form'), '#options' => array('attributes' => array('class' => array('node-preview-backlink'))) + $query_options);
     $view_mode_options = $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle());
     // Unset view modes that are not used in the front end.
     unset($view_mode_options['rss']);
     unset($view_mode_options['search_index']);
     $form['uuid'] = array('#type' => 'value', '#value' => $node->uuid());
     $form['view_mode'] = array('#type' => 'select', '#title' => $this->t('View mode'), '#options' => $view_mode_options, '#default_value' => $view_mode, '#attributes' => array('data-drupal-autosubmit' => TRUE));
     $form['submit'] = array('#type' => 'submit', '#value' => $this->t('Switch'), '#attributes' => array('class' => array('js-hide')));
     return $form;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:27,代码来源:NodePreviewForm.php

示例2: access

 /**
  * {@inheritdoc}
  */
 public function access(EntityInterface $entity, $operation, $langcode = LanguageInterface::LANGCODE_DEFAULT, AccountInterface $account = NULL, $return_as_object = FALSE)
 {
     $account = $this->prepareUser($account);
     if (($return = $this->getCache($entity->uuid(), $operation, $langcode, $account)) !== NULL) {
         // Cache hit, no work necessary.
         return $return_as_object ? $return : $return->isAllowed();
     }
     // Invoke hook_entity_access() and hook_ENTITY_TYPE_access(). Hook results
     // take precedence over overridden implementations of
     // EntityAccessControlHandler::checkAccess(). Entities that have checks that
     // need to be done before the hook is invoked should do so by overriding
     // this method.
     // We grant access to the entity if both of these conditions are met:
     // - No modules say to deny access.
     // - At least one module says to grant access.
     $access = array_merge($this->moduleHandler()->invokeAll('entity_access', array($entity, $operation, $account, $langcode)), $this->moduleHandler()->invokeAll($entity->getEntityTypeId() . '_access', array($entity, $operation, $account, $langcode)));
     $return = $this->processAccessHookResults($access);
     // Also execute the default access check except when the access result is
     // already forbidden, as in that case, it can not be anything else.
     if (!$return->isForbidden()) {
         $return = $return->orIf($this->checkAccess($entity, $operation, $langcode, $account));
     }
     $result = $this->setCache($return, $entity->uuid(), $operation, $langcode, $account);
     return $return_as_object ? $result : $result->isAllowed();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:28,代码来源:EntityAccessControlHandler.php

示例3: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\component\Entity\Component */
     $row['id'] = $entity->id();
     $row['name'] = $this->l($entity->label(), new Url('entity.component.canonical', array('component' => $entity->id())));
     $row['uuid'] = $entity->uuid();
     return $row + parent::buildRow($entity);
 }
开发者ID:poetic,项目名称:clutch,代码行数:11,代码来源:ComponentListBuilder.php

示例4: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\custom_page\Entity\CustomPage */
     $row['id'] = $entity->id();
     $row['name'] = $this->l($entity->label(), new Url('entity.custom_page.canonical', array('custom_page' => $entity->id())));
     $row['uuid'] = $entity->uuid();
     return $row + parent::buildRow($entity);
 }
开发者ID:poetic,项目名称:clutch,代码行数:11,代码来源:CustomPageListBuilder.php

示例5: access

 /**
  * {@inheritdoc}
  */
 public function access(EntityInterface $entity, $operation, $langcode = LanguageInterface::LANGCODE_DEFAULT, AccountInterface $account = NULL)
 {
     $account = $this->prepareUser($account);
     if (($access = $this->getCache($entity->uuid(), $operation, $langcode, $account)) !== NULL) {
         // Cache hit, no work necessary.
         return $access;
     }
     // Invoke hook_entity_access() and hook_ENTITY_TYPE_access(). Hook results
     // take precedence over overridden implementations of
     // EntityAccessController::checkAccess(). Entities that have checks that
     // need to be done before the hook is invoked should do so by overriding
     // this method.
     // We grant access to the entity if both of these conditions are met:
     // - No modules say to deny access.
     // - At least one module says to grant access.
     $access = array_merge($this->moduleHandler()->invokeAll('entity_access', array($entity, $operation, $account, $langcode)), $this->moduleHandler()->invokeAll($entity->getEntityTypeId() . '_access', array($entity, $operation, $account, $langcode)));
     if (($return = $this->processAccessHookResults($access)) === NULL) {
         // No module had an opinion about the access, so let's the access
         // controller check create access.
         $return = (bool) $this->checkAccess($entity, $operation, $langcode, $account);
     }
     return $this->setCache($return, $entity->uuid(), $operation, $langcode, $account);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:26,代码来源:EntityAccessController.php

示例6: entitySave

 /**
  * Saves an entity into the database, from PrivateTempStore.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity being edited.
  *
  * @return \Drupal\Core\Ajax\AjaxResponse
  *   The Ajax response.
  */
 public function entitySave(EntityInterface $entity)
 {
     // Take the entity from PrivateTempStore and save in entity storage.
     // fieldForm() ensures that the PrivateTempStore copy exists ahead.
     $tempstore = $this->tempStoreFactory->get('quickedit');
     $tempstore->get($entity->uuid())->save();
     $tempstore->delete($entity->uuid());
     // Return information about the entity that allows a front end application
     // to identify it.
     $output = array('entity_type' => $entity->getEntityTypeId(), 'entity_id' => $entity->id());
     // Respond to client that the entity was saved properly.
     $response = new AjaxResponse();
     $response->addCommand(new EntitySavedCommand($output));
     return $response;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:24,代码来源:QuickEditController.php

示例7: assertReadEntityIdFromHeaderAndDb

 /**
  * Gets the new entity ID from the location header and tries to read it from
  * the database.
  *
  * @param string $entity_type
  *   Entity type we need to load the entity from DB.
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity we want to check that was inserted correctly.
  * @param array $entity_values
  *   The values of $entity.
  */
 public function assertReadEntityIdFromHeaderAndDb($entity_type, EntityInterface $entity, array $entity_values = array())
 {
     // Get the location from the HTTP response header.
     $location_url = $this->drupalGetHeader('location');
     $url_parts = explode('/', $location_url);
     $id = end($url_parts);
     // Get the entity using the ID found.
     $loaded_entity = \Drupal::entityManager()->getStorage($entity_type)->load($id);
     $this->assertNotIdentical(FALSE, $loaded_entity, 'The new ' . $entity_type . ' was found in the database.');
     $this->assertEqual($entity->uuid(), $loaded_entity->uuid(), 'UUID of created entity is correct.');
     // Verify that the field values sent and received from DB are the same.
     foreach ($entity_values as $property => $value) {
         $actual_value = $loaded_entity->get($property)->value;
         $send_value = $entity->get($property)->value;
         $this->assertEqual($send_value, $actual_value, 'Created property ' . $property . ' expected: ' . $send_value . ', actual: ' . $actual_value);
     }
     // Delete the entity loaded from DB.
     $loaded_entity->delete();
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:30,代码来源:CreateTest.php

示例8: buildKey

 /**
  * {@inheritdoc}
  */
 protected function buildKey(EntityInterface $entity)
 {
     return $entity->uuid() . ':' . $entity->_rev->value;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:7,代码来源:RevisionIndex.php

示例9: buildKey

 /**
  * {@inheritdoc}
  */
 protected function buildKey(EntityInterface $entity)
 {
     return $entity->uuid();
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:7,代码来源:UuidIndex.php

示例10: buildValue

 /**
  * {@inheritdoc}
  */
 protected function buildValue(EntityInterface $entity)
 {
     !($is_new = $entity->isNew());
     $revision_id = $is_new ? 0 : $entity->getRevisionId();
     // We assign a temporary status to the revision since we are indexing it
     // pre save. It will be updated post save with the final status. This will
     // help identifying failures and exception scenarios during entity save.
     $status = 'indexed';
     if (!$is_new && $revision_id) {
         $status = $entity->_deleted->value ? 'deleted' : 'available';
     }
     return array('entity_type_id' => $entity->getEntityTypeId(), 'entity_id' => $is_new ? 0 : $entity->id(), 'revision_id' => $revision_id, 'uuid' => $entity->uuid(), 'rev' => $entity->_rev->value, 'is_stub' => $entity->_rev->is_stub, 'status' => $status);
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:16,代码来源:EntityIndex.php

示例11: doSave

 /**
  * {@inheritdoc}
  *
  * @todo Revisit this logic with forward revisions in mind.
  */
 protected function doSave($id, EntityInterface $entity)
 {
     if ($entity->_rev->is_stub) {
         $entity->isDefaultRevision(TRUE);
     } else {
         // Enforce new revision if any module messed with it in a hook.
         $entity->setNewRevision();
         // Decide whether or not this is the default revision.
         if (!$entity->isNew()) {
             $default_rev = \Drupal::service('entity.index.rev.tree')->getDefaultRevision($entity->uuid());
             if ($entity->_rev->value == $default_rev) {
                 $entity->isDefaultRevision(TRUE);
             } else {
                 $entity->isDefaultRevision(FALSE);
             }
         }
     }
     return parent::doSave($id, $entity);
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:24,代码来源:ContentEntityStorageTrait.php


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