-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a3875f
commit 46a3dff
Showing
4 changed files
with
161 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?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\Article\Infrastructure\Sulu\Content; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Sulu\Article\Domain\Model\ArticleDimensionContentInterface; | ||
use Sulu\Article\Domain\Model\ArticleInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManagerInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Link\ContentLinkProvider; | ||
use Sulu\Bundle\MarkupBundle\Markup\Link\LinkConfiguration; | ||
use Sulu\Bundle\MarkupBundle\Markup\Link\LinkConfigurationBuilder; | ||
use Sulu\Component\Content\Metadata\Factory\StructureMetadataFactoryInterface; | ||
|
||
/** | ||
* @extends ContentLinkProvider<ArticleDimensionContentInterface, ArticleInterface> | ||
*/ | ||
class ArticleLinkProvider extends ContentLinkProvider | ||
{ | ||
public function __construct( | ||
ContentManagerInterface $contentManager, | ||
StructureMetadataFactoryInterface $structureMetadataFactory, | ||
EntityManagerInterface $entityManager, | ||
) { | ||
parent::__construct($contentManager, $structureMetadataFactory, $entityManager, ArticleInterface::class); | ||
} | ||
|
||
public function getConfiguration(): LinkConfiguration | ||
{ | ||
return LinkConfigurationBuilder::create() | ||
->setTitle('Example') | ||
->setResourceKey(ArticleInterface::RESOURCE_KEY) | ||
->setListAdapter('table') | ||
->setDisplayProperties(['id']) | ||
->setOverlayTitle('Select Example') | ||
->setEmptyText('No example selected') | ||
->setIcon('su-document') | ||
->getLinkConfiguration(); | ||
} | ||
} |
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,73 @@ | ||
<?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\Article\Infrastructure\Sulu\Content; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Sulu\Article\Domain\Model\ArticleDimensionContentInterface; | ||
use Sulu\Article\Domain\Model\ArticleInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManagerInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Application\ContentMetadataInspector\ContentMetadataInspectorInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Teaser\ContentTeaserProvider; | ||
use Sulu\Bundle\PageBundle\Teaser\Configuration\TeaserConfiguration; | ||
use Sulu\Component\Content\Metadata\Factory\StructureMetadataFactoryInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
/** | ||
* @extends ContentTeaserProvider<ArticleDimensionContentInterface, ArticleInterface> | ||
*/ | ||
class ArticleTeaserProvider extends ContentTeaserProvider | ||
{ | ||
/** | ||
* @var TranslatorInterface | ||
*/ | ||
protected $translator; | ||
|
||
public function __construct( | ||
ContentManagerInterface $contentManager, | ||
EntityManagerInterface $entityManager, | ||
ContentMetadataInspectorInterface $contentMetadataInspector, | ||
StructureMetadataFactoryInterface $metadataFactory, | ||
TranslatorInterface $translator, | ||
bool $showDrafts, | ||
) { | ||
parent::__construct($contentManager, $entityManager, $contentMetadataInspector, $metadataFactory, ArticleInterface::class, $showDrafts); | ||
|
||
$this->translator = $translator; | ||
} | ||
|
||
public function getConfiguration(): TeaserConfiguration | ||
{ | ||
return new TeaserConfiguration( | ||
$this->translator->trans('sulu_article.article', [], 'admin'), | ||
$this->getResourceKey(), | ||
'table', | ||
['title'], | ||
$this->translator->trans('sulu_article.single_selection_overlay_title', [], 'admin'), | ||
); | ||
} | ||
|
||
/** | ||
* @param array{ | ||
* article?: string|null, | ||
* description?: string|null, | ||
* } $data | ||
*/ | ||
protected function getDescription(DimensionContentInterface $dimensionContent, array $data): ?string | ||
{ | ||
$article = \strip_tags($data['article'] ?? ''); | ||
|
||
return $article ?: parent::getDescription($dimensionContent, $data); | ||
} | ||
} |
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