diff --git a/Content/ArticleDataProvider.php b/Content/ArticleDataProvider.php index d68313341..1b90c05f3 100644 --- a/Content/ArticleDataProvider.php +++ b/Content/ArticleDataProvider.php @@ -118,6 +118,7 @@ protected function getConfigurationBuilder(): BuilderInterface ] ); + // for sulu versions < 2.1 the enableView does not exist if (method_exists($builder, 'enableView')) { $builder->enableView(ArticleAdmin::EDIT_FORM_VIEW, ['id' => 'id']); } diff --git a/DependencyInjection/SuluArticleExtension.php b/DependencyInjection/SuluArticleExtension.php index 36773d1c8..09bc2557b 100644 --- a/DependencyInjection/SuluArticleExtension.php +++ b/DependencyInjection/SuluArticleExtension.php @@ -11,6 +11,7 @@ namespace Sulu\Bundle\ArticleBundle\DependencyInjection; +use Sulu\Bundle\ArticleBundle\Admin\ArticleAdmin; use Sulu\Bundle\ArticleBundle\Document\ArticleDocument; use Sulu\Bundle\ArticleBundle\Document\ArticlePageDocument; use Sulu\Bundle\ArticleBundle\Document\Form\ArticleDocumentType; @@ -19,6 +20,7 @@ use Sulu\Bundle\ArticleBundle\Document\Structure\ArticlePageBridge; use Sulu\Bundle\ArticleBundle\Exception\ArticlePageNotFoundException; use Sulu\Bundle\ArticleBundle\Exception\ParameterNotAllowedException; +use Sulu\Component\SmartContent\Configuration\BuilderInterface; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; @@ -174,62 +176,77 @@ public function prepend(ContainerBuilder $container) } if ($container->hasExtension('sulu_admin')) { - $container->prependExtensionConfig( - 'sulu_admin', - [ - 'lists' => [ - 'directories' => [ - __DIR__ . '/../Resources/config/lists', - ], + $suluAdminConfig = [ + 'lists' => [ + 'directories' => [ + __DIR__ . '/../Resources/config/lists', ], - 'forms' => [ - 'directories' => [ - __DIR__ . '/../Resources/config/forms', - ], + ], + 'forms' => [ + 'directories' => [ + __DIR__ . '/../Resources/config/forms', ], - 'resources' => [ - 'articles' => [ - 'routes' => [ - 'list' => 'sulu_article.get_articles', - 'detail' => 'sulu_article.get_article', - ], + ], + 'resources' => [ + 'articles' => [ + 'routes' => [ + 'list' => 'sulu_article.get_articles', + 'detail' => 'sulu_article.get_article', ], ], - 'field_type_options' => [ - 'selection' => [ - 'article_selection' => [ - 'default_type' => 'list_overlay', - 'resource_key' => 'articles', - 'types' => [ - 'list_overlay' => [ - 'adapter' => 'table', - 'list_key' => 'articles', - 'display_properties' => ['title', 'routePath'], - 'icon' => 'su-newspaper', - 'label' => 'sulu_article.selection_label', - 'overlay_title' => 'sulu_article.selection_overlay_title', - ], + ], + 'field_type_options' => [ + 'selection' => [ + 'article_selection' => [ + 'default_type' => 'list_overlay', + 'resource_key' => 'articles', + 'types' => [ + 'list_overlay' => [ + 'adapter' => 'table', + 'list_key' => 'articles', + 'display_properties' => ['title', 'routePath'], + 'icon' => 'su-newspaper', + 'label' => 'sulu_article.selection_label', + 'overlay_title' => 'sulu_article.selection_overlay_title', ], ], ], - 'single_selection' => [ - 'single_article_selection' => [ - 'default_type' => 'list_overlay', - 'resource_key' => 'articles', - 'types' => [ - 'list_overlay' => [ - 'adapter' => 'table', - 'list_key' => 'articles', - 'display_properties' => ['title'], - 'empty_text' => 'sulu_article.no_article_selected', - 'icon' => 'su-newspaper', - 'overlay_title' => 'sulu_article.single_selection_overlay_title', - ], + ], + 'single_selection' => [ + 'single_article_selection' => [ + 'default_type' => 'list_overlay', + 'resource_key' => 'articles', + 'types' => [ + 'list_overlay' => [ + 'adapter' => 'table', + 'list_key' => 'articles', + 'display_properties' => ['title'], + 'empty_text' => 'sulu_article.no_article_selected', + 'icon' => 'su-newspaper', + 'overlay_title' => 'sulu_article.single_selection_overlay_title', ], ], ], ], - ] + ], + ]; + + $articleViewConfig = [ + 'name' => ArticleAdmin::EDIT_FORM_VIEW, + 'result_to_view' => [ + 'id' => 'id', + ], + ]; + + // for sulu versions < 2.1 the view config does not exist and will fail + if (method_exists(BuilderInterface::class, 'enableView')) { + $suluAdminConfig['field_type_options']['selection']['article_selection']['view'] = $articleViewConfig; + $suluAdminConfig['field_type_options']['single_selection']['single_article_selection']['view'] = $articleViewConfig; + } + + $container->prependExtensionConfig( + 'sulu_admin', + $suluAdminConfig ); } diff --git a/Teaser/ArticleTeaserProvider.php b/Teaser/ArticleTeaserProvider.php index abab97846..6101a7840 100644 --- a/Teaser/ArticleTeaserProvider.php +++ b/Teaser/ArticleTeaserProvider.php @@ -13,6 +13,7 @@ use ONGR\ElasticsearchBundle\Service\Manager; use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery; +use Sulu\Bundle\ArticleBundle\Admin\ArticleAdmin; use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocument; use Sulu\Bundle\ArticleBundle\Metadata\ArticleViewDocumentIdTrait; use Sulu\Bundle\PageBundle\Teaser\Configuration\TeaserConfiguration; @@ -59,7 +60,9 @@ public function getConfiguration() 'articles', 'table', ['title'], - $this->translator->trans('sulu_article.single_selection_overlay_title', [], 'admin') + $this->translator->trans('sulu_article.single_selection_overlay_title', [], 'admin'), + ArticleAdmin::EDIT_FORM_VIEW, + ['id' => 'id'] ); }