-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba0068b
commit 904be22
Showing
19 changed files
with
246 additions
and
579 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 |
---|---|---|
@@ -1,2 +1,17 @@ | ||
{ | ||
"symbol-whitelist" : [ | ||
"null", "true", "false", | ||
"self", "parent", | ||
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", | ||
"Contao\\ManagerPlugin\\Bundle\\BundlePluginInterface", | ||
"Contao\\ManagerPlugin\\Bundle\\Config\\BundleConfig", | ||
"Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface", | ||
"Contao\\ManagerPlugin\\Config\\ConfigPluginInterface", | ||
"Contao\\ManagerPlugin\\Routing\\RoutingPluginInterface", | ||
"CyberSpectrum\\I18N\\MetaModels\\MetaModelDictionaryDefinitionBuilder", | ||
"CyberSpectrum\\I18N\\MetaModels\\MetaModelDictionaryProvider", | ||
"MadeYourDay\\RockSolidCustomElements\\RockSolidCustomElementsBundle", | ||
"MetaModels\\CoreBundle\\MetaModelsCoreBundle", | ||
"Terminal42\\ChangeLanguage\\Terminal42ChangeLanguageBundle" | ||
] | ||
} |
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 |
---|---|---|
@@ -1,23 +1,6 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of cyberspectrum/i18n-contao-bundle. | ||
* | ||
* (c) 2019 CyberSpectrum. | ||
* | ||
* 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 cyberspectrum/i18n-contao-bundle | ||
* @author Christian Schiffler <[email protected]> | ||
* @copyright 2019 CyberSpectrum. | ||
* @license https://github.com/cyberspectrum/i18n-contao-bundle/blob/master/LICENSE MIT | ||
* @filesource | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace CyberSpectrum\I18N\ContaoBundle\Command; | ||
|
||
|
@@ -33,12 +16,8 @@ | |
*/ | ||
class DebugMapCommand extends Command | ||
{ | ||
/** | ||
* The map builder. | ||
* | ||
* @var MapBuilderInterface | ||
*/ | ||
private $mapBuilder; | ||
/** The map builder. */ | ||
private MapBuilderInterface $mapBuilder; | ||
|
||
/** | ||
* Create a new instance. | ||
|
@@ -51,28 +30,25 @@ public function __construct(MapBuilderInterface $mapBuilder) | |
$this->mapBuilder = $mapBuilder; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function configure(): void | ||
{ | ||
parent::configure(); | ||
|
||
$this->setName('debug:i18n-map'); | ||
$this->setDescription('Dump the mapping'); | ||
$this->addArgument('table', InputArgument::OPTIONAL, 'The table name'); | ||
$this->addArgument('source-language', InputArgument::OPTIONAL, 'The source language'); | ||
$this->addArgument('target-language', InputArgument::OPTIONAL, 'The target language'); | ||
$this->addArgument('table', InputArgument::REQUIRED, 'The table name'); | ||
$this->addArgument('source-language', InputArgument::REQUIRED, 'The source language'); | ||
$this->addArgument('target-language', InputArgument::REQUIRED, 'The target language'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$tableName = $input->getArgument('table'); | ||
$tableName = $input->getArgument('table'); | ||
assert(is_string($tableName)); | ||
$sourceLanguage = $input->getArgument('source-language'); | ||
assert(is_string($sourceLanguage)); | ||
$targetLanguage = $input->getArgument('target-language'); | ||
assert(is_string($targetLanguage)); | ||
|
||
$tableMap = $this->mapBuilder->getMappingFor($tableName, $sourceLanguage, $targetLanguage); | ||
$keys = $tableMap->sourceIds(); | ||
|
@@ -83,5 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
} | ||
|
||
$table->render(); | ||
|
||
return 0; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,23 +1,6 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of cyberspectrum/i18n-contao-bundle. | ||
* | ||
* (c) 2018 CyberSpectrum. | ||
* | ||
* 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 cyberspectrum/i18n-contao-bundle | ||
* @author Christian Schiffler <[email protected]> | ||
* @copyright 2018 CyberSpectrum. | ||
* @license https://github.com/cyberspectrum/i18n-contao-bundle/blob/master/LICENSE MIT | ||
* @filesource | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace CyberSpectrum\I18N\ContaoBundle\ContaoManager; | ||
|
||
|
@@ -27,13 +10,14 @@ | |
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; | ||
use Contao\ManagerPlugin\Config\ConfigPluginInterface; | ||
use Contao\ManagerPlugin\Routing\RoutingPluginInterface; | ||
use CyberSpectrum\I18N\ContaoBundle\CyberSpectrumI18NContaoBundle; | ||
use CyberSpectrum\I18NBundle\CyberSpectrumI18NBundle; | ||
use CyberSpectrum\I18N\ContaoBundle\CyberSpectrumI18NContaoBundle; | ||
use MetaModels\CoreBundle\MetaModelsCoreBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\Config\Loader\LoaderResolverInterface; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
use Symfony\Component\Routing\RouteCollection; | ||
|
||
/** | ||
* Plugin for the Contao Manager. | ||
|
@@ -43,7 +27,7 @@ class Plugin implements BundlePluginInterface, ConfigPluginInterface, RoutingPlu | |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBundles(ParserInterface $parser) | ||
public function getBundles(ParserInterface $parser): array | ||
{ | ||
return [ | ||
BundleConfig::create(CyberSpectrumI18NContaoBundle::class) | ||
|
@@ -62,18 +46,26 @@ public function getBundles(ParserInterface $parser) | |
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function registerContainerConfiguration(LoaderInterface $loader, array $managerConfig) | ||
public function registerContainerConfiguration(LoaderInterface $loader, array $managerConfig): void | ||
{ | ||
$loader->load('@CyberSpectrumI18NContaoBundle/Resources/contao-manager/framework.yml'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @psalm-suppress MixedInferredReturnType | ||
* @psalm-suppress MixedReturnStatement | ||
*/ | ||
public function getRouteCollection(LoaderResolverInterface $resolver, KernelInterface $kernel) | ||
public function getRouteCollection(LoaderResolverInterface $resolver, KernelInterface $kernel): ?RouteCollection | ||
{ | ||
return $resolver | ||
->resolve(__DIR__.'/../Resources/config/contao/routing.yml') | ||
->load(__DIR__.'/../Resources/config/contao/routing.yml'); | ||
$loader = $resolver->resolve(__DIR__ . '/../Resources/config/contao/routing.yml'); | ||
|
||
if (!$loader instanceof LoaderInterface) { | ||
throw new \RuntimeException('Failed to load routes'); | ||
} | ||
|
||
return $loader | ||
->load(__DIR__ . '/../Resources/config/contao/routing.yml'); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,68 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of cyberspectrum/i18n-contao-bundle. | ||
* | ||
* (c) 2018 CyberSpectrum. | ||
* | ||
* 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 cyberspectrum/i18n-contao-bundle | ||
* @author Christian Schiffler <[email protected]> | ||
* @copyright 2018 CyberSpectrum. | ||
* @license https://github.com/cyberspectrum/i18n-contao-bundle/blob/master/LICENSE MIT | ||
* @filesource | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
declare(strict_types=1); | ||
|
||
namespace CyberSpectrum\I18N\ContaoBundle\Controller; | ||
|
||
use CyberSpectrum\I18N\Contao\Mapping\MapBuilderInterface; | ||
use CyberSpectrum\I18N\Contao\Mapping\Terminal42ChangeLanguage\ArticleMap; | ||
use CyberSpectrum\I18N\ContaoBundle\FormType\InspectMappingFormType; | ||
use Psr\Log\LoggerAwareInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\Debug\BufferingLogger; | ||
use Symfony\Component\ErrorHandler\BufferingLogger; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Security\Csrf\CsrfTokenManager; | ||
use Symfony\Component\Templating\EngineInterface; | ||
|
||
use function in_array; | ||
use function strtr; | ||
|
||
/** | ||
* This allows to inspect dictionary problems in the Contao backend. | ||
*/ | ||
class ContaoInspectProblemsController extends AbstractController | ||
{ | ||
/** | ||
* The twig engine. | ||
* | ||
* @var EngineInterface | ||
*/ | ||
private $templating; | ||
/** The twig engine. */ | ||
private EngineInterface $templating; | ||
|
||
/** | ||
* The Contao map builder. | ||
* | ||
* @var MapBuilderInterface | ||
*/ | ||
private $mapBuilder; | ||
/** The Contao map builder. */ | ||
private MapBuilderInterface $mapBuilder; | ||
|
||
/** | ||
* The CSRF token manager. | ||
* | ||
* @var CsrfTokenManager | ||
*/ | ||
private $csrfTokenManager; | ||
/** The CSRF token manager. */ | ||
private CsrfTokenManager $csrfTokenManager; | ||
|
||
/** | ||
* The CSRF token name. | ||
* | ||
* @var string | ||
*/ | ||
private $csrfTokenName; | ||
/** The CSRF token name. */ | ||
private string $csrfTokenName; | ||
|
||
/** | ||
* Create a new instance. | ||
|
@@ -93,7 +64,7 @@ public function __construct( | |
*/ | ||
public function __invoke(Request $request): Response | ||
{ | ||
switch ($request->get('act')) { | ||
switch ($request->query->get('act')) { | ||
case 'inspect-map': | ||
return $this->inspectMap($request); | ||
default: | ||
|
@@ -106,25 +77,29 @@ public function __invoke(Request $request): Response | |
* Inspect Terminal42 mappings. | ||
* | ||
* @param Request $request The request. | ||
* | ||
* @return Response | ||
*/ | ||
private function inspectMap(Request $request): Response | ||
{ | ||
if (empty($map = $request->get('map'))) { | ||
if (empty($map = $request->query->get('map'))) { | ||
$map = 'tl_page'; | ||
} | ||
assert(is_string($map)); | ||
|
||
$form = $this->createForm(InspectMappingFormType::class); | ||
$form->handleRequest($request); | ||
|
||
$logger = new BufferingLogger(); | ||
/** @var array{source: string, target: string} $data */ | ||
$data = $form->getData(); | ||
$logger = new BufferingLogger(); | ||
$errors = []; | ||
if ($form->isSubmitted() && $form->isValid()) { | ||
$this->mapBuilder->setLogger($logger); | ||
if ($this->mapBuilder instanceof LoggerAwareInterface) { | ||
$this->mapBuilder->setLogger($logger); | ||
} | ||
$this->mapBuilder->getMappingFor($map, $data['source'], $data['target']); | ||
foreach ($logger->cleanLogs() as $message) { | ||
/** @var list<array{0: string, 1: string, 2: array<string, string>}> $logs */ | ||
$logs = $logger->cleanLogs(); | ||
foreach ($logs as $message) { | ||
if ([] !== ($converted = $this->convertMessage($message))) { | ||
$errors[] = $converted; | ||
} | ||
|
@@ -143,7 +118,7 @@ private function inspectMap(Request $request): Response | |
/** | ||
* Convert an error message to the correct error array. | ||
* | ||
* @param array $message The error message to convert. | ||
* @param array{0: string, 1: string, 2: array<string, string>} $message The error message to convert. | ||
* | ||
* @return array | ||
* | ||
|
@@ -153,7 +128,7 @@ private function inspectMap(Request $request): Response | |
private function convertMessage(array $message): array | ||
{ | ||
[$level, $text, $context] = $message; | ||
if (!\in_array($level, ['warning', 'error'])) { | ||
if (!in_array($level, ['warning', 'error'])) { | ||
return []; | ||
} | ||
|
||
|
@@ -281,10 +256,8 @@ private function link(array $params): array | |
/** | ||
* Transform the message by replacing the context parameters. | ||
* | ||
* @param string $message The message template. | ||
* @param array $context The context parameters. | ||
* | ||
* @return string | ||
* @param string $message The message template. | ||
* @param array<string, string> $context The context parameters. | ||
*/ | ||
private function transformMessage(string $message, array $context): string | ||
{ | ||
|
Oops, something went wrong.