Skip to content

Commit

Permalink
Merge pull request #6 from trilobit-gmbh/feature/someRework
Browse files Browse the repository at this point in the history
run cs fixer, rework structure
  • Loading branch information
trilobit-gmbh committed May 26, 2021
2 parents d8aedec + 6d936fc commit 1939001
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 56 deletions.
13 changes: 2 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.3",
"contao/core-bundle": "~4.4",
"codefog/contao-haste": "^4.0"
},
Expand All @@ -25,16 +25,7 @@
"autoload": {
"psr-4": {
"Trilobit\\ConstantsBundle\\": "src/"
},
"classmap": [
"src/Resources/contao/"
],
"exclude-from-classmap": [
"src/Resources/contao/config/",
"src/Resources/contao/dca/",
"src/Resources/contao/languages/",
"src/Resources/contao/templates/"
]
}
},
"extra": {
"contao-manager-plugin": "Trilobit\\ConstantsBundle\\ContaoManager\\Plugin"
Expand Down
7 changes: 7 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* @copyright trilobit GmbH
* @author trilobit GmbH <https://github.com/trilobit-gmbh>
* @license LGPL-3.0-or-later
* @link http://github.com/trilobit-gmbh/contao-constants-bundle
*/

namespace Trilobit\ConstantsBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down
7 changes: 7 additions & 0 deletions src/DependencyInjection/ConstantsExtension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* @copyright trilobit GmbH
* @author trilobit GmbH <https://github.com/trilobit-gmbh>
* @license LGPL-3.0-or-later
* @link http://github.com/trilobit-gmbh/contao-constants-bundle
*/

namespace Trilobit\ConstantsBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
9 changes: 8 additions & 1 deletion src/EventListener/DataContainer/ConstantsListener.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<?php

/*
* @copyright trilobit GmbH
* @author trilobit GmbH <https://github.com/trilobit-gmbh>
* @license LGPL-3.0-or-later
* @link http://github.com/trilobit-gmbh/contao-constants-bundle
*/

namespace Trilobit\ConstantsBundle\EventListener\DataContainer;

use Contao\DataContainer;
use Contao\System;
use Trilobit\ConstantsBundle\ConstantsModel;
use Trilobit\ConstantsBundle\Model\ConstantsModel;

class ConstantsListener
{
Expand Down
36 changes: 36 additions & 0 deletions src/EventListener/InsertTagListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* @copyright trilobit GmbH
* @author trilobit GmbH <https://github.com/trilobit-gmbh>
* @license LGPL-3.0-or-later
* @link http://github.com/trilobit-gmbh/contao-constants-bundle
*/

namespace Trilobit\ConstantsBundle\EventListener;

use Contao\CoreBundle\ServiceAnnotation\Hook;
use Trilobit\ConstantsBundle\Model\ConstantsModel;

class InsertTagListener
{
/**
* Class ReplaceInsertTags.
*
* @Hook("replaceInsertTags")
*/
public function __invoke(string $tag)
{
$chunks = explode('::', $tag);

if ('const' !== $chunks[0]) {
return false;
}

if (null === ($result = ConstantsModel::findPublishedByName($chunks[1]))) {
return false;
}

return $result->value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* @link http://github.com/trilobit-gmbh/contao-constants-bundle
*/

namespace Trilobit\ConstantsBundle;
namespace Trilobit\ConstantsBundle\Model;

use Model;
use Contao\Model;

/**
* Class SocialmediaModel.
Expand All @@ -23,7 +23,6 @@ class ConstantsModel extends Model

/**
* @param $intId
* @param array $arrOptions
* @param mixed $strName
*
* @return mixed
Expand Down
33 changes: 0 additions & 33 deletions src/Resources/contao/classes/ConstantsInsertTags.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @link http://github.com/trilobit-gmbh/contao-constants-bundle
*/

use Trilobit\ConstantsBundle\ConstantsInsertTags;
use Trilobit\ConstantsBundle\ConstantsModel;
use Trilobit\ConstantsBundle\EventListener\InsertTagListener;
use Trilobit\ConstantsBundle\Model\ConstantsModel;

$GLOBALS['BE_MOD']['trilobit']['tl_constants'] = [
'tables' => ['tl_constants'],
Expand All @@ -17,7 +17,7 @@
/*
* Register hook
*/
$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = [ConstantsInsertTags::class, 'replaceInsertTags'];
$GLOBALS['TL_HOOKS']['replaceInsertTags'][] = [InsertTagListener::class, '__invoke'];

/*
* Models
Expand Down
11 changes: 6 additions & 5 deletions src/Resources/contao/dca/tl_constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
* @link http://github.com/trilobit-gmbh/contao-constants-bundle
*/

use Trilobit\ConstantsBundle\EventListener\DataContainer\ConstantsListener;

$GLOBALS['TL_DCA']['tl_constants'] = [
// Config
'config' => [
'dataContainer' => 'Table',
'enableVersioning' => true,
'onload_callback' => [
[\Trilobit\ConstantsBundle\EventListener\DataContainer\ConstantsListener::class, 'modifyDca']
[ConstantsListener::class, 'modifyDca'],
],
'sql' => [
'keys' => [
Expand Down Expand Up @@ -98,8 +100,7 @@

// Palettes
'palettes' => [
'default' => '{key_legend},name,useWysiwygEditor,value;'
.'{published_legend:hide},published,start,stop',
'default' => '{key_legend},name,useWysiwygEditor,value;{published_legend:hide},published,start,stop',
],

// Subpalettes
Expand All @@ -119,8 +120,8 @@
'label' => &$GLOBALS['TL_LANG']['tl_constants']['useWysiwygEditor'],
'exclude' => true,
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50', 'submitOnChange' => true],
'sql' => "char(1) NOT NULL default ''"
'eval' => ['tl_class' => 'w50 m12', 'submitOnChange' => true],
'sql' => "char(1) NOT NULL default ''",
],
'value' => [
'label' => &$GLOBALS['TL_LANG']['tl_constants']['value'],
Expand Down

0 comments on commit 1939001

Please sign in to comment.