Skip to content

Commit

Permalink
[Slug] docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed Nov 24, 2022
1 parent 1497088 commit eac326c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ jobs:

- name: Upload Folder
uses: 'google-github-actions/upload-cloud-storage@v0'
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/3.0'
with:
path: 'docs/generated-docs/'
destination: 'cors-wolke-coreshop-docs/3.0.0'
parent: false

- name: Upload Folder
uses: 'google-github-actions/upload-cloud-storage@v0'
if: github.ref == 'refs/heads/master'
with:
path: 'docs/generated-docs/'
destination: 'cors-wolke-coreshop-docs/3.1.0'
parent: false
37 changes: 37 additions & 0 deletions docs/02_Bundles/Pimcore_Bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,40 @@ You can inherit this as deep as you want, but be careful. The deeper it goes, th
![Embeded Class Data](img/embedded_class_data.png)

![Embeded Class Data](img/embedded_class_tag.png)

### Slug

Pimcore comes with quite useful objects slugs. But it doesn't come with a Slug Generator. CoreShop for the rescue. In Order to use it,
your class needs to implement `CoreShop\Component\Pimcore\Slug\SluggableInterface` and CoreShop automatically generates slugs for you.

#### Extensions / Influence the slug generation

If you want to change the generated slug or prefix it, you can use the `CoreShop\Component\Pimcore\Event\SlugGenerationEvent` Event.

```
<?php
declare(strict_types=1);
namespace App\EventListener;
use CoreShop\Component\Pimcore\Event\SlugGenerationEvent;
use Pimcore\Model\DataObject\PressRelease;
use Pimcore\Model\Document;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class SlugEventListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
SlugGenerationEvent::class => 'onGenerate',
];
}
public function onGenerate(SlugGenerationEvent $event): void
{
$event->setSlug($event->getSlug() . '-bar');
}
}
```

0 comments on commit eac326c

Please sign in to comment.