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


PHP EntityInterface::getFields方法代码示例

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


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

示例1: getProperties

 /**
  * {@inheritdoc}
  */
 public function getProperties($include_computed = FALSE)
 {
     if (!isset($this->entity)) {
         throw new MissingDataException('Unable to get properties as no entity has been provided.');
     }
     if (!$this->entity instanceof FieldableEntityInterface) {
         // @todo: Add support for config entities in
         // https://www.drupal.org/node/1818574.
         return array();
     }
     return $this->entity->getFields($include_computed);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:EntityAdapter.php

示例2: getHostConfiguration

 function getHostConfiguration(EntityInterface $entity, $prefix = 'field_ran_')
 {
     // TODO: This can't be right... there must be an easier way to access a
     // field collection's fields.
     $field_collection = $entity->getFields()['field_ran_host_configuration']->getIterator()[0];
     $fields = $field_collection->getFieldCollectionItem()->getFields();
     $vars = array();
     $len = strlen($prefix);
     foreach ($fields as $name => $field) {
         if (substr($name, 0, $len) == $prefix) {
             $vars[substr($name, $len)] = array();
             foreach ($field->getIterator() as $object) {
                 $vars[substr($name, $len)][] = $object->getString();
             }
             $vars[substr($name, $len)] = array_filter($vars[substr($name, $len)]);
         }
     }
     return $vars;
 }
开发者ID:ergonlogic,项目名称:ran,代码行数:19,代码来源:Task.php

示例3: get

 /**
  * Responds to entity GET requests.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity object.
  *
  * @return \Drupal\rest\ResourceResponse
  *   The response containing the entity with its accessible fields.
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 public function get(EntityInterface $entity)
 {
     if (!$entity->access('view')) {
         throw new AccessDeniedHttpException();
     }
     $fields = $entity->getFields();
     $display_id = $entity->getEntityTypeId() . '.' . $entity->bundle() . '.restx';
     // Remove hidden fields (Display mode 'default').
     $view_display = \Drupal::entityManager()->getStorage('entity_view_display')->load($display_id);
     if ($view_display) {
         $content = $view_display->get('content');
         foreach ($fields as $field_name => $field) {
             if (!$field->access('view') || substr($field_name, 0, 6) === 'field_' && !isset($content[$field_name])) {
                 unset($fields[$field_name]);
             }
         }
     }
     $output = array('data' => $fields);
     $response = new ResourceResponse($output, ResourceResponse::HTTP_OK);
     $response->addCacheableDependency($output);
     return $response;
 }
开发者ID:nuxy,项目名称:restx,代码行数:33,代码来源:EntityResource.php


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