twin-elements/post-bundle

Posts for CMS

Installs: 137

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.8.0 2023-05-30 16:51 UTC

This package is auto-updated.

Last update: 2024-10-30 02:16:09 UTC


README

#Installation 1.composer

2.Add to routes.yaml

post_admin:
    resource: "@TwinElementsPostBundle/Controller/Admin/"
    prefix: /admin
    type: annotation
    requirements:
        _locale: '%app_locales%'
    defaults:
        _locale: '%locale%'
        _admin_locale: '%admin_locale%'
    options: { i18n: false }

Preview url generator

Create class PostPreviewGenerator

class PostPreviewGenerator implements PostPreviewGeneratorInterface
{
    private RouterInterface $router;

    public function __construct(RouterInterface $router)
    {
        $this->router = $router;
    }

    public function generatePreviewUrl(Post $post): string
    {
        return $this->router->generate('post', [
            'id' => $post->getId(),
            'slug' => $post->getSlug()
        ]);
    }
}

in service.yaml

services:
    TwinElements\PostBundle\UrlGenerator\PostPreviewGeneratorInterface:
        alias: 'App\PreviewUrlGenerator\PostPreviewGenerator'