-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add events to assign own data to view and moduleTemplate (#595
) * [TASK] Add event to assign own data to view * [TASK] Add event to assign own data to moduleTemplate * [TASK] Add documentation for the new events * [TASK] Raise version number Closes: #593
- Loading branch information
Showing
18 changed files
with
240 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extcode\Cart\Controller; | ||
|
||
/* | ||
* This file is part of the package extcode/cart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
use Extcode\Cart\Event\View\ModifyViewEvent; | ||
|
||
abstract class ActionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController | ||
{ | ||
protected function dispatchModifyViewEvent(): void | ||
{ | ||
$modifyViewEvent = new ModifyViewEvent( | ||
$this->request, | ||
$this->settings, | ||
$this->view | ||
); | ||
|
||
$this->eventDispatcher->dispatch($modifyViewEvent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Classes/Event/Template/Components/ModifyModuleTemplateEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extcode\Cart\Event\Template\Components; | ||
|
||
/* | ||
* This file is part of the package extcode/cart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
use TYPO3\CMS\Backend\Template\ModuleTemplate; | ||
use TYPO3\CMS\Extbase\Mvc\RequestInterface; | ||
|
||
class ModifyModuleTemplateEvent | ||
{ | ||
public function __construct( | ||
private readonly RequestInterface $request, | ||
private readonly array $settings, | ||
private readonly ModuleTemplate $moduleTemplate, | ||
) {} | ||
|
||
public function getRequest(): RequestInterface | ||
{ | ||
return $this->request; | ||
} | ||
|
||
public function getSettings(): array | ||
{ | ||
return $this->settings; | ||
} | ||
|
||
public function getModuleTemplate(): ModuleTemplate | ||
{ | ||
return $this->moduleTemplate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Extcode\Cart\Event\View; | ||
|
||
/* | ||
* This file is part of the package extcode/cart. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
use TYPO3\CMS\Extbase\Mvc\RequestInterface; | ||
use TYPO3Fluid\Fluid\View\ViewInterface; | ||
|
||
class ModifyViewEvent | ||
{ | ||
public function __construct( | ||
private readonly RequestInterface $request, | ||
private readonly array $settings, | ||
private readonly ViewInterface $view, | ||
) {} | ||
|
||
public function getRequest(): RequestInterface | ||
{ | ||
return $this->request; | ||
} | ||
|
||
public function getSettings(): array | ||
{ | ||
return $this->settings; | ||
} | ||
|
||
public function getView(): ViewInterface | ||
{ | ||
return $this->view; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...mentation/Changelog/9.1/Feature-593-AddEventToAssignOwnDataToModuleTemplate.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.. include:: ../../Includes.rst.txt | ||
|
||
============================================================== | ||
Feature: #593 - Add event to assign own data to moduleTemplate | ||
============================================================== | ||
|
||
See `Issue 593 <https://github.com/extcode/cart/issues/593>`__ | ||
|
||
Description | ||
=========== | ||
|
||
Adding your own data to module templates is not so easy. In order to assign | ||
own data to the moduleTemplate, you need a way to assign your own data if you | ||
do not want to develop your own backend module. | ||
|
||
The `\Extcode\Cart\Event\Template\Components\ModifyModuleTemplateEvent` event | ||
is dispached in the OrderController for the backend module. | ||
|
||
An own EventListener can use the methods `getRequest()`, `getSettings()`, | ||
`getModuleTemplate()` to retrieve all the necessary information to assign custom | ||
data. | ||
The request object can be used to assign data for specific actions. | ||
|
||
Impact | ||
====== | ||
|
||
No impact is expected. | ||
|
||
|
||
.. index:: Backend |
32 changes: 32 additions & 0 deletions
32
Documentation/Changelog/9.1/Feature-593-AddEventToAssignOwnDataToView.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.. include:: ../../Includes.rst.txt | ||
|
||
==================================================== | ||
Feature: #593 - Add event to assign own data to view | ||
==================================================== | ||
|
||
See `Issue 593 <https://github.com/extcode/cart/issues/593>`__ | ||
|
||
Description | ||
=========== | ||
|
||
Adding your own data to plugin templates is not so easy. In order to assign | ||
own data to the view, you need a lib in TypoScript and a f:cObject in the | ||
template with some JavaScript on top. | ||
|
||
This `\Extcode\Cart\Event\View\ModifyViewEvent` event is dispached in all | ||
actions for which an output is generated via a template. Actions that are | ||
forwarded to another action do not require the event. | ||
|
||
An own EventListener can use the methods `getRequest()`, `getSettings()`, | ||
`getView()` to retrieve all the necessary information to assign custom data. | ||
The request object can be used to assign data for specific actions. For example, | ||
saved addresses of a returning logged-in user can be displayed for selection | ||
instead of the form for the billing address. | ||
|
||
Impact | ||
====== | ||
|
||
No impact is expected. | ||
|
||
|
||
.. index:: Backend |
Oops, something went wrong.