<?php


namespace AutoAdmin\Bundle\Menu\Controller\Admin;

use AutoAdmin\Bundle\Admin\Controller\Admin\EntityController;
use AutoAdmin\Bundle\Menu\Entity\Menu;
use AutoAdmin\Bundle\Menu\Entity\MenuItem;
use AutoAdmin\Bundle\Menu\Entity\MenuItemTranslation;


class MenuController extends EntityController
{
    protected function createEntity($class): object
    {
        /** @var Menu $entity */
        $entity = parent::createEntity($class); // TODO: Change the autogenerated stub
        /** @var MenuItem $root */
        $root = $this->contentFactory->createEntity(MenuItem::class);
        /** @var MenuItemTranslation $rootTr */
        $rootTr = $root->getCurrentTranslation();
        $rootTr->setLabel('root');
        $entity->setRoot($root);

        $root->setMenu($entity);

        return $entity;
    }
}
