-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
352 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright notice | ||
* | ||
* (c) 2024 in2code.de and the following authors: | ||
* Daniel Hoffmann <[email protected]> | ||
* | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
*/ | ||
|
||
namespace In2code\In2publishCore\Event; | ||
|
||
use TYPO3\CMS\Backend\Template\ModuleTemplate; | ||
|
||
final class ModuleTemplateWasPreparedForRendering | ||
{ | ||
private ModuleTemplate $moduleTemplate; | ||
private string $controllerClass; | ||
private string $actionMethodName; | ||
|
||
public function __construct( | ||
ModuleTemplate $moduleTemplate, | ||
string $controllerClass, | ||
string $actionMethodName | ||
) { | ||
$this->moduleTemplate = $moduleTemplate; | ||
$this->controllerClass = $controllerClass; | ||
$this->actionMethodName = $actionMethodName; | ||
} | ||
|
||
public function getModuleTemplate(): ModuleTemplate | ||
{ | ||
return $this->moduleTemplate; | ||
} | ||
|
||
public function getControllerClass(): string | ||
{ | ||
return $this->controllerClass; | ||
} | ||
|
||
public function getActionMethodName(): string | ||
{ | ||
return $this->actionMethodName; | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
Classes/Features/RedirectsSupport/Event/RedirectsWereFilteredForListing.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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Copyright notice | ||
* | ||
* (c) 2024 in2code.de and the following authors: | ||
* Daniel Hoffmann <[email protected]> | ||
* | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
*/ | ||
|
||
namespace In2code\In2publishCore\Features\RedirectsSupport\Event; | ||
|
||
final class RedirectsWereFilteredForListing | ||
{ | ||
private array $redirects; | ||
|
||
public function __construct(array $redirects) | ||
{ | ||
$this->redirects = $redirects; | ||
} | ||
|
||
public function getRedirects(): array | ||
{ | ||
return $this->redirects; | ||
} | ||
|
||
public function setRedirects(array $redirects): void | ||
{ | ||
$this->redirects = $redirects; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
Classes/Features/RedirectsSupport/ViewHelpers/ShowReasonsButtonViewHelper.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,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\In2publishCore\Features\RedirectsSupport\ViewHelpers; | ||
|
||
/* | ||
* Copyright notice | ||
* | ||
* (c) 2024 in2code.de | ||
* Daniel Hoffmann <[email protected]> | ||
* | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
*/ | ||
|
||
use In2code\In2publishCore\Features\RedirectsSupport\Domain\Model\SysRedirectDatabaseRecord; | ||
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; | ||
|
||
class ShowReasonsButtonViewHelper extends AbstractTagBasedViewHelper | ||
{ | ||
protected $tagName = 'a'; | ||
|
||
public function initializeArguments(): void | ||
{ | ||
parent::initializeArguments(); | ||
$this->registerUniversalTagAttributes(); | ||
$this->registerArgument('redirectRecord', SysRedirectDatabaseRecord::class, '', true); | ||
} | ||
|
||
public function render(): string | ||
{ | ||
/** | ||
* @var $redirectRecord SysRedirectDatabaseRecord | ||
*/ | ||
$redirectRecord = $this->arguments['redirectRecord']; | ||
$this->tag->addAttribute('href', '#'); | ||
$this->tag->setContent($this->renderChildren()); | ||
$modalConfiguration = [ | ||
'settings' => [ | ||
'title' => LocalizationUtility::translate('LLL:EXT:in2publish_core/Resources/Private/Language/locallang_mod5.xlf:modal.reasons.title'), | ||
'content' => implode("\r\n", $redirectRecord->getReasonsWhyTheRecordIsNotPublishableHumanReadable()), | ||
'severity' => 1, | ||
], | ||
'buttons' => [ | ||
'abort' => [ | ||
'text' => 'Abort', | ||
'btnClass' => 'btn btn-default', | ||
'name' => 'abort', | ||
'active' => true, | ||
], | ||
], | ||
]; | ||
$this->tag->addAttribute('data-modal-configuration', json_encode($modalConfiguration)); | ||
|
||
return $this->tag->render(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Documentation/Developers/Events/ModuleTemplateWasPreparedForRendering.md
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,38 @@ | ||
# ModuleTemplateWasPreparedForRendering | ||
|
||
## When | ||
|
||
This event is fired each time a backend module is opened. | ||
|
||
## What | ||
|
||
* `moduleTemplate`: an object of type TYPO3\CMS\Backend\Template\ModuleTemplate | ||
* `controllerClass`: controller class calling the event | ||
* `actionMethodName`: action method name calling the event | ||
|
||
## Possibilities | ||
|
||
With this event you can add e.g. buttons to the docheader of a backend module. | ||
|
||
### Example | ||
|
||
This example shows you how to add a button to the docheader of the redirect module. | ||
|
||
```php | ||
use In2code\In2publish\Features\ContentLanguageControl\Toolbar\LanguageSelectionButtonInjection; | ||
use In2code\In2publishCore\Event\ModuleTemplateWasPreparedForRendering; | ||
use In2code\In2publishCore\Features\RedirectsSupport\Controller\RedirectController; | ||
|
||
class ModuleTemplateButtonBarSelectionRenderer | ||
{ | ||
use LanguageSelectionButtonInjection; | ||
|
||
public function whenModuleTemplateWasPreparedForRendering(ModuleTemplateWasPreparedForRendering $event): void | ||
{ | ||
if (RedirectController::class === $event->getControllerClass() && 'listAction' === $event->getActionMethodName()){ | ||
$moduleTemplate = $event->getModuleTemplate(); | ||
$moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($this->languageSelectionButton); | ||
} | ||
} | ||
} | ||
``` |
Oops, something went wrong.