Skip to content

Commit

Permalink
[CS] Refactor (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: DACHCOM Bot <[email protected]>
  • Loading branch information
github-actions[bot] and DACHCOM Bot authored Jan 6, 2025
1 parent 6337d2e commit ccf273f
Show file tree
Hide file tree
Showing 33 changed files with 433 additions and 67 deletions.
13 changes: 12 additions & 1 deletion src/NewsBundle/Configuration/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\Configuration;

class Configuration
Expand Down Expand Up @@ -28,4 +39,4 @@ public function getConfig(string $slot): mixed
{
return $this->config[$slot];
}
}
}
11 changes: 11 additions & 0 deletions src/NewsBundle/Controller/Admin/SettingsController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\Controller\Admin;

use NewsBundle\Manager\EntryTypeManager;
Expand Down
11 changes: 11 additions & 0 deletions src/NewsBundle/Controller/EntryController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\Controller;

use Pimcore\Controller\FrontendController;
Expand Down
11 changes: 11 additions & 0 deletions src/NewsBundle/CoreExtension/EntryTypeSelect.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\CoreExtension;

use Pimcore\Model\DataObject\ClassDefinition\Data\Select;
Expand Down
13 changes: 12 additions & 1 deletion src/NewsBundle/DependencyInjection/CompilerPass/PresetPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\DependencyInjection\CompilerPass;

use NewsBundle\Registry\PresetRegistry;
Expand All @@ -18,4 +29,4 @@ public function process(ContainerBuilder $container): void
}
}
}
}
}
11 changes: 11 additions & 0 deletions src/NewsBundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\DependencyInjection;

use NewsBundle\Generator\HeadMetaGenerator;
Expand Down
19 changes: 15 additions & 4 deletions src/NewsBundle/DependencyInjection/NewsExtension.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\DependencyInjection;

use NewsBundle\Configuration\Configuration as BundleConfiguration;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use NewsBundle\Configuration\Configuration as BundleConfiguration;

class NewsExtension extends Extension
{
Expand All @@ -26,4 +37,4 @@ public function load(array $configs, ContainerBuilder $container): void
$configManagerDefinition = $container->getDefinition(BundleConfiguration::class);
$configManagerDefinition->addMethodCall('setConfig', [$config]);
}
}
}
29 changes: 19 additions & 10 deletions src/NewsBundle/Document/Areabrick/News/News.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\Document\Areabrick\News;

use NewsBundle\Configuration\Configuration;
use NewsBundle\Event\NewsBrickEvent;
use NewsBundle\Manager\EntryTypeManager;
use NewsBundle\NewsEvents;
use NewsBundle\Registry\PresetRegistry;
use Pimcore\Extension\Document\Areabrick\AbstractAreabrick;
use Pimcore\Extension\Document\Areabrick\EditableDialogBoxConfiguration;
use Pimcore\Extension\Document\Areabrick\EditableDialogBoxInterface;
use Pimcore\Model\DataObject;
use Pimcore\Model\Document;
use Pimcore\Translation\Translator;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\HttpFoundation\Response;
use NewsBundle\Configuration\Configuration;
use NewsBundle\Manager\EntryTypeManager;
use Pimcore\Model\DataObject;
use Pimcore\Model\Document;

