class EntityBrowserFormController in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/Controllers/EntityBrowserFormController.php \Drupal\entity_browser\Controllers\EntityBrowserFormController
Standalone entity browser page.
Hierarchy
- class \Drupal\Core\Controller\FormController uses DependencySerializationTrait
- class \Drupal\Core\Controller\HtmlFormController
- class \Drupal\entity_browser\Controllers\EntityBrowserFormController implements ContainerInjectionInterface
- class \Drupal\Core\Controller\HtmlFormController
Expanded class hierarchy of EntityBrowserFormController
File
- src/
Controllers/ EntityBrowserFormController.php, line 19
Namespace
Drupal\entity_browser\ControllersView source
class EntityBrowserFormController extends HtmlFormController implements ContainerInjectionInterface {
/**
* Current route match service.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $currentRouteMatch;
/**
* The browser storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $browserStorage;
/**
* Current request.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* Constructs Entity browser form controller.
*
* @param \Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface $argument_resolver
* The argument resolver.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
* @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver
* The class resolver.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* Current route match service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager service.
* @param \Symfony\Component\HttpFoundation\Request $request
* Current request.
*/
public function __construct(ArgumentResolverInterface $argument_resolver, FormBuilderInterface $form_builder, ClassResolverInterface $class_resolver, RouteMatchInterface $route_match, EntityTypeManagerInterface $entity_type_manager, Request $request) {
parent::__construct($argument_resolver, $form_builder, $class_resolver);
$this->currentRouteMatch = $route_match;
$this->browserStorage = $entity_type_manager
->getStorage('entity_browser');
$this->request = $request;
$this->formBuilder = $form_builder;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('http_kernel.controller.argument_resolver'), $container
->get('form_builder'), $container
->get('class_resolver'), $container
->get('current_route_match'), $container
->get('entity_type.manager'), $container
->get('request_stack')
->getCurrentRequest());
}
/**
* {@inheritdoc}
*/
protected function getFormObject(RouteMatchInterface $route_match, $form_arg) {
$browser = $this
->loadBrowser();
if ($original_path = $this->request
->get('original_path')) {
$browser
->addAdditionalWidgetParameters([
'path_parts' => explode('/', $original_path),
]);
}
return $browser
->getFormObject();
}
/**
* Standalone entity browser title callback.
*/
public function title() {
$browser = $this
->loadBrowser();
return Xss::filter($browser
->label());
}
/**
* Loads entity browser object for this page.
*
* @return \Drupal\entity_browser\EntityBrowserInterface
* Loads the entity browser object
*/
protected function loadBrowser() {
/* @var $route \Symfony\Component\Routing\Route */
$route = $this->currentRouteMatch
->getRouteObject();
/* @var $browser \Drupal\entity_browser\EntityBrowserInterface */
return $this->browserStorage
->load($route
->getDefault('entity_browser_id'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EntityBrowserFormController:: |
protected | property | The browser storage. | |
EntityBrowserFormController:: |
protected | property | Current route match service. | |
EntityBrowserFormController:: |
protected | property | Current request. | |
EntityBrowserFormController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
EntityBrowserFormController:: |
protected | function |
Returns the object used to build the form. Overrides HtmlFormController:: |
|
EntityBrowserFormController:: |
protected | function | Loads entity browser object for this page. | |
EntityBrowserFormController:: |
public | function | Standalone entity browser title callback. | |
EntityBrowserFormController:: |
public | function |
Constructs Entity browser form controller. Overrides HtmlFormController:: |
|
FormController:: |
protected | property | The argument resolver. | |
FormController:: |
protected | property | The controller resolver. | |
FormController:: |
protected | property | The form builder. | |
FormController:: |
public | function | Invokes the form and returns the result. | |
HtmlFormController:: |
protected | property | The class resolver. | |
HtmlFormController:: |
protected | function |
Extracts the form argument string from a request. Overrides FormController:: |