-
-
Notifications
You must be signed in to change notification settings - Fork 188
/
AbstractWidgetController.php
56 lines (52 loc) · 1.84 KB
/
AbstractWidgetController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Neos\FluidAdaptor\Core\Widget;
/*
* This file is part of the Neos.FluidAdaptor package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\ActionResponse;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\FluidAdaptor\Core\Widget\Exception\WidgetContextNotFoundException;
/**
* This is the base class for all widget controllers.
* Basically, it is an ActionController, and it additionally
* has $this->widgetConfiguration set to the Configuration of the current Widget.
*
* @api
*/
abstract class AbstractWidgetController extends ActionController
{
/**
* Configuration for this widget.
*
* @var array
* @api
*/
protected $widgetConfiguration;
/**
* Handles a request. The result output is returned by altering the given response.
*
* @param ActionRequest $request The request object
* @param ActionResponse $response The response, modified by this handler
* @return void
* @throws WidgetContextNotFoundException
* @throws \Neos\Flow\Mvc\Exception\UnsupportedRequestTypeException
* @api
*/
public function processRequest(ActionRequest $request, ActionResponse $response)
{
/** @var $widgetContext WidgetContext */
$widgetContext = $request->getInternalArgument('__widgetContext');
if (!$widgetContext instanceof WidgetContext) {
throw new WidgetContextNotFoundException('The widget context could not be found in the request.', 1307450180);
}
$this->widgetConfiguration = $widgetContext->getWidgetConfiguration();
parent::processRequest($request, $response);
}
}