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


PHP options_allowed_values函数代码示例

本文整理汇总了PHP中options_allowed_values函数的典型用法代码示例。如果您正苦于以下问题:PHP options_allowed_values函数的具体用法?PHP options_allowed_values怎么用?PHP options_allowed_values使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: init

 /**
  * Overrides \Drupal\views\Plugin\views\argument\ArgumentPluginBase::init().
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type']);
     $field_storage = $field_storage_definitions[$this->definition['field_name']];
     $this->allowed_values = options_allowed_values($field_storage);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:FieldList.php

示例2: init

 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $field_storage = $this->getFieldStorageDefinition();
     // Set valueOptions here so getValueOptions() will just return it.
     $this->valueOptions = options_allowed_values($field_storage);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:10,代码来源:ListField.php

示例3: testOptionsAllowedValues

 /**
  * Tests options_allowed_values().
  *
  * @see options_test_dynamic_values_callback()
  */
 public function testOptionsAllowedValues()
 {
     // Test allowed values without passed $items.
     $values = options_allowed_values($this->fieldStorage);
     $this->assertEqual([], $values);
     $values = options_allowed_values($this->fieldStorage, $this->entity);
     $expected_values = array($this->entity->label(), $this->entity->url(), $this->entity->uuid(), $this->entity->bundle());
     $expected_values = array_combine($expected_values, $expected_values);
     $this->assertEqual($expected_values, $values);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:15,代码来源:OptionsDynamicValuesApiTest.php

示例4: generateValues

 public function generateValues($object, $instance, $plugin_definition, $form_display_options)
 {
     $object_field = array();
     $field_info = Field::fieldInfo()->getFieldStorageDefinition($object->entityType(), $instance->getFieldName());
     if ($allowed_values = options_allowed_values($field_info, $object)) {
         $keys = array_keys($allowed_values);
         $object_field['value'] = $keys[mt_rand(0, count($allowed_values) - 1)];
     }
     return $object_field;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:DevelGenerateFieldOptions.php

示例5: viewElements

 /**
  * {@inheritdoc}
  */
 public function viewElements(FieldItemListInterface $items)
 {
     $elements = array();
     $entity = $items->getEntity();
     $allowed_values = options_allowed_values($this->fieldDefinition, $entity);
     foreach ($items as $delta => $item) {
         if (isset($allowed_values[$item->value])) {
             $output = field_filter_xss($allowed_values[$item->value]);
         } else {
             // If no match was found in allowed values, fall back to the key.
             $output = field_filter_xss($item->value);
         }
         $elements[$delta] = array('#markup' => $output);
     }
     return $elements;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:19,代码来源:OptionsDefaultFormatter.php

示例6: init

 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $this->definition['field_name'] = $this->definition['entity field'];
     $field_storage = $this->getFieldStorageDefinition();
     // We may have not a valid workflow field.
     if (FALSE && $field_storage) {
         // Set valueOptions here so getValueOptions() will just return it.
         $this->valueOptions = options_allowed_values($field_storage);
         // $this->valueOptions = workflow_state_allowed_values($field_storage);
     } else {
         // TODO D8. This is a hack. It doesn't work.
         // The default options_allowed_values only reads field_name. Repair that.
         $field_name = $this->definition['entity field'];
         $field_storage = new FieldStorageConfig(['field_name' => $field_name, 'type' => 'testtype', 'entity_type' => $options['entity_type']]);
         $field_storage->set('allowed_values_function', 'workflow_state_allowed_values');
         $wid = '';
         // Set valueOptions here so getValueOptions() will just return it.
         // $this->valueOptions = options_allowed_values($field_storage);
         // $this->valueOptions = workflow_state_allowed_values($field_storage);
         $this->valueOptions = workflow_get_workflow_state_names($wid, $options['group_info']['widget'] == 'select');
     }
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:26,代码来源:WorkflowState.php

示例7: getSettableOptions

 /**
  * {@inheritdoc}
  */
 public function getSettableOptions(AccountInterface $account = NULL)
 {
     $allowed_options = options_allowed_values($this->getFieldDefinition(), $this->getEntity());
     return $allowed_options;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:8,代码来源:ListItemBase.php

示例8: generateSampleValue

 /**
  * {@inheritdoc}
  */
 public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
   $allowed_options = options_allowed_values($field_definition->getFieldStorageDefinition());
   $values['value'] = array_rand($allowed_options);
   return $values;
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:8,代码来源:ListItemBase.php

示例9: init

 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $field_storage = $this->getFieldStorageDefinition();
     $this->allowedValues = options_allowed_values($field_storage);
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:9,代码来源:NumberListField.php

示例10: getOptionsAllowedValues

 /**
  * Returns the array of allowed values for the Options email field.
  *
  * @return array
  *   An array of allowed values entered by the user, for the Options email
  *   field.
  */
 protected function getOptionsAllowedValues() {
   return options_allowed_values($this->getFieldDefinition()->getFieldStorageDefinition(), $this->getEntity());
 }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:10,代码来源:OptionsEmailItem.php


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