-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix/add_purge_translator' into 'release/2.3.0'
Add purge translator See merge request metamodels/core!345
- Loading branch information
Showing
6 changed files
with
139 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of MetaModels/core. | ||
* | ||
* (c) 2012-2024 The MetaModels team. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* This project is provided in good faith and hope to be usable by anyone. | ||
* | ||
* @package MetaModels/core | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2012-2024 The MetaModels team. | ||
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
||
namespace MetaModels\BackendIntegration; | ||
|
||
use Contao\CoreBundle\Monolog\ContaoContext; | ||
use ContaoCommunityAlliance\Contao\Bindings\ContaoEvents; | ||
use ContaoCommunityAlliance\Contao\Bindings\Events\System\LogEvent; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
class PurgeTranslator | ||
{ | ||
public function __construct( | ||
private readonly string $cacheDir, | ||
private readonly EventDispatcherInterface $dispatcher, | ||
) { | ||
} | ||
|
||
|
||
/** | ||
* Purge the symfony translator. | ||
* | ||
* @return void | ||
* | ||
* @SuppressWarnings(PHPMD.Superglobals) | ||
* @SuppressWarnings(PHPMD.CamelCaseVariableName) | ||
*/ | ||
public function purge() | ||
{ | ||
$fileSystem = new Filesystem(); | ||
$fileSystem->remove($this->cacheDir); | ||
$this->dispatcher->dispatch( | ||
new LogEvent('Purged the Symfony translator', __METHOD__, ContaoContext::CRON), | ||
ContaoEvents::SYSTEM_LOG | ||
); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of MetaModels/core. | ||
* | ||
* (c) 2012-2019 The MetaModels team. | ||
* (c) 2012-2024 The MetaModels team. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -21,74 +21,86 @@ | |
* @author Ingolf Steinhardt <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @author Richard Henkenjohann <[email protected]> | ||
* @copyright 2012-2019 The MetaModels team. | ||
* @copyright 2012-2024 The MetaModels team. | ||
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
||
$container = \Contao\System::getContainer(); | ||
use Contao\ArrayUtil; | ||
use Contao\System; | ||
use MetaModels\BackendIntegration\PurgeAssets; | ||
use MetaModels\BackendIntegration\PurgeTranslator; | ||
use MetaModels\CoreBundle\Contao\Hooks\LoadDataContainer; | ||
use MetaModels\FrontendIntegration\Content\Filter; | ||
use MetaModels\FrontendIntegration\Content\FilterClearAll; | ||
use MetaModels\FrontendIntegration\FrontendFilter; | ||
use MetaModels\Widgets\MultiTextWidget; | ||
use MetaModels\Widgets\SubDcaWidget; | ||
use MetaModels\Widgets\TagsWidget; | ||
|
||
$container = System::getContainer(); | ||
|
||
// @deprecated Use the config parameter metamodels.system_columns instead. | ||
$GLOBALS['METAMODELS_SYSTEM_COLUMNS'] = $container->getParameter('metamodels.system_columns'); | ||
|
||
// Front-end modules. | ||
$GLOBALS['FE_MOD']['metamodels']['metamodels_frontendfilter'] = 'MetaModels\FrontendIntegration\Module\Filter'; | ||
$GLOBALS['FE_MOD']['metamodels']['metamodels_frontendclearall'] = | ||
'MetaModels\FrontendIntegration\Module\FilterClearAll'; | ||
$GLOBALS['FE_MOD']['metamodels']['metamodels_frontendfilter'] = Filter::class; | ||
$GLOBALS['FE_MOD']['metamodels']['metamodels_frontendclearall'] = FilterClearAll::class; | ||
|
||
// Content elements. | ||
$GLOBALS['TL_CTE']['metamodels']['metamodels_frontendfilter'] = 'MetaModels\FrontendIntegration\Content\Filter'; | ||
$GLOBALS['TL_CTE']['metamodels']['metamodels_frontendclearall'] = | ||
'MetaModels\FrontendIntegration\Content\FilterClearAll'; | ||
$GLOBALS['TL_CTE']['metamodels']['metamodels_frontendfilter'] = Filter::class; | ||
$GLOBALS['TL_CTE']['metamodels']['metamodels_frontendclearall'] = FilterClearAll::class; | ||
|
||
// Frontend widgets. | ||
$GLOBALS['TL_FFL']['multitext'] = 'MetaModels\Widgets\MultiTextWidget'; | ||
$GLOBALS['TL_FFL']['tags'] = 'MetaModels\Widgets\TagsWidget'; | ||
$GLOBALS['TL_FFL']['multitext'] = MultiTextWidget::class; | ||
$GLOBALS['TL_FFL']['tags'] = TagsWidget::class; | ||
|
||
// HOOKS. | ||
$GLOBALS['TL_HOOKS']['outputFrontendTemplate'][] = | ||
array('MetaModels\FrontendIntegration\FrontendFilter', 'generateClearAll'); | ||
$GLOBALS['TL_HOOKS']['outputFrontendTemplate'][] = [FrontendFilter::class, 'generateClearAll']; | ||
|
||
// Add cache only if dir defined in container (and therefore we are using the cache). | ||
if ($cacheDir = $container->getParameter('metamodels.cache_dir')) { | ||
// We need to translate the cache dir - otherwise the backend view is distorted. See \Contao\PurgeData::run(). | ||
$GLOBALS['TL_PURGE']['folders']['metamodels']['affected'] = [str_replace( | ||
$container->getParameter('kernel.cache_dir') . '/', | ||
'%s/', | ||
$cacheDir | ||
)]; | ||
$GLOBALS['TL_PURGE']['folders']['metamodels']['affected'] = [ | ||
str_replace( | ||
$container->getParameter('kernel.cache_dir') . '/', | ||
'%s/', | ||
$cacheDir | ||
) | ||
]; | ||
$GLOBALS['TL_PURGE']['folders']['metamodels']['callback'] = ['metamodels.cache.purger', 'purge']; | ||
} | ||
|
||
$GLOBALS['TL_PURGE']['folders']['metamodels_assets']['affected'][] = 'assets/metamodels'; | ||
$GLOBALS['TL_PURGE']['folders']['metamodels_assets']['callback'] = | ||
array('MetaModels\BackendIntegration\PurgeAssets', 'purge'); | ||
$GLOBALS['TL_PURGE']['folders']['metamodels_assets']['callback'] = [PurgeAssets::class, 'purge']; | ||
|
||
$GLOBALS['TL_PURGE']['folders']['translator']['affected'] = []; | ||
$GLOBALS['TL_PURGE']['folders']['translator']['callback'] = [PurgeTranslator::class, 'purge']; | ||
|
||
// Meta Information. | ||
$GLOBALS['METAMODELS']['metainformation']['allowedTitle'][] = 'text'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedTitle'][] = 'select'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedTitle'][] = 'translatedtext'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedTitle'][] = 'translatedselect'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedTitle'][] = 'combinedvalues'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedTitle'][] = 'translatedcombinedvalues'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'text'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'select'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'translatedtext'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'translatedselect'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'longtext'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'translatedlongtext'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'combinedvalues'; | ||
$GLOBALS['METAMODELS']['metainformation']['allowedDescription'][] = 'translatedcombinedvalues'; | ||
|
||
\Contao\ArrayUtil::arrayInsert($GLOBALS['BE_FFL'], 15, array | ||
( | ||
'mm_subdca' => 'MetaModels\Widgets\SubDcaWidget' | ||
)); | ||
ArrayUtil::arrayInsert($GLOBALS['BE_FFL'], 15, [ | ||
'mm_subdca' => SubDcaWidget::class | ||
]); | ||
|
||
// Initialize the filter parameters to an empty array if not initialized yet. | ||
if (!isset($GLOBALS['MM_FILTER_PARAMS'])) { | ||
$GLOBALS['MM_FILTER_PARAMS'] = array(); | ||
$GLOBALS['MM_FILTER_PARAMS'] = []; | ||
} | ||
|
||
$GLOBALS['TL_HOOKS']['initializeSystem'][] = ['metamodels.sub_system_boot', 'boot']; | ||
|
||
$GLOBALS['TL_HOOKS']['loadDataContainer'][] = | ||
[\MetaModels\CoreBundle\Contao\Hooks\LoadDataContainer::class, 'onLoadDataContainer']; | ||
$GLOBALS['TL_HOOKS']['loadDataContainer'][] = [LoadDataContainer::class, 'onLoadDataContainer']; |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of MetaModels/core. | ||
* | ||
* (c) 2012-2018 The MetaModels team. | ||
* (c) 2012-2024 The MetaModels team. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -15,7 +15,7 @@ | |
* @author Christian Schiffler <[email protected]> | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @copyright 2012-2018 The MetaModels team. | ||
* @copyright 2012-2024 The MetaModels team. | ||
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -25,3 +25,6 @@ | |
|
||
$GLOBALS['TL_LANG']['tl_maintenance_jobs']['metamodels_assets'][0] = 'MetaModels assets'; | ||
$GLOBALS['TL_LANG']['tl_maintenance_jobs']['metamodels_assets'][1] = 'Clear the MetaModels assets files (backend icons etc.).'; | ||
|
||
$GLOBALS['TL_LANG']['tl_maintenance_jobs']['translator'][0] = 'Symfony translator'; | ||
$GLOBALS['TL_LANG']['tl_maintenance_jobs']['translator'][1] = 'Clear the Symfony translator cache for active environment.'; |