diff --git a/.gitattributes b/.gitattributes index 819b6286..745a52d6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,5 +5,5 @@ .gitattributes export-ignore .gitignore export-ignore .php_cs.dist export-ignore -.phpstan.neon export-ignore -.phpunit.xml.dist export-ignore +phpstan.neon export-ignore +phpunit.xml.dist export-ignore diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 4a328677..6dd48ef3 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -11,10 +11,10 @@ namespace Sulu\Bundle\ArticleBundle\DependencyInjection; -use Sulu\Bundle\ArticleBundle\Article\Domain\Model\Article; -use Sulu\Bundle\ArticleBundle\Article\Domain\Model\ArticleDimensionContent; use Sulu\Bundle\ArticleBundle\Document\ArticlePageViewObject; use Sulu\Bundle\ArticleBundle\Document\ArticleViewDocument; +use Sulu\Bundle\ArticleBundle\Domain\Model\Article; +use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleDimensionContent; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -36,28 +36,23 @@ public function getConfigTreeBuilder() $rootNode ->children() - ->arrayNode('article') + ->enumNode('storage') + ->values([self::ARTICLE_STORAGE_PHPCR, self::ARTICLE_STORAGE_EXPERIMENTAL]) + ->defaultValue(self::ARTICLE_STORAGE_PHPCR) + ->end() + ->arrayNode('objects') ->addDefaultsIfNotSet() ->children() - ->enumNode('storage') - ->values([self::ARTICLE_STORAGE_PHPCR, self::ARTICLE_STORAGE_EXPERIMENTAL]) - ->defaultValue(self::ARTICLE_STORAGE_PHPCR) + ->arrayNode('article') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('model')->defaultValue(Article::class)->end() + ->end() ->end() - ->arrayNode('objects') + ->arrayNode('article_content') ->addDefaultsIfNotSet() ->children() - ->arrayNode('article') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('model')->defaultValue(Article::class)->end() - ->end() - ->end() - ->arrayNode('article_content') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('model')->defaultValue(ArticleDimensionContent::class)->end() - ->end() - ->end() + ->scalarNode('model')->defaultValue(ArticleDimensionContent::class)->end() ->end() ->end() ->end() diff --git a/DependencyInjection/SuluArticleExtension.php b/DependencyInjection/SuluArticleExtension.php index 60831580..81ac83af 100644 --- a/DependencyInjection/SuluArticleExtension.php +++ b/DependencyInjection/SuluArticleExtension.php @@ -11,13 +11,13 @@ namespace Sulu\Bundle\ArticleBundle\DependencyInjection; -use Sulu\Bundle\ArticleBundle\Article\Domain\Model\ArticleInterface; use Sulu\Bundle\ArticleBundle\Document\ArticleDocument; use Sulu\Bundle\ArticleBundle\Document\ArticlePageDocument; use Sulu\Bundle\ArticleBundle\Document\Form\ArticleDocumentType; use Sulu\Bundle\ArticleBundle\Document\Form\ArticlePageDocumentType; use Sulu\Bundle\ArticleBundle\Document\Structure\ArticleBridge; use Sulu\Bundle\ArticleBundle\Document\Structure\ArticlePageBridge; +use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleInterface; use Sulu\Bundle\ArticleBundle\Exception\ArticlePageNotFoundException; use Sulu\Bundle\ArticleBundle\Exception\ParameterNotAllowedException; use Sulu\Bundle\PersistenceBundle\DependencyInjection\PersistenceExtensionTrait; @@ -46,7 +46,7 @@ public function prepend(ContainerBuilder $container) $configs = $resolvingBag->resolveValue($configs); $config = $this->processConfiguration(new Configuration(), $configs); - $storage = $config['article']['storage']; + $storage = $config['storage']; if ($container->hasExtension('jms_serializer')) { $container->prependExtensionConfig( @@ -325,7 +325,7 @@ private function prependExperimentalStorage(ContainerBuilder $container): void 'mappings' => [ 'SuluBundleArticle' => [ 'type' => 'xml', - 'prefix' => 'Sulu\Bundle\ArticleBundle\Article\Domain\Model', + 'prefix' => 'Sulu\Bundle\ArticleBundle\Domain\Model', 'dir' => \dirname(__DIR__) . '/Resources/config/doctrine/Article', 'alias' => 'SuluArticleBundle', 'is_bundle' => false, @@ -405,7 +405,7 @@ public function load(array $configs, ContainerBuilder $container) $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); - $storage = $config['article']['storage']; + $storage = $config['storage']; $container->setParameter('sulu_article.article_storage', $storage); if (Configuration::ARTICLE_STORAGE_PHPCR === $storage) { @@ -417,7 +417,7 @@ public function load(array $configs, ContainerBuilder $container) private function loadExperimentalStorage(array $config, ContainerBuilder $container, Loader\XmlFileLoader $loader): void { - $this->configurePersistence($config['article']['objects'], $container); + $this->configurePersistence($config['objects'], $container); $loader->load('experimental.xml'); } diff --git a/Article/Domain/Model/Article.php b/Domain/Model/Article.php similarity index 94% rename from Article/Domain/Model/Article.php rename to Domain/Model/Article.php index c320823b..b79933ff 100644 --- a/Article/Domain/Model/Article.php +++ b/Domain/Model/Article.php @@ -9,7 +9,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ArticleBundle\Article\Domain\Model; +namespace Sulu\Bundle\ArticleBundle\Domain\Model; use Ramsey\Uuid\Uuid; use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityTrait; diff --git a/Article/Domain/Model/ArticleDimensionContent.php b/Domain/Model/ArticleDimensionContent.php similarity index 97% rename from Article/Domain/Model/ArticleDimensionContent.php rename to Domain/Model/ArticleDimensionContent.php index ecfe015c..059ea4e7 100644 --- a/Article/Domain/Model/ArticleDimensionContent.php +++ b/Domain/Model/ArticleDimensionContent.php @@ -11,7 +11,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ArticleBundle\Article\Domain\Model; +namespace Sulu\Bundle\ArticleBundle\Domain\Model; use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface; use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentTrait; diff --git a/Article/Domain/Model/ArticleDimensionContentInterface.php b/Domain/Model/ArticleDimensionContentInterface.php similarity index 93% rename from Article/Domain/Model/ArticleDimensionContentInterface.php rename to Domain/Model/ArticleDimensionContentInterface.php index fd206fc6..2e6f7d7e 100644 --- a/Article/Domain/Model/ArticleDimensionContentInterface.php +++ b/Domain/Model/ArticleDimensionContentInterface.php @@ -9,7 +9,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ArticleBundle\Article\Domain\Model; +namespace Sulu\Bundle\ArticleBundle\Domain\Model; use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface; use Sulu\Bundle\ContentBundle\Content\Domain\Model\ExcerptInterface; diff --git a/Article/Domain/Model/ArticleInterface.php b/Domain/Model/ArticleInterface.php similarity index 90% rename from Article/Domain/Model/ArticleInterface.php rename to Domain/Model/ArticleInterface.php index 7f39ae9d..bd4b0eb5 100644 --- a/Article/Domain/Model/ArticleInterface.php +++ b/Domain/Model/ArticleInterface.php @@ -9,7 +9,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ArticleBundle\Article\Domain\Model; +namespace Sulu\Bundle\ArticleBundle\Domain\Model; use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface; use Sulu\Component\Persistence\Model\AuditableInterface; diff --git a/Article/Infrastructure/Sulu/Admin/ArticleAdmin.php b/Infrastructure/Sulu/Admin/ArticleAdmin.php similarity index 97% rename from Article/Infrastructure/Sulu/Admin/ArticleAdmin.php rename to Infrastructure/Sulu/Admin/ArticleAdmin.php index b209b96e..e2267393 100644 --- a/Article/Infrastructure/Sulu/Admin/ArticleAdmin.php +++ b/Infrastructure/Sulu/Admin/ArticleAdmin.php @@ -9,7 +9,7 @@ * with this source code in the file LICENSE. */ -namespace Sulu\Bundle\ArticleBundle\Article\Infrastructure\Sulu\Admin; +namespace Sulu\Bundle\ArticleBundle\Infrastructure\Sulu\Admin; use Sulu\Bundle\AdminBundle\Admin\Admin; use Sulu\Bundle\AdminBundle\Admin\Navigation\NavigationItem; @@ -17,7 +17,7 @@ use Sulu\Bundle\AdminBundle\Admin\View\ToolbarAction; use Sulu\Bundle\AdminBundle\Admin\View\ViewBuilderFactoryInterface; use Sulu\Bundle\AdminBundle\Admin\View\ViewCollection; -use Sulu\Bundle\ArticleBundle\Article\Domain\Model\ArticleInterface; +use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleInterface; use Sulu\Bundle\ContentBundle\Content\Infrastructure\Sulu\Admin\ContentViewBuilderFactoryInterface; use Sulu\Component\Localization\Manager\LocalizationManagerInterface; use Sulu\Component\Security\Authorization\PermissionTypes; diff --git a/Resources/config/doctrine/Article/Article.orm.xml b/Resources/config/doctrine/Article/Article.orm.xml index d8228020..1a28b7de 100644 --- a/Resources/config/doctrine/Article/Article.orm.xml +++ b/Resources/config/doctrine/Article/Article.orm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> @@ -11,7 +11,7 @@ - + diff --git a/Resources/config/doctrine/Article/ArticleDimensionContent.orm.xml b/Resources/config/doctrine/Article/ArticleDimensionContent.orm.xml index 74296914..6b30ffc7 100644 --- a/Resources/config/doctrine/Article/ArticleDimensionContent.orm.xml +++ b/Resources/config/doctrine/Article/ArticleDimensionContent.orm.xml @@ -2,7 +2,7 @@ - @@ -10,7 +10,7 @@ - + diff --git a/Resources/config/experimental.xml b/Resources/config/experimental.xml index cdbc5f1c..7ac80f80 100644 --- a/Resources/config/experimental.xml +++ b/Resources/config/experimental.xml @@ -11,7 +11,7 @@ --> - + diff --git a/Resources/doc/experimental-storage.md b/Resources/doc/experimental-storage.md index 11c21313..cbd19e35 100644 --- a/Resources/doc/experimental-storage.md +++ b/Resources/doc/experimental-storage.md @@ -2,6 +2,15 @@ For the **experimental** storage the articles are stored using the [SuluContentBundle](https://github.com/sulu/sulucontentbundle). +## Table of content + + - [Installation](#installation) + - [Routes](#routes) + - [Configuration](#configuration) + - [Override Entities](#override-entities) + - [Override Article Entity](#override-article-entity) + - [Override Article Content Entity](#override-article-entity) + ## Installation To use the experimental storage you need to have the [SuluContentBundle](https://github.com/sulu/sulucontentbundle) installed. @@ -18,19 +27,28 @@ sulu_article: storage: experimental ``` +## Routes + +```yaml +# config/routes/sulu_article_admin.yaml + +## coming soon ... +``` + ## Configuration The following is showing the full configuration of the **experimental** article module: ```yaml sulu_product: - article: - storage: experimental - - # optional - objects: - article: - model: 'Sulu\Bundle\ArticleBundle\Article\Domain\Model\Article' + storage: experimental + + # optional + objects: + article: + model: 'Sulu\Bundle\ArticleBundle\Domain\Model\Article' + article_content: + model: 'Sulu\Bundle\ArticleBundle\Domain\Model\ArticleDimensionContent' ``` ## Override Entities @@ -44,7 +62,7 @@ sulu_product: namespace App\Entity; use Doctrine\ORM\Mapping as ORM; -use Sulu\Bundle\ArticleBundle\Product\Domain\Model\Article as SuluArticle; +use Sulu\Bundle\ArticleBundle\Domain\Model\Article as SuluArticle; /** * @ORM\Table(name="ar_articles") @@ -61,10 +79,42 @@ Configure your new model class: # config/packages/sulu_article.yaml sulu_article: - article: - objects: - article: - model: 'App\Entity\Article' + objects: + article: + model: 'App\Entity\Article' +``` + +To add new fields to your entity have a look at the [Doctrine Mapping Documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/basic-mapping.html); + +### Override Article Content Entity + +```php + - - ./Tests + + + Tests/Unit + + + + Tests/Functional @@ -20,8 +25,10 @@ - - + + + +