From a4cb89953de07ad24cf1242127b5f1b8802db1e3 Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Sun, 31 Mar 2019 14:52:54 +0200 Subject: [PATCH 1/2] Create top level exceptions that can be applied for frontend and backend. --- .../Exception/DefinitionException.php | 5 ++- .../Exception/EditOnlyModeException.php | 3 +- .../Exception/NotCreatableException.php | 3 +- .../Exception/NotDeletableException.php | 3 +- src/Exception/NotEditableException.php | 35 +++++++++++++++++++ src/deprecated-autoload.php | 8 +++++ 6 files changed, 51 insertions(+), 6 deletions(-) rename src/{Contao/View/Contao2BackendView => }/Exception/DefinitionException.php (91%) rename src/{Contao/View/Contao2BackendView => }/Exception/EditOnlyModeException.php (89%) rename src/{Contao/View/Contao2BackendView => }/Exception/NotCreatableException.php (89%) rename src/{Contao/View/Contao2BackendView => }/Exception/NotDeletableException.php (89%) create mode 100644 src/Exception/NotEditableException.php diff --git a/src/Contao/View/Contao2BackendView/Exception/DefinitionException.php b/src/Exception/DefinitionException.php similarity index 91% rename from src/Contao/View/Contao2BackendView/Exception/DefinitionException.php rename to src/Exception/DefinitionException.php index 46c758745..0e45aa04a 100644 --- a/src/Contao/View/Contao2BackendView/Exception/DefinitionException.php +++ b/src/Exception/DefinitionException.php @@ -14,14 +14,13 @@ * @author David Molineus * @author Christian Schiffler * @author Sven Baumann + * @author Richard Henkenjohann * @copyright 2013-2019 Contao Community Alliance. * @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ -namespace ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception; - -use ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException; +namespace ContaoCommunityAlliance\DcGeneral\Exception; /** * Class DefinitionException. diff --git a/src/Contao/View/Contao2BackendView/Exception/EditOnlyModeException.php b/src/Exception/EditOnlyModeException.php similarity index 89% rename from src/Contao/View/Contao2BackendView/Exception/EditOnlyModeException.php rename to src/Exception/EditOnlyModeException.php index f8f5299d4..e397a3da0 100644 --- a/src/Contao/View/Contao2BackendView/Exception/EditOnlyModeException.php +++ b/src/Exception/EditOnlyModeException.php @@ -14,12 +14,13 @@ * @author David Molineus * @author Christian Schiffler * @author Sven Baumann + * @author Richard Henkenjohann * @copyright 2013-2019 Contao Community Alliance. * @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ -namespace ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception; +namespace ContaoCommunityAlliance\DcGeneral\Exception; /** * Exception is thrown if an data definition is in edit only mode. diff --git a/src/Contao/View/Contao2BackendView/Exception/NotCreatableException.php b/src/Exception/NotCreatableException.php similarity index 89% rename from src/Contao/View/Contao2BackendView/Exception/NotCreatableException.php rename to src/Exception/NotCreatableException.php index e48be5366..bbd2528e7 100644 --- a/src/Contao/View/Contao2BackendView/Exception/NotCreatableException.php +++ b/src/Exception/NotCreatableException.php @@ -14,12 +14,13 @@ * @author David Molineus * @author Christian Schiffler * @author Sven Baumann + * @author Richard Henkenjohann * @copyright 2013-2019 Contao Community Alliance. * @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ -namespace ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception; +namespace ContaoCommunityAlliance\DcGeneral\Exception; /** * Class NotDeletableException. diff --git a/src/Contao/View/Contao2BackendView/Exception/NotDeletableException.php b/src/Exception/NotDeletableException.php similarity index 89% rename from src/Contao/View/Contao2BackendView/Exception/NotDeletableException.php rename to src/Exception/NotDeletableException.php index 8011ee15d..df7e77a0a 100644 --- a/src/Contao/View/Contao2BackendView/Exception/NotDeletableException.php +++ b/src/Exception/NotDeletableException.php @@ -14,12 +14,13 @@ * @author David Molineus * @author Christian Schiffler * @author Sven Baumann + * @author Richard Henkenjohann * @copyright 2013-2019 Contao Community Alliance. * @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later * @filesource */ -namespace ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception; +namespace ContaoCommunityAlliance\DcGeneral\Exception; /** * Class NotDeletableException. diff --git a/src/Exception/NotEditableException.php b/src/Exception/NotEditableException.php new file mode 100644 index 000000000..0e3130ecf --- /dev/null +++ b/src/Exception/NotEditableException.php @@ -0,0 +1,35 @@ + + * @copyright 2013-2019 Contao Community Alliance. + * @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later + * @filesource + */ + +namespace ContaoCommunityAlliance\DcGeneral\Exception; + +/** + * Class NotEditableException. + * + * This exception is thrown if a data definition does not support edit actions. + */ +class NotEditableException extends DefinitionException +{ + /** + * The message template. + * + * @var string + */ + protected $message = 'Not able to perform edit action for data definition "%s".'; +} diff --git a/src/deprecated-autoload.php b/src/deprecated-autoload.php index d5a5e114f..fb5d8c406 100644 --- a/src/deprecated-autoload.php +++ b/src/deprecated-autoload.php @@ -19,10 +19,18 @@ // This hack is to load the "old locations" of the classes. use ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\EventListener\ColorPickerWizardListener; +use ContaoCommunityAlliance\DcGeneral\Exception\DefinitionException; +use ContaoCommunityAlliance\DcGeneral\Exception\EditOnlyModeException; +use ContaoCommunityAlliance\DcGeneral\Exception\NotCreatableException; +use ContaoCommunityAlliance\DcGeneral\Exception\NotDeletableException; spl_autoload_register( function ($class) { static $classes = [ + '\ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception\DefinitionException' => DefinitionException::class, + '\ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception\EditOnlyModeException' => EditOnlyModeException::class, + '\ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception\NotCreatableException' => NotCreatableException::class, + '\ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Exception\NotDeletableException' => NotDeletableException::class, '\ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Subscriber\ColorPickerWizardSubscriber' => ColorPickerWizardListener::class, ]; From bfcf21e576cbd903f25dfb685f97fa2989491901 Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Wed, 3 Apr 2019 19:02:47 +0200 Subject: [PATCH 2/2] Add author. --- src/deprecated-autoload.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/deprecated-autoload.php b/src/deprecated-autoload.php index fb5d8c406..32a9f7c78 100644 --- a/src/deprecated-autoload.php +++ b/src/deprecated-autoload.php @@ -12,6 +12,7 @@ * * @package contao-community-alliance/dc-general * @author Sven Baumann + * @author Richard Henkenjohann * @copyright 2013-2019 Contao Community Alliance. * @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later * @filesource