public function generateMenus()
    {
        foreach ($this->config['roots'] as $name => $config) {
            $this->output->write(sprintf(
                '- <comment>%s</comment> %s ',
                $name,
                str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT)
            ));

            if (null !== $menu = $this->findMenuByName($name)) {
                $this->output->writeln('already exists.');
                continue;
            }

            /** @var \Ekyna\Bundle\CmsBundle\Entity\Menu $menu */
            $menu = $this->repository->createNew();
            $menu
                ->setName($name)
                ->setDescription($config['description'])
                ->setLocked(true);

            foreach ($this->locales as $locale) {
                $menuTranslation = $menu->translate($locale, true);
                $menuTranslation
                    ->setTitle($config['title']);
            }

            $this->operator->persist($menu);

            $this->output->writeln('created.');
        }
    }
public function generateMenus()
    {
        foreach ($this->config['roots'] as $name => $config) {
            $this->output->write(sprintf(
                '- <comment>%s</comment> %s ',
                $name,
                str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT)
            ));

            if (null !== $menu = $this->findMenuByName($name)) {
                $this->output->writeln('already exists.');
                continue;
            }

            /** @var \Ekyna\Bundle\CmsBundle\Entity\Menu $menu */
            $menu = $this->repository->createNew();
            $menu
                ->setName($name)
                ->setDescription($config['description'])
                ->setLocked(true);

            foreach ($this->locales as $locale) {
                $menuTranslation = $menu->translate($locale, true);
                $menuTranslation
                    ->setTitle($config['title']);
            }

            $this->operator->persist($menu);

            $this->output->writeln('created.');
        }
    }
public function generateMenus ( ) { foreach ( $ this -> config [ 'roots' ] as $ name => $ config ) { $ this -> output -> write ( sprintf ( '- <comment>%s</comment> %s ' , $ name , str_pad ( '.' , 44 - mb_strlen ( $ name ) , '.' , STR_PAD_LEFT ) ) ) ; if ( null !== $ menu = $ this -> findMenuByName ( $ name ) ) { $ this -> output -> writeln ( 'already exists.' ) ; continue ; } /** @var \Ekyna\Bundle\CmsBundle\Entity\Menu $menu */ $ menu = $ this -> repository -> createNew ( ) ; $ menu -> setName ( $ name ) -> setDescription ( $ config [ 'description' ] ) -> setLocked ( true ) ; foreach ( $ this -> locales as $ locale ) { $ menuTranslation = $ menu -> translate ( $ locale , true ) ; $ menuTranslation -> setTitle ( $ config [ 'title' ] ) ; } $ this -> operator -> persist ( $ menu ) ; $ this -> output -> writeln ( 'created.' ) ; } }
Generates the menus based on configuration.
Generates the menus based on configuration .