Skip to content

Commit bc85183

Browse files
committed
OXDEV-9909: Add a new SeoEncoderArticle model extension including factory
1 parent f1c42c6 commit bc85183

11 files changed

Lines changed: 191 additions & 0 deletions

File tree

CHANGELOG-v13.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Minimum PHP version is now 8.3, tested up to PHP 8.5
1212
- Upgraded PHPUnit from 11 to 12
1313

14+
### Added
15+
- `SeoEncoderArticle` with `oeGetCategoryUri` and `oeIsFixed` method, including `SeoEncoderArticleFactory`
16+
1417
### Fixed
1518
- Graphqlite is incompatible with webonyx/graphql-php v15.31
1619

metadata.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
/**
1111
* Metadata version
1212
*/
13+
14+
use OxidEsales\GraphQL\Base\Seo\Infrastructure\Model\SeoEncoderArticle;
15+
1316
$sMetadataVersion = '2.0';
1417

1518
/**
@@ -31,6 +34,7 @@
3134
'url' => 'www.oxid-esales.com',
3235
'email' => 'info@oxid-esales.com',
3336
'extend' => [
37+
\OxidEsales\Eshop\Application\Model\SeoEncoderArticle::class => SeoEncoderArticle::class,
3438
],
3539
'controllers' => [
3640
// Widget Controller

services.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
imports:
22
- { resource: src/Infrastructure/services.yaml }
3+
- { resource: src/Seo/services.yaml }
34

45
services:
56

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace OxidEsales\GraphQL\Base\Seo\Infrastructure\Factory;
11+
12+
use OxidEsales\Eshop\Application\Model\SeoEncoderArticle;
13+
14+
class SeoEncoderArticleFactory implements SeoEncoderArticleFactoryInterface
15+
{
16+
public function create(): SeoEncoderArticle
17+
{
18+
return oxNew(SeoEncoderArticle::class);
19+
}
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
namespace OxidEsales\GraphQL\Base\Seo\Infrastructure\Factory;
9+
10+
use OxidEsales\Eshop\Application\Model\SeoEncoderArticle;
11+
12+
interface SeoEncoderArticleFactoryInterface
13+
{
14+
public function create(): SeoEncoderArticle;
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
public: false
5+
6+
OxidEsales\GraphQL\Base\Seo\Infrastructure\Factory\SeoEncoderArticleFactoryInterface:
7+
class: OxidEsales\GraphQL\Base\Seo\Infrastructure\Factory\SeoEncoderArticleFactory
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace OxidEsales\GraphQL\Base\Seo\Infrastructure\Model;
11+
12+
use OxidEsales\Eshop\Application\Model\Article;
13+
use OxidEsales\Eshop\Application\Model\Category;
14+
15+
/*
16+
* This class is used to create proxy-methods for needed protected methods.
17+
* This class will be removed as far as the used methods are public.
18+
* Please avoid using this class in your code if possible!
19+
*/
20+
21+
class SeoEncoderArticle extends SeoEncoderArticle_parent
22+
{
23+
public function oeGetCategoryUri(Article $article, Category $category, int $languageId): string
24+
{
25+
/** @phpstan-ignore method.notFound */
26+
return $this->createArticleCategoryUri($article, $category, $languageId);
27+
}
28+
29+
public function oeIsFixed(string $objectId, int $languageId, ?string $params = null): bool
30+
{
31+
/** @phpstan-ignore method.notFound */
32+
return $this->isFixed('oxarticle', $objectId, $languageId, null, $params);
33+
}
34+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
imports:
2+
- { resource: Factory/services.yaml }

src/Seo/services.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
imports:
2+
- { resource: Infrastructure/services.yaml }
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* Copyright © OXID eSales AG. All rights reserved.
5+
* See LICENSE file for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace OxidEsales\GraphQL\Base\Tests\Integration\Seo\Infrastructure\Factory;
11+
12+
use OxidEsales\Eshop\Application\Model\SeoEncoderArticle;
13+
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
14+
use OxidEsales\GraphQL\Base\Seo\Infrastructure\Factory\SeoEncoderArticleFactory;
15+
use OxidEsales\GraphQL\Base\Seo\Infrastructure\Model\SeoEncoderArticle as ExtendedSeoEncoderArticle;
16+
use PHPUnit\Framework\Attributes\CoversClass;
17+
use PHPUnit\Framework\Attributes\Test;
18+
19+
#[CoversClass(SeoEncoderArticleFactory::class)]
20+
final class SeoEncoderArticleFactoryTest extends IntegrationTestCase
21+
{
22+
#[Test]
23+
public function createReturnsSeoEncoderArticle(): void
24+
{
25+
$sut = new SeoEncoderArticleFactory();
26+
27+
$this->assertInstanceOf(SeoEncoderArticle::class, $sut->create());
28+
}
29+
30+
#[Test]
31+
public function oxNewResolvesToOurSeoEncoderArticle(): void
32+
{
33+
$result = oxNew(SeoEncoderArticle::class);
34+
35+
$this->assertInstanceOf(ExtendedSeoEncoderArticle::class, $result);
36+
}
37+
}

0 commit comments

Comments
 (0)