1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8namespace Tiki\Command\ProfileExport; 9 10use Symfony\Component\Console\Input\InputArgument; 11use Symfony\Component\Console\Input\InputInterface; 12use Symfony\Component\Console\Input\InputOption; 13use Symfony\Component\Console\Output\OutputInterface; 14 15class Menu extends ObjectWriter 16{ 17 protected function configure() 18 { 19 $this 20 ->setName('profile:export:menu') 21 ->setDescription('Export a menu definition') 22 ->addOption( 23 'all', 24 null, 25 InputOption::VALUE_NONE, 26 'Export all menus' 27 ) 28 ->addArgument( 29 'menu', 30 InputArgument::OPTIONAL, 31 'Menu ID' 32 ); 33 34 parent::configure(); 35 } 36 37 protected function execute(InputInterface $input, OutputInterface $output) 38 { 39 $menuId = $input->getArgument('menu'); 40 $all = $input->getOption('all'); 41 42 if (! $all && empty($menuId)) { 43 $output->writeln('<error>' . tra('Not enough arguments (missing: "menu" or "--all" option)') . '</error>'); 44 return false; 45 } 46 47 $writer = $this->getProfileWriter($input); 48 49 $result = \Tiki_Profile_InstallHandler_Menu::export($writer, $menuId, $all); 50 51 if ($result) { 52 $writer->save(); 53 } else { 54 $output->writeln("Menu not found: $menuId"); 55 } 56 } 57} 58