Skip to content

Commit

Permalink
Update Example and ExampleDimensionContent Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Mar 16, 2023
1 parent a6619fc commit 36b8fb8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 13 deletions.
14 changes: 12 additions & 2 deletions Content/Domain/Model/ContentRichEntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
* @template T of DimensionContentInterface
*/
trait ContentRichEntityTrait
{
/**
* @var ArrayCollection<int, DimensionContentInterface>
* @var ArrayCollection<int, T>
*/
protected $dimensionContents;

/**
* @return Collection<int, DimensionContentInterface>
* @return Collection<int, T>
*/
public function getDimensionContents(): Collection
{
Expand All @@ -33,13 +36,20 @@ public function getDimensionContents(): Collection
return $this->dimensionContents;
}

/**
* @param T $dimensionContent
*/
public function addDimensionContent(DimensionContentInterface $dimensionContent): void
{
$this->initializeDimensionContents();

$this->dimensionContents->add($dimensionContent);
}


/**
* @param T $dimensionContent
*/
public function removeDimensionContent(DimensionContentInterface $dimensionContent): void
{
$this->initializeDimensionContents();
Expand Down
2 changes: 1 addition & 1 deletion Content/Domain/Model/DimensionContentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getStage(): string;
public function setStage(string $stage): void;

/**
* @return T<static>
* @return T
*/
public function getResource(): ContentRichEntityInterface;

Expand Down
5 changes: 4 additions & 1 deletion Tests/Application/ExampleTestBundle/Entity/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;

/**
* @implements ContentRichEntityInterface<ExampleDimensionContent<static>>
* @implements ContentRichEntityInterface<ExampleDimensionContent>
*/
class Example implements ContentRichEntityInterface
{
/**
* @phpstan-use ContentRichEntityTrait<ExampleDimensionContent>
*/
use ContentRichEntityTrait;

public const RESOURCE_KEY = 'examples';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Model\WorkflowTrait;

/**
* @implements DimensionContentInterface<Example<static>>
* @implements DimensionContentInterface<Example>
*/
class ExampleDimensionContent implements DimensionContentInterface, ExcerptInterface, SeoInterface, TemplateInterface, RoutableInterface, WorkflowInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;
use Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Teaser\ContentTeaserProvider;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\ExampleDimensionContent;
use Sulu\Bundle\PageBundle\Teaser\Configuration\TeaserConfiguration;
use Sulu\Component\Content\Metadata\Factory\StructureMetadataFactoryInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @extends ContentTeaserProvider<ExampleDimensionContent, Example>
*/
class ExampleTeaserProvider extends ContentTeaserProvider
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;
use Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Search\ContentReindexProvider;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\ExampleDimensionContent;
use Sulu\Bundle\ContentBundle\Tests\Traits\CreateExampleTrait;
use Sulu\Bundle\TestBundle\Testing\SuluTestCase;
Expand All @@ -26,17 +27,17 @@ class ContentReindexProviderTest extends SuluTestCase
use CreateExampleTrait;

/**
* @var ContentReindexProvider
* @var ContentReindexProvider<ExampleDimensionContent, Example>
*/
private $reindexProvider;

/**
* @var ContentRichEntityInterface
* @var Example
*/
private static $example1;

/**
* @var ContentRichEntityInterface
* @var Example
*/
private static $example2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
use Massive\Bundle\SearchBundle\Search\Metadata\ClassMetadata;
use Massive\Bundle\SearchBundle\Search\ObjectToDocumentConverter;
use Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManagerInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;
use Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Search\ContentSearchMetadataProvider;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\ExampleDimensionContent;
use Sulu\Bundle\ContentBundle\Tests\Traits\CreateExampleTrait;
use Sulu\Bundle\TestBundle\Testing\SuluTestCase;

Expand All @@ -37,12 +38,12 @@ class ContentSearchMetadataProviderTest extends SuluTestCase
private $objectToDocumentConverter;

/**
* @var ContentSearchMetadataProvider
* @var ContentSearchMetadataProvider<ExampleDimensionContent, Example>
*/
private $searchMetadataProvider;

/**
* @var ContentRichEntityInterface
* @var Example
*/
private static $example1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace Sulu\Bundle\ContentBundle\Tests\Functional\Content\Infrastructure\Sulu\Sitemap;

use Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Sitemap\ContentSitemapProvider;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\ExampleDimensionContent;
use Sulu\Bundle\ContentBundle\Tests\Traits\AssertSnapshotTrait;
use Sulu\Bundle\ContentBundle\Tests\Traits\CreateExampleTrait;
use Sulu\Bundle\TestBundle\Testing\SuluTestCase;
Expand All @@ -30,7 +32,7 @@ class ContentSitemapProviderTest extends SuluTestCase
public const HOST = 'localhost';

/**
* @var ContentSitemapProvider
* @var ContentSitemapProvider<ExampleDimensionContent, Example>
*/
private $contentSitemapProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testResolveSimple(): void
use DimensionContentTrait;

/**
* @var ContentRichEntityInterface
* @var ContentRichEntityInterface<DimensionContentInterface>
*/
protected $resource;

Expand Down

0 comments on commit 36b8fb8

Please sign in to comment.