PHP code example of umanit / tree-bundle

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

    

umanit / tree-bundle example snippets


    Umanit\TreeBundle\UmanitTreeBundle::class => ['all' => true],

    public function getAction(Request $request)
    {
        $entity = $request->attributes->get('contentObject'); // Your entity
        $node = $request->attributes->get('contentNode'); // TreeBundle's node
    }

$builder
    ->add('parents', \Umanit\TreeBundle\Form\Type\TreeNodeType::class, [
        '

$builder
    ->add('seoMetadata', \Umanit\TreeBundle\Form\Type\SeoMetadataType::class, [
        '

$builder
    ->add('link', 'umanit_link_type_translatable', [
            'label' => 'Link',
            // List of content types available
            'models' => [
                'Page'    => 'Umanit\App\Entity\Page',
                'Article' => 'Umanit\App\Entity\Article',
            ],
        ], [
            // Filters for some content types (if needed)
            'query_filters' => [
                'App\Entity\Page' => ['locale' => 'en'],
            ],
            'allow_external' => false,   
        ]
    ]);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Umanit\TreeBundle\Entity\AbstractMenu as BaseMenu;
use Umanit\TreeBundle\Repository\MenuRepository;

/**
 * Menu
 *
 * @ORM\Table(name="menu")
 * @ORM\Entity(repositoryClass="Umanit\TreeBundle\Repository\MenuRepository") // Using TreeBundle's repository is
 *                                                                            mandatory
 * @ORM\HasLifecycleCallbacks() // This is mandatory too
 */
#[ORM\Table(name: 'menu')]
#[ORM\Entity(repositoryClass: MenuRepository::class)] // Using TreeBundle's repository is mandatory
#[ORM\HasLifecycleCallbacks] // Mandatory
class Menu extends BaseMenu
{
}

namespace App\Form;

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Vich\UploaderBundle\Form\Type\VichImageType;
use Umanit\TreeBundle\Form\Type\MenuType as BaseMenuType;

class MenuType extends BaseMenuType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder
            ->add('imageFile', VichImageType::class, [
                'label'        => 'Image',
                '