You are here

interface EntityFormInterface in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/EntityFormInterface.php \Drupal\Core\Entity\EntityFormInterface

Defines an interface for entity form classes.

Hierarchy

Expanded class hierarchy of EntityFormInterface

All classes that implement EntityFormInterface

1 file declares its use of EntityFormInterface
language.module in core/modules/language/language.module
Add language handling functionality to Drupal.

File

core/lib/Drupal/Core/Entity/EntityFormInterface.php, line 19
Contains \Drupal\Core\Entity\EntityFormInterface.

Namespace

Drupal\Core\Entity
View source
interface EntityFormInterface extends BaseFormIdInterface {

  /**
   * Sets the operation for this form.
   *
   * @param string $operation
   *   The name of the current operation.
   *
   * @return $this
   */
  public function setOperation($operation);

  /**
   * Gets the operation identifying the form.
   *
   * @return string
   *   The name of the operation.
   */
  public function getOperation();

  /**
   * Gets the form entity.
   *
   * The form entity which has been used for populating form element defaults.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The current form entity.
   */
  public function getEntity();

  /**
   * Sets the form entity.
   *
   * Sets the form entity which will be used for populating form element
   * defaults. Usually, the form entity gets updated by
   * \Drupal\Core\Entity\EntityFormInterface::submit(), however this may
   * be used to completely exchange the form entity, e.g. when preparing the
   * rebuild of a multi-step form.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity the current form should operate upon.
   *
   * @return $this
   */
  public function setEntity(EntityInterface $entity);

  /**
   * Determines which entity will be used by this form from a RouteMatch object.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The route match.
   * @param string $entity_type_id
   *   The entity type identifier.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity object as determined from the passed-in route match.
   */
  public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entity_type_id);

  /**
   * Builds an updated entity object based upon the submitted form values.
   *
   * For building the updated entity object the form's entity is cloned and
   * the submitted form values are copied to entity properties. The form's
   * entity remains unchanged.
   *
   * @see \Drupal\Core\Entity\EntityFormInterface::getEntity()
   *
   * @param array $form
   *   A nested array form elements comprising the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   An updated copy of the form's entity object.
   */
  public function buildEntity(array $form, FormStateInterface $form_state);

  /**
   * Form submission handler for the 'save' action.
   *
   * Normally this method should be overridden to provide specific messages to
   * the user and redirect the form after the entity has been saved.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return int
   *   Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
   */
  public function save(array $form, FormStateInterface $form_state);

  /**
   * Sets the string translation service for this form.
   *
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   The translation manager.
   *
   * @return $this
   */
  public function setStringTranslation(TranslationInterface $string_translation);

  /**
   * Sets the module handler for this form.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   *
   * @return $this
   */
  public function setModuleHandler(ModuleHandlerInterface $module_handler);

  /**
   * Sets the entity manager for this form.
   *
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager.
   *
   * @return $this
   *
   * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
   *
   * @todo Remove this set call in https://www.drupal.org/node/2603542.
   */
  public function setEntityManager(EntityManagerInterface $entity_manager);

  /**
   * Sets the entity type manager for this form.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   *
   * @return $this
   */
  public function setEntityTypeManager(EntityTypeManagerInterface $entity_type_manager);

}

Members

Namesort descending Modifiers Type Description Overrides
BaseFormIdInterface::getBaseFormId public function Returns a string identifying the base form. 2
EntityFormInterface::buildEntity public function Builds an updated entity object based upon the submitted form values. 1
EntityFormInterface::getEntity public function Gets the form entity. 1
EntityFormInterface::getEntityFromRouteMatch public function Determines which entity will be used by this form from a RouteMatch object. 1
EntityFormInterface::getOperation public function Gets the operation identifying the form. 1
EntityFormInterface::save public function Form submission handler for the 'save' action. 1
EntityFormInterface::setEntity public function Sets the form entity. 1
EntityFormInterface::setEntityManager Deprecated public function Sets the entity manager for this form. 1
EntityFormInterface::setEntityTypeManager public function Sets the entity type manager for this form. 1
EntityFormInterface::setModuleHandler public function Sets the module handler for this form. 1
EntityFormInterface::setOperation public function Sets the operation for this form. 1
EntityFormInterface::setStringTranslation public function Sets the string translation service for this form.
FormInterface::buildForm public function Form constructor. 157
FormInterface::getFormId public function Returns a unique string identifying the form. 212
FormInterface::submitForm public function Form submission handler. 167
FormInterface::validateForm public function Form validation handler. 20