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


PHP EntityForm::buildEntity方法代码示例

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


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

示例1: buildEntity

 /**
  * {@inheritdoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state)
 {
     $entity = parent::buildEntity($form, $form_state);
     $tags = array_map('trim', explode(',', $entity->get('tags')));
     $entity->set('tags', $tags);
     return $entity;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:10,代码来源:RulesComponentFormBase.php

示例2: buildEntity

 /**
  * {@inheritdoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state)
 {
     /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
     $entity = parent::buildEntity($form, $form_state);
     // Mark the entity as requiring validation.
     $entity->setValidationRequired(!$form_state->getTemporaryValue('entity_validated'));
     return $entity;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:11,代码来源:ContentEntityForm.php

示例3: buildEntity

 /**
  * {@inheritdoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state)
 {
     // Save period.
     $type = Schedule::getPeriodType($form_state->getValue('period_type'));
     $seconds = Schedule::periodToSeconds(['number' => $form_state->getValue('period_number'), 'type' => $type]);
     $form_state->setValue('period', $seconds);
     return parent::buildEntity($form, $form_state);
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:11,代码来源:ScheduleForm.php

示例4: buildEntity

 /**
  * {@inheritdoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state) {
   $entity = parent::buildEntity($form, $form_state);
   // Update the link type plugin.
   // @todo Do this somewhere else?
   $entity->setLinkTypePlugin($entity->get('link_type'));
   //debug($entity->getLinkTypePlugin()->getPluginId(), $entity->get('link_type'));
   return $entity;
 }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:11,代码来源:FlagFormBase.php

示例5: buildEntity

 /**
  * {@inheritdoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state)
 {
     // Save field cardinality.
     if ($form_state->getValue('cardinality') === 'number' && $form_state->getValue('cardinality_number')) {
         $form_state->setValue('cardinality', $form_state->getValue('cardinality_number'));
     }
     return parent::buildEntity($form, $form_state);
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:11,代码来源:FieldStorageConfigEditForm.php

示例6: buildEntity

 /**
  * {@inheritDoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state)
 {
     /** @var \Drupal\pathauto\PathautoPatternInterface $entity */
     $entity = parent::buildEntity($form, $form_state);
     $default_weight = 0;
     $alias_type = $entity->getAliasType();
     if ($alias_type->getDerivativeId() && $this->entityTypeManager->hasDefinition($alias_type->getDerivativeId())) {
         $entity_type = $alias_type->getDerivativeId();
         // First, remove bundle and language conditions.
         foreach ($entity->getSelectionConditions() as $condition_id => $condition) {
             if (in_array($condition->getPluginId(), ['entity_bundle:' . $entity_type, 'node_type', 'language'])) {
                 $entity->removeSelectionCondition($condition_id);
             }
         }
         if ($bundles = array_filter((array) $form_state->getValue('bundles'))) {
             $default_weight -= 5;
             $plugin_id = $entity_type == 'node' ? 'node_type' : 'entity_bundle:' . $entity_type;
             $entity->addSelectionCondition(['id' => $plugin_id, 'bundles' => $bundles, 'negate' => FALSE, 'context_mapping' => [$entity_type => $entity_type]]);
         }
         if ($languages = array_filter((array) $form_state->getValue('languages'))) {
             $default_weight -= 5;
             $language_mapping = $entity_type . ':' . $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode') . ':language';
             $entity->addSelectionCondition(['id' => 'language', 'langcodes' => array_combine($languages, $languages), 'negate' => FALSE, 'context_mapping' => ['language' => $language_mapping]]);
             $entity->addRelationship($language_mapping, t('Language'));
         }
     }
     $entity->setWeight($default_weight);
     return $entity;
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:32,代码来源:PatternEditForm.php

示例7: buildEntity

 /**
  * {@inheritdoc}
  */
 public function buildEntity(array $form, FormStateInterface $form_state)
 {
     /** @var \Drupal\menu_link_config\Entity\MenuLinkConfig $entity */
     $entity = parent::buildEntity($form, $form_state);
     $new_definition = $this->extractFormValues($form, $form_state);
     $entity->id = $new_definition['metadata']['entity_id'];
     $entity->parent = $new_definition['parent'];
     $entity->menu_name = $new_definition['menu_name'];
     $entity->setStatus(!$new_definition['hidden']);
     $entity->expanded = $new_definition['expanded'];
     $entity->weight = $new_definition['weight'];
     $entity->url = $new_definition['url'];
     $entity->route_name = $new_definition['route_name'];
     $entity->route_parameters = $new_definition['route_parameters'];
     $entity->options = $new_definition['options'];
     return $entity;
 }
开发者ID:robertfoleyjr,项目名称:robertfoleyjr-d8,代码行数:20,代码来源:MenuLinkConfigForm.php


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