PHP code example of vlad-x / pages-bundle

1. Go to this page and download the library: Download vlad-x/pages-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vlad-x / pages-bundle example snippets


return [
    // ...
    VladX\PagesBundle\PagesBundle::class => ['all' => true],
];

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use VladX\PagesBundle\Entity\Page;

#[ORM\Entity]
class HomePage extends Page
{
}

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use VladX\PagesBundle\Entity\Page;

#[ORM\Entity]
#[ORM\AttributeOverrides([
    new ORM\AttributeOverride(
        name: 'slug',
        column: new ORM\Column(length: 500, unique: false),
    ),
])]
class HomePage extends Page
{
}

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use VladX\PagesBundle\Entity\Page;
use VladX\PagesBundle\Attributes\Nestable;

#[ORM\Entity]
#[Nestable]
class NestablePage extends Page
{
}

php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate

namespace App\Controller\Admin;

use App\Entity\HomePage;
use VladX\PagesBundle\Admin\PageCrudController;

class HomePageCrudController extends PageCrudController
{
    public static function getEntityFqcn(): string
    {
        return HomePage::class;
    }
}

public function configureFields(string $pageName): iterable
{
    $this->addGeneralFields(TextField::new('customField'));
    yield from parent::configureFields($pageName);
}

use VladX\PagesBundle\Utility\PagesTemplates;

class PageController extends AbstractController
{
    public function show(HomePage $page, PageHelper $pageHelper, PagesTemplates $templates): Response
    {
        return $this->render(
            $templates->getTemplatePath($page->getTemplate()) ?? 'default/index.html.twig',
            [
                'page' => $page,
                'meta' => $pageHelper->preparePageMeta($page)['meta'],
            ]
        );
    }
}