class ViewsMegarowController in Views Megarow 8
Default controller for Ajax requests.
Hierarchy
- class \Drupal\views_megarow\Controller\ViewsMegarowController implements \Symfony\Component\DependencyInjection\ContainerAwareInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
Expanded class hierarchy of ViewsMegarowController
1 string reference to 'ViewsMegarowController'
1 service uses ViewsMegarowController
File
- src/
Controller/ ViewsMegarowController.php, line 14
Namespace
Drupal\views_megarow\ControllerView source
class ViewsMegarowController implements ContainerAwareInterface {
use ContainerAwareTrait;
/**
* The controller resolver.
*
* @var \Drupal\Core\Controller\ControllerResolverInterface
*/
protected $controllerResolver;
/**
* The Ajax response renderer.
*
* @var \Drupal\Core\Ajax\AjaxResponseRenderer
*/
protected $viewsMegarowRenderer;
/**
* Constructs a new AjaxController instance.
*
* @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver
* The controller resolver.
* @param \Drupal\Core\Ajax\AjaxResponseRenderer $ajax_renderer
* The Ajax response renderer.
*/
public function __construct(ControllerResolver $controller_resolver, ViewsMegarowResponseRenderer $views_megarow_renderer) {
$this->controllerResolver = $controller_resolver;
$this->viewsMegarowRenderer = $views_megarow_renderer;
}
/**
* Controller method for Ajax content.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
* @param callable $_content
* The callable that returns the content of the Ajax response.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* A response object.
*/
public function content(Request $request, $_content) {
$content = $this
->getContentResult($request, $_content);
return $this->viewsMegarowRenderer
->render($content);
}
/**
* Returns the result of invoking the sub-controller.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
* @param mixed $controller_definition
* A controller definition string, or a callable object/closure.
*
* @return mixed
* The result of invoking the controller. Render arrays, strings, HtmlPage,
* and HtmlFragment objects are possible.
*/
public function getContentResult(Request $request, $controller_definition) {
if ($controller_definition instanceof \Closure) {
$callable = $controller_definition;
}
else {
$callable = $this->controllerResolver
->getControllerFromDefinition($controller_definition);
}
$arguments = $this->controllerResolver
->getArguments($request, $callable);
$page_content = call_user_func_array($callable, $arguments);
return $page_content;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ViewsMegarowController:: |
protected | property | The controller resolver. | |
ViewsMegarowController:: |
protected | property | The Ajax response renderer. | |
ViewsMegarowController:: |
public | function | Controller method for Ajax content. | |
ViewsMegarowController:: |
public | function | Returns the result of invoking the sub-controller. | |
ViewsMegarowController:: |
public | function | Constructs a new AjaxController instance. |