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


PHP FieldDefinitionInterface::getItemDefinition方法代碼示例

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


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

示例1: generateSampleValue

 /**
  * {@inheritdoc}
  */
 public static function generateSampleValue(FieldDefinitionInterface $field_definition)
 {
     $random = new Random();
     if ($field_definition->getItemDefinition()->getSetting('link_type') & LinkItemInterface::LINK_EXTERNAL) {
         // Set of possible top-level domains.
         $tlds = array('com', 'net', 'gov', 'org', 'edu', 'biz', 'info');
         // Set random length for the domain name.
         $domain_length = mt_rand(7, 15);
         switch ($field_definition->getSetting('title')) {
             case DRUPAL_DISABLED:
                 $values['title'] = '';
                 break;
             case DRUPAL_REQUIRED:
                 $values['title'] = $random->sentences(4);
                 break;
             case DRUPAL_OPTIONAL:
                 // In case of optional title, randomize its generation.
                 $values['title'] = mt_rand(0, 1) ? $random->sentences(4) : '';
                 break;
         }
         $values['uri'] = 'http://www.' . $random->word($domain_length) . '.' . $tlds[mt_rand(0, sizeof($tlds) - 1)];
     } else {
         $values['uri'] = 'base:' . $random->name(mt_rand(1, 64));
     }
     return $values;
 }
開發者ID:DrupalCamp-NYC,項目名稱:dcnyc16,代碼行數:29,代碼來源:LinkItem.php

示例2: getPropertyDescription

 /**
  * {@inheritdoc}
  */
 public function getPropertyDescription($property)
 {
     return $this->fieldDefinition->getItemDefinition()->getPropertyDefinition($property)->getDescription();
 }
開發者ID:Tawreh,項目名稱:mtg,代碼行數:7,代碼來源:FieldTargetDefinition.php

示例3: processViewsDataForEntityReference

 /**
  * Processes the views data for an entity reference field.
  *
  * @param string $table
  *   The table the language field is added to.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The field definition.
  * @param array $views_field
  *   The views field data.
  * @param string $field_column_name
  *   The field column being processed.
  */
 protected function processViewsDataForEntityReference($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name)
 {
     // @todo Should the actual field handler respect that this just renders a
     //   number?
     // @todo Create an optional entity field handler, that can render the
     //   entity.
     // @see https://www.drupal.org/node/2322949
     if ($entity_type_id = $field_definition->getItemDefinition()->getSetting('target_type')) {
         $entity_type = $this->entityManager->getDefinition($entity_type_id);
         if ($entity_type instanceof ContentEntityType) {
             $views_field['relationship'] = ['base' => $this->getViewsTableForEntityType($entity_type), 'base field' => $entity_type->getKey('id'), 'label' => $entity_type->getLabel(), 'title' => $entity_type->getLabel(), 'id' => 'standard'];
             $views_field['field']['id'] = 'field';
             $views_field['argument']['id'] = 'numeric';
             $views_field['filter']['id'] = 'numeric';
             $views_field['sort']['id'] = 'standard';
         } else {
             $views_field['field']['id'] = 'field';
             $views_field['argument']['id'] = 'string';
             $views_field['filter']['id'] = 'string';
             $views_field['sort']['id'] = 'standard';
         }
     }
     if ($field_definition->getName() == $this->entityType->getKey('bundle')) {
         $views_field['filter']['id'] = 'bundle';
     }
 }
開發者ID:brstde,項目名稱:gap1,代碼行數:38,代碼來源:EntityViewsData.php


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