當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。