Skip to content

Commit

Permalink
Fix namespaces in documentation about extending view document (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter authored Jun 1, 2021
1 parent 6698927 commit c2902ed
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Resources/doc/article-view-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ return [
```php
<?php

namespace AppBundle\Document;
// src/Document/ArticleViewDocument.php

namespace App\Document;

use ONGR\ElasticsearchBundle\Annotation\Document;
use ONGR\ElasticsearchBundle\Annotation\Property;
Expand All @@ -114,7 +116,7 @@ class ArticleViewDocument extends SuluArticleViewDocument
* }
* )
*/
public $article;
public $myCustomProperty;
}
```

Expand Down Expand Up @@ -149,6 +151,8 @@ sulu_article:
```php
<?php

// src/EventListener/ArticleIndexListener.php

namespace App\EventListener;

use Sulu\Bundle\ArticleBundle\Event\IndexEvent;
Expand All @@ -161,11 +165,11 @@ class ArticleIndexListener
$viewDocument = $event->getViewDocument();
$data = $document->getStructure()->toArray();

if (!array_key_exists('article', $data)) {
if (!array_key_exists('myCustomProperty', $data)) {
return;
}

$viewDocument->article = $data['article'];
$viewDocument->myCustomProperty = $data['myCustomProperty'];
}
}
```
Expand Down

0 comments on commit c2902ed

Please sign in to comment.