Skip to content

Commit

Permalink
Merge branch '2.1' of https://github.com/sulu/SuluArticleBundle into 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Feb 26, 2021
2 parents 5ec1a53 + e86aac4 commit e373716
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 31 deletions.
51 changes: 31 additions & 20 deletions Resources/doc/article-view-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,37 @@ The `content` and `view` property is represented by a proxy to avoid resolving d
To extend the indexed data you can extend the `ArticleViewDocument`. This can be achieved by performing the following
steps. The same steps can also be used to extend the `ArticlePageViewObject`.

### 0. Create a Bundle Class

Unfortunately, the ElasticsearchBundle allows to overwrite document classes only if an `AppBundle` is registered in the
application. If you do not have registered such a bundle yet, you need to add it to your `src` directory and enable it
in the `config/bundles.php` file.

```php
<?php

// src/AppBundle.php

namespace App;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle
{
}
```

```php
<?php

// config/bundles.php

return [
// ...
\App\AppBundle::class => ['all' => true],
]
```

#### 1. Create custom class

```php
Expand Down Expand Up @@ -125,23 +156,3 @@ class ArticleIndexListener
<tag name="kernel.event_listener" event="sulu_article.index" method="onIndex"/>
</service>
```

### Troubleshooting

Unfortunately, the ElasticsearchBundle allows to overwrite document classes only if an `AppBundle` is registered in the
application. If you do not have registered such a bundle yet, you need to add it to your `src` directory and enable it
in the `config/bundles.php` file.

```
<?php
// src/AppBundle.php
namespace App;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AppBundle extends Bundle
{
}
```
2 changes: 1 addition & 1 deletion Resources/doc/content-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The SuluArticleBundle provides 3 ways to include articles into another page (or article).

1. Direct assignment: `article_selection`
1. Direct assignment: `article_selection` or `single_article_selection`
2. Smart-Content: `articles` or `articles_page_tree`
2. Teaser-Selection: `article`

Expand Down
34 changes: 24 additions & 10 deletions Resources/doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@ composer require sulu/article-bundle
```yml
# config/packages/sulu_article.yaml

sulu_article:
index_name: '%env(resolve:ELASTICSEARCH_INDEX)%'
hosts:
- '%env(resolve:ELASTICSEARCH_HOST)%'
types:
article:
translation_key: "sulu_article.article"

sulu_route:
mappings:
Sulu\Bundle\ArticleBundle\Document\ArticleDocument:
generator: "schema"
generator: schema
options:
route_schema: "/articles/{object.getTitle()}"
route_schema: '/articles/{object.getTitle()}'
Sulu\Bundle\ArticleBundle\Document\ArticlePageDocument:
generator: "article_page"
generator: article_page
options:
route_schema: "/{translator.trans(\"page\")}-{object.getPageNumber()}"
parent: "{object.getParent().getRoutePath()}"
route_schema: '{translator.trans("page")}-{object.getPageNumber()}'
parent: '{object.getParent().getRoutePath()}'

sulu_article:
index_name: su_articles
hosts: ['127.0.0.1:9200']

# config/packages/ongr_elasticsearch.yaml
ongr_elasticsearch:
analysis:
tokenizer:
Expand All @@ -43,6 +46,17 @@ ongr_elasticsearch:
tokenizer: pathTokenizer
```
### Create env variables
As the elasticsearch index and host could be different between system we create
environment variables for them.
```
# .env
ELASTICSEARCH_HOST=127.0.0.1:9200
ELASTICSEARCH_INDEX=su_myproject
```

### Configure the routing

```yml
Expand Down

0 comments on commit e373716

Please sign in to comment.