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


PHP EntityManagerInterface::getFormObject方法代码示例

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


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

示例1: getForm

 /**
  * {@inheritdoc}
  */
 public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array())
 {
     $form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation);
     $form_object->setEntity($entity);
     $form_state = (new FormState())->setFormState($form_state_additions);
     return $this->formBuilder->buildForm($form_object, $form_state);
 }
开发者ID:318io,项目名称:318-io,代码行数:10,代码来源:EntityFormBuilder.php

示例2: getForm

 /**
  * {@inheritdoc}
  */
 public function getForm(EntityInterface $entity, $operation = 'default', array $form_state = array())
 {
     $form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation);
     $form_object->setEntity($entity);
     $form_state['build_info']['callback_object'] = $form_object;
     $form_state['build_info']['base_form_id'] = $form_object->getBaseFormID();
     $form_state['build_info'] += array('args' => array());
     return $this->formBuilder->buildForm($form_object, $form_state);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:12,代码来源:EntityFormBuilder.php

示例3: getFormObject

 /**
  * {@inheritdoc}
  *
  * Instead of a class name or service ID, $form_arg will be a string
  * representing the entity and operation being performed.
  * Consider the following route:
  * @code
  *   path: '/foo/{node}/bar'
  *   defaults:
  *     _entity_form: 'node.edit'
  * @endcode
  * This means that the edit form for the node entity will used.
  * If the entity type has a default form, only the name of the
  * entity {param} needs to be passed:
  * @code
  *   path: '/foo/{node}/baz'
  *   defaults:
  *     _entity_form: 'node'
  * @endcode
  */
 protected function getFormObject(RouteMatchInterface $route_match, $form_arg)
 {
     // If no operation is provided, use 'default'.
     $form_arg .= '.default';
     list($entity_type_id, $operation) = explode('.', $form_arg);
     $form_object = $this->entityManager->getFormObject($entity_type_id, $operation);
     // Allow the entity form to determine the entity object from a given route
     // match.
     $entity = $form_object->getEntityFromRouteMatch($route_match, $entity_type_id);
     $form_object->setEntity($entity);
     return $form_object;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:32,代码来源:HtmlEntityFormController.php

示例4: getFormObject

 /**
  * {@inheritdoc}
  *
  * Instead of a class name or service ID, $form_arg will be a string
  * representing the entity and operation being performed.
  * Consider the following route:
  * @code
  *   path: '/foo/{node}/bar'
  *   defaults:
  *     _entity_form: 'node.edit'
  * @endcode
  * This means that the edit form for the node entity will used.
  * If the entity type has a default form, only the name of the
  * entity {param} needs to be passed:
  * @code
  *   path: '/foo/{node}/baz'
  *   defaults:
  *     _entity_form: 'node'
  * @endcode
  */
 protected function getFormObject(Request $request, $form_arg)
 {
     // If no operation is provided, use 'default'.
     $form_arg .= '.default';
     list($entity_type, $operation) = explode('.', $form_arg);
     if ($request->attributes->has($entity_type)) {
         $entity = $request->attributes->get($entity_type);
     } else {
         $entity = $this->manager->getStorage($entity_type)->create(array());
     }
     return $this->manager->getFormObject($entity_type, $operation)->setEntity($entity);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:32,代码来源:HtmlEntityFormController.php

示例5: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $current_user_id = $this->currentUser()->id();
     // Clear out the accounts from the temp store.
     $this->tempStoreFactory->get('user_user_operations_cancel')->delete($current_user_id);
     if ($form_state['values']['confirm']) {
         foreach ($form_state['values']['accounts'] as $uid => $value) {
             // Prevent programmatic form submissions from cancelling user 1.
             if ($uid <= 1) {
                 continue;
             }
             // Prevent user administrators from deleting themselves without confirmation.
             if ($uid == $current_user_id) {
                 $admin_form_mock = array();
                 $admin_form_state = $form_state;
                 unset($admin_form_state['values']['user_cancel_confirm']);
                 // The $user global is not a complete user entity, so load the full
                 // entity.
                 $account = $this->userStorage->load($uid);
                 $admin_form = $this->entityManager->getFormObject('user', 'cancel');
                 $admin_form->setEntity($account);
                 // Calling this directly required to init form object with $account.
                 $admin_form->buildForm($admin_form_mock, $admin_form_state);
                 $admin_form->submit($admin_form_mock, $admin_form_state);
             } else {
                 user_cancel($form_state['values'], $uid, $form_state['values']['user_cancel_method']);
             }
         }
     }
     $form_state['redirect_route']['route_name'] = 'user.admin_account';
 }
开发者ID:shumer,项目名称:blog,代码行数:34,代码来源:UserMultipleCancelConfirm.php

示例6: entityForm

  /**
   * {@inheritdoc}
   */
  public function entityForm($entity_form, FormStateInterface $form_state) {
    $operation = 'default';
    $controller = $this->entityManager->getFormObject($entity_form['#entity']->getEntityTypeId(), $operation);
    $controller->setEntity($entity_form['#entity']);
    $child_form_state = $this->buildChildFormState($controller, $form_state, $entity_form['#entity'], $operation);

    $entity_form = $controller->buildForm($entity_form, $child_form_state);

    if (!$entity_form['#display_actions']) {
      unset($entity_form['actions']);
    }

    // TODO - this is field-only part of the code. Figure out how to refactor.
    if ($child_form_state->get('inline_entity_form')) {
      foreach ($child_form_state->get('inline_entity_form') as $id => $data) {
        $form_state->set(['inline_entity_form', $id], $data);
      }
    }

    $form_state->set('field', $child_form_state->get('field'));

    $entity_form['#element_validate'][] = [get_class($this), 'entityFormValidate'];

    $entity_form['#ief_element_submit'][] = [get_class($this), 'entityFormSubmit'];
    $entity_form['#ief_element_submit'][] = [get_class($this), 'submitCleanFormState'];

    // Allow other modules to alter the form.
    $this->moduleHandler->alter('inline_entity_form_entity_form', $entity_form, $form_state);

    return $entity_form;
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:34,代码来源:EntityInlineEntityFormHandler.php

示例7: getFormObject

 /**
  * {@inheritdoc}
  */
 public function getFormObject($entity_type, $operation)
 {
     return $this->entityManager->getFormObject($entity_type, $operation);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:7,代码来源:EntityManagerWrapper.php


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