Example #1
0
 /**
  * {@inheritdoc}
  */
 public function setFormObject(FormInterface $form_object)
 {
     $this->mainFormState->setFormObject($form_object);
     return $this;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getFormId($form_arg, FormStateInterface &$form_state)
 {
     // If the $form_arg is the name of a class, instantiate it. Don't allow
     // arbitrary strings to be passed to the class resolver.
     if (is_string($form_arg) && class_exists($form_arg)) {
         $form_arg = $this->classResolver->getInstanceFromDefinition($form_arg);
     }
     if (!is_object($form_arg) || !$form_arg instanceof FormInterface) {
         throw new \InvalidArgumentException("The form argument {$form_arg} is not a valid form.");
     }
     // Add the $form_arg as the callback object and determine the form ID.
     $form_state->setFormObject($form_arg);
     if ($form_arg instanceof BaseFormIdInterface) {
         $form_state->addBuildInfo('base_form_id', $form_arg->getBaseFormId());
     }
     return $form_arg->getFormId();
 }
 /**
  * @covers ::setFormObject
  */
 public function testSetFormObject()
 {
     $form = $this->getMock(FormInterface::class);
     $this->decoratedFormState->setFormObject($form)->shouldBeCalled();
     $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setFormObject($form));
 }