Wrapping controller for entity forms that serve as the main page body.
Expanded class hierarchy of HtmlEntityFormController
class HtmlEntityFormController extends HtmlFormController {
/**
* {@inheritdoc}
*
* Due to reflection, the argument must be named $_entity_form. The parent
* method has $request and $_form, but the parameter must match the route.
*/
public function content(Request $request, $_entity_form) {
return parent::content($request, $_entity_form);
}
/**
* {@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
* pattern: '/foo/{node}/bar'
* defaults:
* _entity_form: 'node.edit'
* @endcode
* This means that the edit form controller for the node entity will used.
* If the entity type has a default form controller, only the name of the
* entity {param} needs to be passed:
* @code
* pattern: '/foo/{node}/baz'
* defaults:
* _entity_form: 'node'
* @endcode
*/
protected function getFormObject(Request $request, $form_arg) {
$manager = $this->container
->get('plugin.manager.entity');
// 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 = $manager
->getStorageController($entity_type)
->create(array());
}
return $manager
->getFormController($entity_type, $operation)
->setEntity($entity);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HtmlEntityFormController:: |
public | function |
Due to reflection, the argument must be named $_entity_form. The parent
method has $request and $_form, but the parameter must match the route. Overrides HtmlFormController:: |
|
HtmlEntityFormController:: |
protected | function |
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: Overrides HtmlFormController:: |
|
HtmlFormController:: |
protected | property | The injection container for this object. | |
HtmlFormController:: |
public | function |
Injects the service container used by this object. Overrides ContainerAwareInterface:: |