Skip to content

Commit

Permalink
Rename ContentInterface to ContentRichEntityInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Dec 13, 2019
1 parent 8ac7361 commit f0f66a0
Show file tree
Hide file tree
Showing 31 changed files with 215 additions and 236 deletions.
18 changes: 9 additions & 9 deletions Content/Application/ContentCopier/ContentCopier.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\ApiViewResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\ViewFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentDimensionCollectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;

class ContentCopier implements ContentCopierInterface
Expand Down Expand Up @@ -56,33 +56,33 @@ public function __construct(
}

public function copy(
ContentInterface $sourceContent,
ContentRichEntityInterface $sourceContentRichEntity,
array $sourceDimensionAttributes,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichEntity,
array $targetDimensionAttributes
): ContentViewInterface {
$sourceContentView = $this->contentLoader->load($sourceContent, $sourceDimensionAttributes);
$sourceContentView = $this->contentLoader->load($sourceContentRichEntity, $sourceDimensionAttributes);

return $this->copyFromContentView($sourceContentView, $targetContent, $targetDimensionAttributes);
return $this->copyFromContentView($sourceContentView, $targetContentRichEntity, $targetDimensionAttributes);
}

public function copyFromContentDimensionCollection(
ContentDimensionCollectionInterface $contentDimensionCollection,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichEntity,
array $targetDimensionAttributes
): ContentViewInterface {
$sourceContentView = $this->viewFactory->create($contentDimensionCollection);

return $this->copyFromContentView($sourceContentView, $targetContent, $targetDimensionAttributes);
return $this->copyFromContentView($sourceContentView, $targetContentRichEntity, $targetDimensionAttributes);
}

public function copyFromContentView(
ContentViewInterface $sourceContentView,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichENtity,
array $targetDimensionAttributes
): ContentViewInterface {
$data = $this->contentResolver->resolve($sourceContentView);

return $this->contentPersister->persist($targetContent, $data, $targetDimensionAttributes);
return $this->contentPersister->persist($targetContentRichENtity, $data, $targetDimensionAttributes);
}
}
10 changes: 5 additions & 5 deletions Content/Application/ContentCopier/ContentCopierInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentCopier;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentDimensionCollectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;

interface ContentCopierInterface
Expand All @@ -24,9 +24,9 @@ interface ContentCopierInterface
* @param mixed[] $targetDimensionAttributes
*/
public function copy(
ContentInterface $sourceContent,
ContentRichEntityInterface $sourceContentRichEntity,
array $sourceDimensionAttributes,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichEntity,
array $targetDimensionAttributes
): ContentViewInterface;

