-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass DimensionContentCollection to DataMapper services (#182)
- Loading branch information
1 parent
e3e85e9
commit 8f26491
Showing
30 changed files
with
814 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
Content/Infrastructure/Sulu/Preview/PreviewDimensionContentCollection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Preview; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentCollectionInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface; | ||
|
||
/** | ||
* @internal | ||
* @implements \IteratorAggregate<DimensionContentInterface> | ||
*/ | ||
class PreviewDimensionContentCollection implements \IteratorAggregate, DimensionContentCollectionInterface | ||
{ | ||
/** | ||
* @var DimensionContentInterface | ||
*/ | ||
private $previewDimensionContent; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $previewLocale; | ||
|
||
public function __construct( | ||
DimensionContentInterface $previewDimensionContent, | ||
string $previewLocale | ||
) { | ||
$this->previewDimensionContent = $previewDimensionContent; | ||
$this->previewLocale = $previewLocale; | ||
} | ||
|
||
public function getDimensionContentClass(): string | ||
{ | ||
return \get_class($this->previewDimensionContent); | ||
} | ||
|
||
public function getDimensionContent(array $dimensionAttributes): ?DimensionContentInterface | ||
{ | ||
return $this->previewDimensionContent; | ||
} | ||
|
||
public function getDimensionAttributes(): array | ||
{ | ||
return array_merge( | ||
$this->previewDimensionContent::getDefaultDimensionAttributes(), | ||
['locale' => $this->previewLocale] | ||
); | ||
} | ||
|
||
public function getIterator() | ||
{ | ||
return new ArrayCollection([$this->previewDimensionContent]); | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return 1; | ||
} | ||
} |
Oops, something went wrong.