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


PHP FormStateInterface::prepareCallback方法代码示例

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


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

示例1: buildResponse

 /**
  * {@inheritdoc}
  */
 public function buildResponse(Request $request, array $form, FormStateInterface $form_state, array $commands)
 {
     // If the form build ID has changed, issue an Ajax command to update it.
     if (isset($form['#build_id_old']) && $form['#build_id_old'] !== $form['#build_id']) {
         $commands[] = new UpdateBuildIdCommand($form['#build_id_old'], $form['#build_id']);
     }
     // We need to return the part of the form (or some other content) that needs
     // to be re-rendered so the browser can update the page with changed
     // content. It is up to the #ajax['callback'] function of the element (may
     // or may not be a button) that triggered the Ajax request to determine what
     // needs to be rendered.
     $callback = NULL;
     if (($triggering_element = $form_state->getTriggeringElement()) && isset($triggering_element['#ajax']['callback'])) {
         $callback = $triggering_element['#ajax']['callback'];
     }
     $callback = $form_state->prepareCallback($callback);
     if (empty($callback) || !is_callable($callback)) {
         throw new HttpException(500, 'The specified #ajax callback is empty or not callable.');
     }
     $result = call_user_func_array($callback, [&$form, &$form_state, $request]);
     // If the callback is an #ajax callback, the result is a render array, and
     // we need to turn it into an AJAX response, so that we can add any commands
     // we got earlier; typically the UpdateBuildIdCommand when handling an AJAX
     // submit from a cached page.
     if ($result instanceof AjaxResponse) {
         $response = $result;
     } else {
         /** @var \Drupal\Core\Ajax\AjaxResponse $response */
         $response = $this->ajaxRenderer->renderResponse($result, $request, $this->routeMatch);
     }
     foreach ($commands as $command) {
         $response->addCommand($command, TRUE);
     }
     return $response;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:38,代码来源:FormAjaxResponseBuilder.php

示例2: executeValidateHandlers

 /**
  * {@inheritdoc}
  */
 public function executeValidateHandlers(&$form, FormStateInterface &$form_state)
 {
     // If there was a button pressed, use its handlers.
     $handlers = $form_state->getValidateHandlers();
     // Otherwise, check for a form-level handler.
     if (!$handlers && isset($form['#validate'])) {
         $handlers = $form['#validate'];
     }
     foreach ($handlers as $callback) {
         call_user_func_array($form_state->prepareCallback($callback), array(&$form, &$form_state));
     }
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:15,代码来源:FormValidator.php

示例3: prepareCallback

 /**
  * {@inheritdoc}
  */
 public function prepareCallback($callback)
 {
     return $this->mainFormState->prepareCallback($callback);
 }
开发者ID:Laudanum,项目名称:authorization,代码行数:7,代码来源:SubFormState.php

示例4: executeSubmitHandlers

 /**
  * {@inheritdoc}
  */
 public function executeSubmitHandlers(&$form, FormStateInterface &$form_state)
 {
     // If there was a button pressed, use its handlers.
     $handlers = $form_state->getSubmitHandlers();
     // Otherwise, check for a form-level handler.
     if (!$handlers && !empty($form['#submit'])) {
         $handlers = $form['#submit'];
     }
     foreach ($handlers as $callback) {
         // Check if a previous _submit handler has set a batch, but make sure we
         // do not react to a batch that is already being processed (for instance
         // if a batch operation performs a
         //  \Drupal\Core\Form\FormBuilderInterface::submitForm()).
         if (($batch =& $this->batchGet()) && !isset($batch['id'])) {
             // Some previous submit handler has set a batch. To ensure correct
             // execution order, store the call in a special 'control' batch set.
             // See _batch_next_set().
             $batch['sets'][] = array('form_submit' => $callback);
             $batch['has_form_submits'] = TRUE;
         } else {
             call_user_func_array($form_state->prepareCallback($callback), array(&$form, &$form_state));
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:27,代码来源:FormSubmitter.php

示例5: prepareCallback

 /**
  * {@inheritdoc}
  */
 public function prepareCallback($callback)
 {
     return $this->decoratedFormState->prepareCallback($callback);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:7,代码来源:FormStateDecoratorBase.php

示例6: testPrepareCallback

 /**
  * @covers ::prepareCallback
  *
  * @dataProvider providerPrepareCallback
  *
  * @param string|callable $unprepared_callback
  * @param callable $prepared_callback
  */
 public function testPrepareCallback($unprepared_callback, callable $prepared_callback)
 {
     $this->decoratedFormState->prepareCallback($unprepared_callback)->willReturn($prepared_callback)->shouldBeCalled();
     $this->assertSame($prepared_callback, $this->formStateDecoratorBase->prepareCallback($unprepared_callback));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:FormStateDecoratorBaseTest.php


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