Expand All @@ -35,7 +35,7 @@ public function copy(
*/
public function copyFromContentDimensionCollection(
ContentDimensionCollectionInterface $contentDimensionCollection,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichEntity,
array $targetDimensionAttributes
): ContentViewInterface;

Expand All @@ -44,7 +44,7 @@ public function copyFromContentDimensionCollection(
*/
public function copyFromContentView(
ContentViewInterface $sourceContentView,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichENtity,
array $targetDimensionAttributes
): ContentViewInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentDimensionCollection;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentDimensionCollectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentDimensionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionCollectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Repository\ContentDimensionRepositoryInterface;
Expand All @@ -47,11 +47,11 @@ public function __construct(ContentDimensionRepositoryInterface $contentDimensio
}

public function create(
ContentInterface $content,
ContentRichEntityInterface $contentRichEntity,
DimensionCollectionInterface $dimensionCollection,
array $data
): ContentDimensionCollectionInterface {
$contentDimensionCollection = $this->contentDimensionRepository->load($content, $dimensionCollection);
$contentDimensionCollection = $this->contentDimensionRepository->load($contentRichEntity, $dimensionCollection);

$localizedDimension = $dimensionCollection->getLocalizedDimension();
$unlocalizedDimension = $dimensionCollection->getUnlocalizedDimension();
Expand All @@ -63,15 +63,15 @@ public function create(
}

$unlocalizedContentDimension = $this->getOrCreateContentDimension(
$content,
$contentRichEntity,
$contentDimensions,
$unlocalizedDimension
);

$localizedContentDimension = null;
if ($localizedDimension) {
$localizedContentDimension = $this->getOrCreateContentDimension(
$content,
$contentRichEntity,
$contentDimensions,
$localizedDimension
);
Expand All @@ -97,7 +97,7 @@ public function create(
}

private function getOrCreateContentDimension(
ContentInterface $content,
ContentRichEntityInterface $contentRichEntity,
Collection $contentDimensions,
DimensionInterface $dimension
): ContentDimensionInterface {
Expand All @@ -106,8 +106,8 @@ private function getOrCreateContentDimension(
})->first();

if (!$contentDimension) {
$contentDimension = $content->createDimension($dimension);
$content->addDimension($contentDimension);
$contentDimension = $contentRichEntity->createDimension($dimension);
$contentRichEntity->addDimension($contentDimension);
$contentDimensions->add($contentDimension);
}

Expand Down
22 changes: 11 additions & 11 deletions Content/Application/ContentFacade/ContentFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentWorkflow\ContentWorkflowInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\ApiViewResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;

class ContentFacade implements ContentFacadeInterface
Expand Down Expand Up @@ -62,14 +62,14 @@ public function __construct(
$this->contentWorkflow = $contentWorkflow;
}

public function load(ContentInterface $content, array $dimensionAttributes): ContentViewInterface
public function load(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): ContentViewInterface
{
return $this->contentLoader->load($content, $dimensionAttributes);
return $this->contentLoader->load($contentRichEntity, $dimensionAttributes);
}

public function persist(ContentInterface $content, array $data, array $dimensionAttributes): ContentViewInterface
public function persist(ContentRichEntityInterface $contentRichEntity, array $data, array $dimensionAttributes): ContentViewInterface
{
return $this->contentPersister->persist($content, $data, $dimensionAttributes);
return $this->contentPersister->persist($contentRichEntity, $data, $dimensionAttributes);
}

public function resolve(ContentViewInterface $contentView): array
Expand All @@ -78,24 +78,24 @@ public function resolve(ContentViewInterface $contentView): array
}

public function copy(
ContentInterface $sourceContent,
ContentRichEntityInterface $sourceContentRichEntity,
array $sourceDimensionAttributes,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichEntity,
array $targetDimensionAttributes
): ContentViewInterface {
return $this->contentCopier->copy(
$sourceContent,
$sourceContentRichEntity,
$sourceDimensionAttributes,
$targetContent,
$targetContentRichEntity,
$targetDimensionAttributes
);
}

public function applyTransition(
ContentInterface $content,
ContentRichEntityInterface $contentRichEntity,
array $dimensionAttributes,
string $transitionName
): ContentViewInterface {
return $this->contentWorkflow->apply($content, $dimensionAttributes, $transitionName);
return $this->contentWorkflow->apply($contentRichEntity, $dimensionAttributes, $transitionName);
}
}
12 changes: 6 additions & 6 deletions Content/Application/ContentFacade/ContentFacadeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@

namespace Sulu\Bundle\ContentBundle\Content\Application\ContentFacade;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;

interface ContentFacadeInterface
{
/**
* @param mixed[] $dimensionAttributes
*/
public function load(ContentInterface $content, array $dimensionAttributes): ContentViewInterface;
public function load(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): ContentViewInterface;

/**
* @param mixed[] $data
* @param mixed[] $dimensionAttributes
*/
public function persist(ContentInterface $content, array $data, array $dimensionAttributes): ContentViewInterface;
public function persist(ContentRichEntityInterface $contentRichEntity, array $data, array $dimensionAttributes): ContentViewInterface;

/**
* @return mixed[]
Expand All @@ -39,17 +39,17 @@ public function resolve(ContentViewInterface $contentView): array;
* @param mixed[] $targetDimensionAttributes
*/
public function copy(
ContentInterface $sourceContent,
ContentRichEntityInterface $sourceContentRichEntity,
array $sourceDimensionAttributes,
ContentInterface $targetContent,
ContentRichEntityInterface $targetContentRichEntity,
array $targetDimensionAttributes
): ContentViewInterface;

/**
* @param mixed[] $dimensionAttributes
*/
public function applyTransition(
ContentInterface $content,
ContentRichEntityInterface $contentRichEntity,
array $dimensionAttributes,
string $transitionName
): ContentViewInterface;
Expand Down
10 changes: 5 additions & 5 deletions Content/Application/ContentLoader/ContentLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Sulu\Bundle\ContentBundle\Content\Domain\Exception\ContentNotFoundException;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\ViewFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Repository\ContentDimensionRepositoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Repository\DimensionRepositoryInterface;
Expand Down Expand Up @@ -47,18 +47,18 @@ public function __construct(
$this->viewFactory = $viewFactory;
}

public function load(ContentInterface $content, array $dimensionAttributes): ContentViewInterface
public function load(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): ContentViewInterface
{
$dimensionCollection = $this->dimensionRepository->findByAttributes($dimensionAttributes);

if (0 === \count($dimensionCollection)) {
throw new ContentNotFoundException($content, $dimensionAttributes);
throw new ContentNotFoundException($contentRichEntity, $dimensionAttributes);
}

$contentDimensionCollection = $this->contentDimensionRepository->load($content, $dimensionCollection);
$contentDimensionCollection = $this->contentDimensionRepository->load($contentRichEntity, $dimensionCollection);

if (0 === \count($contentDimensionCollection)) {
throw new ContentNotFoundException($content, $dimensionAttributes);
throw new ContentNotFoundException($contentRichEntity, $dimensionAttributes);
}

return $this->viewFactory->create($contentDimensionCollection);
Expand Down
4 changes: 2 additions & 2 deletions Content/Application/ContentLoader/ContentLoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

namespace Sulu\Bundle\ContentBundle\Content\Application\ContentLoader;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;

interface ContentLoaderInterface
{
/**
* @param mixed[] $dimensionAttributes
*/
public function load(ContentInterface $content, array $dimensionAttributes): ContentViewInterface;
public function load(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): ContentViewInterface;
}
6 changes: 3 additions & 3 deletions Content/Application/ContentPersister/ContentPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\ContentDimensionCollectionFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\DimensionCollectionFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\ViewFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;

class ContentPersister implements ContentPersisterInterface
Expand Down Expand Up @@ -52,11 +52,11 @@ public function __construct(
$this->viewFactory = $viewFactory;
}

public function persist(ContentInterface $content, array $data, array $dimensionAttributes): ContentViewInterface
public function persist(ContentRichEntityInterface $contentRichEntity, array $data, array $dimensionAttributes): ContentViewInterface
{
$dimensionCollection = $this->dimensionCollectionFactory->create($dimensionAttributes);
$contentDimensionCollection = $this->contentDimensionCollectionFactory->create(
$content,
$contentRichEntity,
$dimensionCollection,
$data
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sulu\Bundle\ContentBundle\Content\Application\ContentPersister;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;

interface ContentPersisterInterface
Expand All @@ -22,5 +22,5 @@ interface ContentPersisterInterface
* @param mixed[] $data
* @param mixed[] $dimensionAttributes
*/
public function persist(ContentInterface $content, array $data, array $dimensionAttributes): ContentViewInterface;
public function persist(ContentRichEntityInterface $contentRichEntity, array $data, array $dimensionAttributes): ContentViewInterface;
}
12 changes: 6 additions & 6 deletions Content/Application/ContentWorkflow/ContentWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Exception\ContentNotExistTransitionException;
use Sulu\Bundle\ContentBundle\Content\Domain\Exception\ContentNotFoundException;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\ViewFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentViewInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\WorkflowInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Repository\ContentDimensionRepositoryInterface;
Expand Down Expand Up @@ -81,22 +81,22 @@ public function __construct(
}

public function apply(
ContentInterface $content,
ContentRichEntityInterface $contentRichEntity,
array $dimensionAttributes,
string $transitionName
): ContentViewInterface {
$dimensionCollection = $this->dimensionRepository->findByAttributes($dimensionAttributes);

if (0 === \count($dimensionCollection)) {
throw new ContentNotFoundException($content, $dimensionAttributes);
throw new ContentNotFoundException($contentRichEntity, $dimensionAttributes);
}

$contentDimensionCollection = $this->contentDimensionRepository->load($content, $dimensionCollection);
$contentDimensionCollection = $this->contentDimensionRepository->load($contentRichEntity, $dimensionCollection);

$localizedContentDimension = $contentDimensionCollection->getLocalizedContentDimension();

if (!$localizedContentDimension) {
throw new ContentNotFoundException($content, $dimensionAttributes);
throw new ContentNotFoundException($contentRichEntity, $dimensionAttributes);
}

if (!$localizedContentDimension instanceof WorkflowInterface) {
Expand All @@ -110,7 +110,7 @@ public function apply(

try {
$workflow->apply($localizedContentDimension, $transitionName, [
'contentRichEntity' => $content,
'contentRichEntity' => $contentRichEntity,
'contentDimensionCollection' => $contentDimensionCollection,
'dimensionAttributes' => $dimensionAttributes,
]);
Expand Down
Loading

0 comments on commit f0f66a0

Please sign in to comment.