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


PHP EntityInterface::hasField方法代碼示例

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


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

示例1: validateRequestAttributes

 /**
  * Validates request attributes.
  */
 protected function validateRequestAttributes(EntityInterface $entity, $field_name, $langcode)
 {
     // Validate the field name and language.
     if (!$field_name || !$entity->hasField($field_name)) {
         return FALSE;
     }
     if (!$langcode || !$entity->hasTranslation($langcode)) {
         return FALSE;
     }
     return TRUE;
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:14,代碼來源:EditEntityFieldAccessCheck.php

示例2: getChangedFieldName

 /**
  * Returns the name of the field that implements the changed timestamp.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity being tested.
  *
  * @return string
  *   The the field name.
  */
 protected function getChangedFieldName($entity)
 {
     return $entity->hasField('content_translation_changed') ? 'content_translation_changed' : 'changed';
 }
開發者ID:ravindrasingh22,項目名稱:Drupal-8-rc,代碼行數:13,代碼來源:ContentTranslationUITestBase.php

示例3: setChangedTime

 /**
  * {@inheritdoc}
  */
 public function setChangedTime($timestamp)
 {
     $field_name = $this->translation->hasField('content_translation_changed') ? 'content_translation_changed' : 'changed';
     $this->translation->set($field_name, $timestamp);
     return $this;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:9,代碼來源:ContentTranslationMetadataWrapper.php

示例4: updateAlias

 /**
  * {@inheritdoc}
  */
 public function updateAlias(EntityInterface $entity, $op, array $options = array())
 {
     // Skip if the entity does not have the path field.
     if (!$entity instanceof ContentEntityInterface || !$entity->hasField('path')) {
         return NULL;
     }
     // Skip if pathauto processing is disabled.
     if (isset($entity->path->pathauto) && empty($entity->path->pathauto) && empty($options['force'])) {
         return NULL;
     }
     $options += array('language' => $entity->language()->getId());
     $type = $entity->getEntityTypeId();
     $bundle = $entity->bundle();
     // Skip processing if the entity has no pattern.
     if (!$this->getPatternByEntity($type, $bundle, $options['language'])) {
         return NULL;
     }
     // Deal with taxonomy specific logic.
     if ($type == 'taxonomy_term') {
         $config_forum = $this->configFactory->get('forum.settings');
         if ($entity->getVocabularyId() == $config_forum->get('vocabulary')) {
             $type = 'forum';
         }
     }
     $result = $this->createAlias($type, $op, '/' . $entity->urlInfo()->getInternalPath(), array($type => $entity), $bundle, $options['language']);
     if ($type == 'taxonomy_term' && empty($options['is_child'])) {
         // For all children generate new aliases.
         $options['is_child'] = TRUE;
         unset($options['language']);
         foreach ($this->getTermTree($entity->getVocabularyId(), $entity->id(), NULL, TRUE) as $subterm) {
             $this->updateAlias($subterm, $op, $options);
         }
     }
     return $result;
 }
開發者ID:AllieRays,項目名稱:debugging-drupal-8,代碼行數:38,代碼來源:PathautoManager.php

示例5: updateEntityAlias

 /**
  * {@inheritdoc}
  */
 public function updateEntityAlias(EntityInterface $entity, $op, array $options = array())
 {
     // Skip if the entity does not have the path field.
     if (!$entity instanceof ContentEntityInterface || !$entity->hasField('path')) {
         return NULL;
     }
     // Skip if pathauto processing is disabled.
     if ($entity->path->pathauto != PathautoState::CREATE && empty($options['force'])) {
         return NULL;
     }
     $options += array('language' => $entity->language()->getId());
     $type = $entity->getEntityTypeId();
     // Skip processing if the entity has no pattern.
     if (!$this->getPatternByEntity($entity)) {
         return NULL;
     }
     // Deal with taxonomy specific logic.
     // @todo Update and test forum related code.
     if ($type == 'taxonomy_term') {
         $config_forum = $this->configFactory->get('forum.settings');
         if ($entity->getVocabularyId() == $config_forum->get('vocabulary')) {
             $type = 'forum';
         }
     }
     try {
         $result = $this->createEntityAlias($entity, $op);
     } catch (\InvalidArgumentException $e) {
         drupal_set_message($e->getMessage(), 'error');
         return NULL;
     }
     // @todo Move this to a method on the pattern plugin.
     if ($type == 'taxonomy_term') {
         foreach ($this->loadTermChildren($entity->id()) as $subterm) {
             $this->updateEntityAlias($subterm, $op, $options);
         }
     }
     return $result;
 }
開發者ID:eric-shell,項目名稱:eric-shell-d8,代碼行數:41,代碼來源:PathautoGenerator.php

示例6: initIsTranslating

 /**
  * Initializes the translation form state.
  *
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  * @param \Drupal\Core\Entity\EntityInterface $host
  */
 protected function initIsTranslating(FormStateInterface $form_state, EntityInterface $host)
 {
     if ($this->isTranslating != NULL) {
         return;
     }
     $this->isTranslating = FALSE;
     if (!$host->isTranslatable()) {
         return;
     }
     if (!$host->getEntityType()->hasKey('default_langcode')) {
         return;
     }
     $default_langcode_key = $host->getEntityType()->getKey('default_langcode');
     if (!$host->hasField($default_langcode_key)) {
         return;
     }
     if (!empty($form_state->get('content_translation'))) {
         // Adding a language through the ContentTranslationController.
         $this->isTranslating = TRUE;
     }
     if ($host->hasTranslation($form_state->get('langcode')) && $host->getTranslation($form_state->get('langcode'))->get($default_langcode_key)->value == 0) {
         // Editing a translation.
         $this->isTranslating = TRUE;
     }
 }
開發者ID:eric-shell,項目名稱:eric-shell-d8,代碼行數:31,代碼來源:InlineParagraphsWidget.php


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