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