Skip to content

Commit

Permalink
fix: make shopware 6.6 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 22, 2024
1 parent ebaad69 commit ee9ca62
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"Frosh\\RobotsTxt\\": "src/"
}
},
"require": {
"shopware/core": "~6.5.0 || ~6.6.0"
},
"extra": {
"shopware-plugin-class": "Frosh\\RobotsTxt\\FroshRobotsTxt",
"label": {
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/RobotsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Shopware\Storefront\Controller\StorefrontController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

#[Route(defaults: ['_routeScope' => ['storefront']])]

Check failure on line 12 in src/Controller/RobotsController.php

View workflow job for this annotation

GitHub Actions / lint

Attribute class Symfony\Component\Routing\Attribute\Route does not exist.

Check failure on line 12 in src/Controller/RobotsController.php

View workflow job for this annotation

GitHub Actions / lint

Attribute class Symfony\Component\Routing\Attribute\Route does not exist.
class RobotsController extends StorefrontController
Expand All @@ -16,7 +16,7 @@ public function __construct(private readonly RobotsPageLoader $robotsPageLoader)
{
}

#[Route(path: '/robots.txt', name: 'frontend.robots.txt', methods: ['GET'], defaults: ['_format' => 'txt'])]
#[Route(path: '/robots.txt', name: 'frontend.robots.txt', defaults: ['_format' => 'txt'], methods: ['GET'])]

Check failure on line 19 in src/Controller/RobotsController.php

View workflow job for this annotation

GitHub Actions / lint

Attribute class Symfony\Component\Routing\Attribute\Route does not exist.

Check failure on line 19 in src/Controller/RobotsController.php

View workflow job for this annotation

GitHub Actions / lint

Attribute class Symfony\Component\Routing\Attribute\Route does not exist.
public function robotsTxt(SalesChannelContext $context, Request $request): Response
{
$page = $this->robotsPageLoader->load($request, $context);
Expand Down
7 changes: 5 additions & 2 deletions src/Page/Robots/RobotsPageLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@

class RobotsPageLoader
{
/**
* @param EntityRepository<SalesChannelDomainCollection> $salesChannelDomainRepository
*/
public function __construct(

Check failure on line 23 in src/Page/Robots/RobotsPageLoader.php

View workflow job for this annotation

GitHub Actions / lint

PHPDoc tag @param for parameter $salesChannelDomainRepository contains generic type Shopware\Core\Framework\DataAbstractionLayer\EntityRepository<Shopware\Core\System\SalesChannel\Aggregate\SalesChannelDomain\SalesChannelDomainCollection> but class Shopware\Core\Framework\DataAbstractionLayer\EntityRepository is not generic.

Check failure on line 23 in src/Page/Robots/RobotsPageLoader.php

View workflow job for this annotation

GitHub Actions / lint

PHPDoc tag @param for parameter $salesChannelDomainRepository contains generic type Shopware\Core\Framework\DataAbstractionLayer\EntityRepository<Shopware\Core\System\SalesChannel\Aggregate\SalesChannelDomain\SalesChannelDomainCollection> but class Shopware\Core\Framework\DataAbstractionLayer\EntityRepository is not generic.
private readonly EventDispatcherInterface $eventDispatcher,
private readonly EntityRepository $domainRepository,
private readonly EntityRepository $salesChannelDomainRepository,

Check failure on line 25 in src/Page/Robots/RobotsPageLoader.php

View workflow job for this annotation

GitHub Actions / lint

PHPDoc type for property Frosh\RobotsTxt\Page\Robots\RobotsPageLoader::$salesChannelDomainRepository contains generic type Shopware\Core\Framework\DataAbstractionLayer\EntityRepository<Shopware\Core\System\SalesChannel\Aggregate\SalesChannelDomain\SalesChannelDomainCollection> but class Shopware\Core\Framework\DataAbstractionLayer\EntityRepository is not generic.

Check failure on line 25 in src/Page/Robots/RobotsPageLoader.php

View workflow job for this annotation

GitHub Actions / lint

PHPDoc type for property Frosh\RobotsTxt\Page\Robots\RobotsPageLoader::$salesChannelDomainRepository contains generic type Shopware\Core\Framework\DataAbstractionLayer\EntityRepository<Shopware\Core\System\SalesChannel\Aggregate\SalesChannelDomain\SalesChannelDomainCollection> but class Shopware\Core\Framework\DataAbstractionLayer\EntityRepository is not generic.
private readonly SystemConfigService $systemConfigService
) {
}
Expand Down Expand Up @@ -55,7 +58,7 @@ private function getDomains(string $hostname, Context $context): SalesChannelDom
$criteria = new Criteria();
$criteria->addFilter(new ContainsFilter('url', $hostname));

$domains = $this->domainRepository->search($criteria, $context)->getEntities();
$domains = $this->salesChannelDomainRepository->search($criteria, $context)->getEntities();
assert($domains instanceof SalesChannelDomainCollection);

return $domains;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://symfony.com/schema/routing/routing-1.0.xsd">
<import resource="../../Controller/**/*.php" type="annotation"/>
<import resource="../../Controller/**/*.php" type="attribute"/>
</routes>
25 changes: 3 additions & 22 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,9 @@
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<!-- Core\Content\Framework\Adapter\Twig\Extension -->
<service id="Frosh\RobotsTxt\Core\Framework\Adapter\Twig\Extension\LeadingSpacesFilterExtension" >
<tag name="twig.extension"/>
</service>

<!-- PageLoader -->
<service id="Frosh\RobotsTxt\Page\Robots\RobotsPageLoader">
<argument type="service" id="event_dispatcher"/>
<argument type="service" id="sales_channel_domain.repository"/>
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
</service>

<!-- Controller -->
<service id="Frosh\RobotsTxt\Controller\RobotsController" public="true">
<argument type="service" id="Frosh\RobotsTxt\Page\Robots\RobotsPageLoader"/>
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
<call method="setTwig">
<argument type="service" id="twig"/>
</call>
</service>
<services>
<defaults autowire="true" autoconfigure="true" />
<prototype namespace="Frosh\RobotsTxt\" resource="../../" exclude="../../{Resources,FroshRobotsTxt.php}" />
</services>
</container>

0 comments on commit ee9ca62

Please sign in to comment.