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; 9 10use Symfony\Component\Console\Command\Command; 11use Symfony\Component\Console\Input\InputArgument; 12use Symfony\Component\Console\Input\InputInterface; 13use Symfony\Component\Console\Output\OutputInterface; 14 15class MultiTikiListCommand extends Command 16{ 17 protected function configure() 18 { 19 $this 20 ->setName('multitiki:list') 21 ->setDescription('List MultiTikis in a path') 22 ->addArgument( 23 'path', 24 InputArgument::OPTIONAL, 25 'path to the Tiki instance to list (defaults to this one if absent)' 26 ) 27 ; 28 } 29 30 protected function execute(InputInterface $input, OutputInterface $output) 31 { 32 $path = $input->getArgument('path'); 33 34 if (! $path) { 35 $path = getcwd(); 36 } 37 38 $virtuals = $path . '/db/virtuals.inc'; 39 40 $list = []; 41 42 if (is_file($virtuals)) { 43 $list = file($virtuals); 44 } 45 if ($list) { 46 if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { 47 $output->writeln("<info>Multitikis in $path</info>"); 48 } 49 foreach ($list as $multi) { 50 $output->writeln(trim($multi)); 51 } 52 } else { 53 if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { 54 $output->writeln("<info>No multitikis found in $path</info>"); 55 } 56 } 57 } 58} 59