PHP code example of zenstruck / content-bundle

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

    

zenstruck / content-bundle example snippets


    // path/to/your/bundle/Entity/Node.php

    namespace YourApplicationBundle\Entity;

    use Zenstruck\Bundle\ContentBundle\Entity\Node as BaseNode;

    /**
     * @orm:Entity
     */
    class Node extends BaseNode
    {
        // add any node fields (or leave empty)
    }
    

    // path/to/your/bundle/Entity/BlogPost.php

    namespace YourApplicationBundle\Entity;

    /**
     * @orm:Entity
     */
    class BlogPost extends Node
    {
        /**
         * @orm:Column(type="text", nullable=true)
         */
        protected $body;

        public function getBody()
        {
            return $this->body;
        }

        public function setBody($body)
        {
            $this->body = $body;
        }
    }
    

// controller
$manager = $this->container->get('zenstruck_content.manager');
$manager->getAncestors($node);

namespace Acme\DemoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Zenstruck\Bundle\ContentBundle\Validator\InheritedUniqueEntity;

/**
 * Acme\DemoBundle\Entity\Node
 *
 * @ORM\Table(name="page")
 * @ORM\Entity
 * @InheritedUniqueEntity(field="body")
 */
class Page extends Node
{

    /**
     * @var string $body
     *
     * @ORM\Column(name="body", type="string", length=255, nullable=true)
     */
    protected $body;

    //...
}