Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Goran\SaveCloseCe\Hooks;
namespace Goran\SaveCloseCe\Provider;

use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\Components\ModifyButtonBarEvent;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
Expand All @@ -11,26 +12,18 @@

/**
* Add an extra save and close button at the end
*
* Class SaveButtonHook
* @package Goran\SaveCloseCe\Hooks
*/
class SaveCloseHook
class SaveCloseProvider
{
/**
* @param array $params
* @param $buttonBar
* @return array
*/
public function addSaveCloseButton($params, &$buttonBar)
public function __invoke(ModifyButtonBarEvent $event): void
{
$buttons = $params['buttons'];
$buttons = $event->getButtons();
$saveButton = $buttons[ButtonBar::BUTTON_POSITION_LEFT][2][0] ?? null;
if ($saveButton instanceof InputButton) {
/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);

$saveCloseButton = $buttonBar->makeInputButton()
$saveCloseButton = $event->getButtonBar()->makeInputButton()
->setName('_saveandclosedok')
->setValue('1')
->setForm($saveButton->getForm())
Expand All @@ -40,7 +33,7 @@ public function addSaveCloseButton($params, &$buttonBar)

$buttons[ButtonBar::BUTTON_POSITION_LEFT][2][] = $saveCloseButton;
}
return $buttons;
$event->setButtons($buttons);
}

/**
Expand Down
12 changes: 12 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

Goran\SaveCloseCe\:
resource: '../Classes/*'
Goran\SaveCloseCe\Provider\SaveCloseProvider:
tags:
- name: event.listener
identifier: 'save-close-to-button-bar'
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
}
},
"require": {
"php": "^7. || ^8.0",
"typo3/cms-core": "^9.5 || ^10.2 || ^11.0"
"php": "^7.4 || ^8.0 || ^8.1",
"typo3/cms-core": "^11.0 || 12.0^"
},
"extra": {
"typo3/cms": {
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[
'depends' =>
[
'typo3' => '9.5.0-11.5.99',
'typo3' => '11.5.0-12.4.99',
],
'conflicts' =>
[],
Expand Down
4 changes: 1 addition & 3 deletions ext_tables.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
if (!defined('TYPO3_MODE')) {
if (!defined('TYPO3')) {
die('Access denied.');
}

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Backend\Template\Components\ButtonBar']['getButtonsHook'][] = 'Goran\SaveCloseCe\Hooks\SaveCloseHook->addSaveCloseButton';