class News extends AbstractAreabrick implements EditableDialogBoxInterface
{
Expand Down Expand Up @@ -139,7 +150,6 @@ public function getEditableDialogBoxConfiguration(Document\Editable $area, ?Docu
'config' => $fieldConfiguration['single_objects']['relations_config']
];


$secondTabItems[] = [
'type' => 'numeric',
'label' => $this->translator->trans('news.entries_per_page', [], 'admin'),
Expand Down Expand Up @@ -226,7 +236,7 @@ public function action(Document\Editable\Area\Info $info): ?Response
$presetParams = [];

//check if preset has been selected at first
if($this->isPresetMode($fieldConfiguration)) {
if ($this->isPresetMode($fieldConfiguration)) {
$isPresetMode = true;
$preset = $this->presetRegistry->get($fieldConfiguration['presets']['value']);
$preset->setInfo($info);
Expand Down Expand Up @@ -278,9 +288,9 @@ public function action(Document\Editable\Area\Info $info): ?Response

if ($fieldConfiguration['entry_types']['value'] !== 'all') {
$mainClasses[] = 'entry-type-' . str_replace([
'_',
' '
], ['-'], strtolower($fieldConfiguration['entry_types']['value']));
'_',
' '
], ['-'], strtolower($fieldConfiguration['entry_types']['value']));
}

$event = new NewsBrickEvent($info, $querySettings);
Expand Down Expand Up @@ -580,5 +590,4 @@ public function getHtmlTagClose(Document\Editable\Area\Info $info): string
{
return '';
}

}
11 changes: 11 additions & 0 deletions src/NewsBundle/Event/NewsBrickEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\Event;

use Pimcore\Model\Document\Editable\Area\Info;
Expand Down
19 changes: 17 additions & 2 deletions src/NewsBundle/EventListener/EntryTypeListener.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\EventListener;

use NewsBundle\Configuration\Configuration;
use NewsBundle\Manager\EntryTypeManager;
use Pimcore\Bundle\AdminBundle\Event\AdminEvents;
use Pimcore\Tool\Admin as AdminTool;
use Pimcore\Model\DataObject\ClassDefinition\CustomLayout;
use Pimcore\Model\DataObject\NewsEntry;
use Pimcore\Model\DataObject\Service;
use Pimcore\Tool\Admin as AdminTool;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -56,6 +67,7 @@ public function setEntryTypeLayout(GenericEvent $e): void
$requestedLayoutId !== '0'
) {
$e->setArgument('data', $data);

return;
}

Expand All @@ -76,13 +88,13 @@ public function setEntryTypeLayout(GenericEvent $e): void
$data['currentLayoutId'] = 0;
$data['layout'] = $object->getClass()->getLayoutDefinitions();
$e->setArgument('data', $data);

return;
}

//watch out, a new object is coming in!
if (is_null($layoutType)) {
$layoutType = $defaultLayoutType;

}

foreach ($entryTypes as $typeName => $type) {
Expand All @@ -92,6 +104,7 @@ public function setEntryTypeLayout(GenericEvent $e): void

if ($layoutType === $typeName) {
$layoutId = $type['custom_layout_id'];

break;
}
}
Expand All @@ -104,12 +117,14 @@ public function setEntryTypeLayout(GenericEvent $e): void
$data['layout'] = null;
$data['currentLayoutId'] = null;
$e->setArgument('data', $data);

return;
}
}

if ($layoutId !== 0) {
$customLayout = null;

try {
$customLayout = CustomLayout::getById($layoutId);
} catch (\Exception $e) {
Expand Down
16 changes: 15 additions & 1 deletion src/NewsBundle/EventListener/MetaDataListener.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace NewsBundle\EventListener;

use NewsBundle\Generator\HeadMetaGeneratorInterface;
use NewsBundle\Model\EntryInterface;
use Pimcore\Model\DataObject\NewsEntry;
use Pimcore\Twig\Extension\Templating\HeadMeta;
use Pimcore\Twig\Extension\Templating\HeadTitle;
use Pimcore\Twig\Extension\Templating\Placeholder\Container;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Pimcore\Twig\Extension\Templating\Placeholder\Container;

class MetaDataListener implements EventSubscriberInterface
{
Expand Down Expand Up @@ -73,13 +84,16 @@ public function onKernelRequest(RequestEvent $event): void
switch ($this->headMetaGenerator->getTitlePosition()) {
case Container::SET:
$this->headTitle->set($title);

break;
case Container::PREPEND:
$this->headTitle->prepend($title);

break;
case Container::APPEND:
default:
$this->headTitle->append($title);

break;
}
}
Expand Down
Loading

0 comments on commit ccf273f

Please sign in to comment.