PHP code example of n-ramos / celebrimbor-bundle

1. Go to this page and download the library: Download n-ramos/celebrimbor-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/ */

    

n-ramos / celebrimbor-bundle example snippets


use Doctrine\ORM\Mapping as ORM;
use NRamos\CelebrimborBundle\Concern\InteractsWithPageBuilderContent;
use NRamos\CelebrimborBundle\Contract\HasPageBuilderContent;

#[ORM\Entity]
class Page implements HasPageBuilderContent
{
    use InteractsWithPageBuilderContent;

    // ... your own id, title, slug, etc.
}

use NRamos\CelebrimborBundle\Form\PageBuilderType;

$builder->add('document', PageBuilderType::class, [
    // 'format' => PageBuilderFormat::Document,
    'preview_url' => $this->generateUrl('admin_page_preview', ['id' => $page->getId()]),
]);

use NRamos\CelebrimborBundle\Preview\AbstractPreviewController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class PagePreviewController extends AbstractPreviewController
{
    #[Route('/admin/pages/{id}/preview', name: 'admin_page_preview')]
    public function __invoke(Page $page): Response
    {
        // A) Native Twig — one template per block (blocks/<name>.html.twig):
        return $this->renderPreview($page);

        // B) Same JS renderer as the editor (faithful to production):
        // return $this->renderJsPreview($page);
    }
}