Skip to content

Commit

Permalink
feat: Added NodesSourcesHeadFactoryInterface for better WebResponse a…
Browse files Browse the repository at this point in the history
…nd CommonContent responses maintainability.
  • Loading branch information
ambroisemaupate committed Mar 13, 2023
1 parent 50a04af commit ed05a24
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
use RZ\Roadiz\Core\AbstractEntities\TranslationInterface;
use RZ\Roadiz\CoreBundle\Api\Breadcrumbs\BreadcrumbsFactoryInterface;
use RZ\Roadiz\CoreBundle\Api\Model\NodesSourcesHeadFactory;
use RZ\Roadiz\CoreBundle\Api\Model\NodesSourcesHeadFactoryInterface;
use RZ\Roadiz\CoreBundle\Api\Model\WebResponse;
use RZ\Roadiz\CoreBundle\Api\Model\WebResponseInterface;
use RZ\Roadiz\CoreBundle\Api\TreeWalker\AutoChildrenNodeSourceWalker;
Expand All @@ -23,15 +23,15 @@ final class WebResponseOutputDataTransformer implements WebResponseDataTransform
use BlocksAwareWebResponseOutputDataTransformerTrait;
use RealmsAwareWebResponseOutputDataTransformerTrait;

private NodesSourcesHeadFactory $nodesSourcesHeadFactory;
private NodesSourcesHeadFactoryInterface $nodesSourcesHeadFactory;
private BreadcrumbsFactoryInterface $breadcrumbsFactory;
private WalkerContextInterface $walkerContext;
private CacheItemPoolInterface $cacheItemPool;
private UrlGeneratorInterface $urlGenerator;
private RealmResolverInterface $realmResolver;

public function __construct(
NodesSourcesHeadFactory $nodesSourcesHeadFactory,
NodesSourcesHeadFactoryInterface $nodesSourcesHeadFactory,
BreadcrumbsFactoryInterface $breadcrumbsFactory,
WalkerContextInterface $walkerContext,
CacheItemPoolInterface $cacheItemPool,
Expand Down
9 changes: 9 additions & 0 deletions lib/RoadizCoreBundle/src/Api/Model/NodesSourcesHead.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ public function getGoogleTagManager(): ?string
return $this->settingsBag->get('google_tag_manager_id', null) ?? null;
}

/**
* @return string|null
*/
#[Serializer\Groups(["web_response", "nodes_sources_single", "walker"])]
public function getMatomoTagManager(): ?string
{
return $this->settingsBag->get('matomo_tag_manager_id', null) ?? null;
}

/**
* @return string|null
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use RZ\Roadiz\CoreBundle\EntityApi\NodeSourceApi;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

final class NodesSourcesHeadFactory
final class NodesSourcesHeadFactory implements NodesSourcesHeadFactoryInterface
{
private Settings $settingsBag;
private UrlGeneratorInterface $urlGenerator;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\CoreBundle\Api\Model;

use RZ\Roadiz\Core\AbstractEntities\TranslationInterface;
use RZ\Roadiz\CoreBundle\Entity\NodesSources;

interface NodesSourcesHeadFactoryInterface
{
public function createForTranslation(TranslationInterface $translation): NodesSourcesHeadInterface;
public function createForNodeSource(NodesSources $nodesSources): NodesSourcesHeadInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function getMetaTitle(): ?string;
public function getMetaDescription(): ?string;
public function getPolicyUrl(): ?string;
public function getHomePageUrl(): ?string;
public function isNoIndex(): bool;
public function getHomePage(): ?NodesSources;
public function getShareImage(): ?DocumentInterface;
public function getTranslation(): TranslationInterface;
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/GetCommonContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\TreeWalker\MenuNodeSourceWalker;
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\Core\AbstractEntities\TranslationInterface;
use RZ\Roadiz\CoreBundle\Api\Model\NodesSourcesHeadFactory;
use RZ\Roadiz\CoreBundle\Api\Model\NodesSourcesHeadFactoryInterface;
use RZ\Roadiz\CoreBundle\Api\TreeWalker\TreeWalkerGenerator;
use RZ\Roadiz\CoreBundle\Preview\PreviewResolverInterface;
use RZ\Roadiz\CoreBundle\Repository\TranslationRepository;
Expand All @@ -22,14 +22,14 @@ final class GetCommonContentController extends AbstractController
{
private RequestStack $requestStack;
private ManagerRegistry $managerRegistry;
private NodesSourcesHeadFactory $nodesSourcesHeadFactory;
private NodesSourcesHeadFactoryInterface $nodesSourcesHeadFactory;
private PreviewResolverInterface $previewResolver;
private TreeWalkerGenerator $treeWalkerGenerator;

public function __construct(
RequestStack $requestStack,
ManagerRegistry $managerRegistry,
NodesSourcesHeadFactory $nodesSourcesHeadFactory,
NodesSourcesHeadFactoryInterface $nodesSourcesHeadFactory,
PreviewResolverInterface $previewResolver,
TreeWalkerGenerator $treeWalkerGenerator
) {
Expand Down

0 comments on commit ed05a24

Please sign in to comment.