Skip to content

Commit

Permalink
append config for article-page in article-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Jun 22, 2017
1 parent 1ba40e3 commit 133cfa2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
35 changes: 35 additions & 0 deletions DependencyInjection/SuluArticleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public function load(array $configs, ContainerBuilder $container)
}

$this->appendDefaultAuthor($config, $container);
$this->appendArticlePageConfig($container);
}

/**
Expand All @@ -188,4 +189,38 @@ private function appendDefaultAuthor(array $config, ContainerBuilder $container)
$container->setParameter('sulu_document_manager.mapping', $mapping);
$container->setParameter('sulu_article.default_author', $config['default_author']);
}

/**
* Append configuration for article-page (cloned from article).
*
* @param ContainerBuilder $container
*/
private function appendArticlePageConfig(ContainerBuilder $container)
{
$paths = $container->getParameter('sulu.content.structure.paths');
$paths['article_page'] = $this->cloneArticleConfig($paths['article'], 'article_page');
$container->setParameter('sulu.content.structure.paths', $paths);

$defaultTypes = $container->getParameter('sulu.content.structure.default_types');
$defaultTypes['article_page'] = $defaultTypes['article'];
$container->setParameter('sulu.content.structure.default_types', $defaultTypes);
}

/**
* Clone given path configuration and use given type.
*
* @param array $config
* @param string $type
*
* @return array
*/
private function cloneArticleConfig(array $config, $type)
{
$result = [];
foreach ($config as $item) {
$result[] = ['path' => $item['path'], 'type' => $type];
}

return $result;
}
}
6 changes: 2 additions & 4 deletions Resources/doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ else read: [Installation for ElasticSearch 5.0](installation_es5.md)

### Add bundles to AbstractKernel

The bundle should be registered after the `SuluCoreBundle`.

```php
/* app/AbstractKernel.php */

Expand All @@ -41,14 +43,10 @@ sulu_core:
structure:
default_type:
article: "article_default"
article_page: "article_default"
paths:
article:
path: "%kernel.root_dir%/Resources/templates/articles"
type: "article"
article_page:
path: "%kernel.root_dir%/Resources/templates/articles"
type: "article_page"
```
### Configure the routing
Expand Down

0 comments on commit 133cfa2

Please sign in to comment.