Skip to content

Commit

Permalink
Merge PR #41 from zonky2
Browse files Browse the repository at this point in the history
  • Loading branch information
baumannsven committed Jan 25, 2023
2 parents 0254c7b + 6ebcda0 commit cb8e667
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/View/EditMask.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general-contao-frontend.
*
* (c) 2015-2022 Contao Community Alliance.
* (c) 2015-2023 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -15,20 +15,21 @@
* @author Richard Henkenjohann <[email protected]>
* @author Sven Baumann <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2015-2022 Contao Community Alliance.
* @copyright 2015-2023 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general-contao-frontend/blob/master/LICENSE LGPL-3.0
* @filesource
*/

namespace ContaoCommunityAlliance\DcGeneral\ContaoFrontend\View;

use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetEditModeButtonsEvent;
use ContaoCommunityAlliance\DcGeneral\ContaoFrontend\Event\DcGeneralFrontendEvents;
use ContaoCommunityAlliance\DcGeneral\ContaoFrontend\Event\HandleSubmitEvent;
use ContaoCommunityAlliance\DcGeneral\Data\DataProviderInterface;
use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetEditMaskSubHeadlineEvent;
use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetEditModeButtonsEvent;
use ContaoCommunityAlliance\DcGeneral\DataDefinition\ContainerInterface;
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\PropertiesDefinitionInterface;
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Palette\PaletteInterface;
use ContaoCommunityAlliance\DcGeneral\Data\DataProviderInterface;
use ContaoCommunityAlliance\DcGeneral\Data\ModelInterface;
use ContaoCommunityAlliance\DcGeneral\Data\PropertyValueBag;
use ContaoCommunityAlliance\DcGeneral\DcGeneralEvents;
Expand Down Expand Up @@ -192,7 +193,7 @@ public function execute()
$template->setData(
[
'fieldsets' => $fieldSets,
'subHeadline' => $this->getHeadline(),
'subHeadline' => $this->getSubHeadline(),
'table' => $this->definition->getName(),
'enctype' => 'multipart/form-data',
'error' => $this->errors,
Expand Down Expand Up @@ -500,13 +501,30 @@ private function handleSubmit($buttons)
* Determine the headline to use.
*
* @return string.
*
* @deprecated This is deprecated since 2.3 and will be removed in 3.0.
*/
private function getHeadline()
private function getHeadline(): string
{
if ($this->model->getId()) {
return $this->translateLabel('editRecord', [$this->model->getId()]);
}
return $this->translateLabel('newRecord');
// @codingStandardsIgnoreStart
@\trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated - use getSubHeadline()!', E_USER_DEPRECATED);
// @codingStandardsIgnoreEnd

$this->getSubHeadline();
}

/**
* Determine the headline to use.
*
* @return string.
*/
private function getSubHeadline(): string
{
$event = new GetEditMaskSubHeadlineEvent($this->environment, $this->model);

$this->dispatcher->dispatch($event, $event::NAME);

return $event->getHeadline();
}

/**
Expand Down

0 comments on commit cb8e667

Please sign in to comment.