Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add single article selection content type #2

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Sulu\Article\Infrastructure\Sulu\Content;

use Sulu\Article\Domain\Repository\ArticleRepositoryInterface;
use Sulu\Article\Infrastructure\Doctrine\Repository\ArticleRepository;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;
use Sulu\Bundle\WebsiteBundle\ReferenceStore\ReferenceStoreInterface;
use Sulu\Component\Content\Compat\PropertyInterface;
use Sulu\Component\Content\PreResolvableContentTypeInterface;
Expand All @@ -16,7 +18,7 @@ class SingleArticleSelectionContentType extends SimpleContentType implements Pre

public function __construct(
ArticleRepositoryInterface $articleRepository,
ReferenceStoreInterface $referenceStore,
ReferenceStoreInterface $referenceStore,
)
{
parent::__construct('Article');
Expand All @@ -32,7 +34,22 @@ public function getContentData(PropertyInterface $property)
return null;
}

return $this->articleRepository->getOneBy(['uuid' => $uuid]);
$dimensionAttributes = [
'locale' => $property->getStructure()->getLanguageCode(),
'stage' => DimensionContentInterface::STAGE_DRAFT,
TheCadien marked this conversation as resolved.
Show resolved Hide resolved
];

return $this->articleRepository->getOneBy(
TheCadien marked this conversation as resolved.
Show resolved Hide resolved
filters: \array_merge(
[
'uuid' => $uuid,
'load_ghost_content' => true,
TheCadien marked this conversation as resolved.
Show resolved Hide resolved
],
$dimensionAttributes,
),
selects: [
ArticleRepositoryInterface::GROUP_SELECT_ARTICLE_ADMIN => true,
TheCadien marked this conversation as resolved.
Show resolved Hide resolved
]);
}

public function preResolve(PropertyInterface $property)
Expand Down