Command/GenerateDocumentClassCommand.php
author ymh <ymh.work@gmail.com>
Thu, 01 Mar 2012 18:44:24 +0100
changeset 81 145296a918f8
parent 23 b435f8055cb4
permissions -rwxr-xr-x
Small correction

<?php
/*
 * This file is part of the WikiTagBundle package.
 *
 * (c) IRI <http://www.iri.centrepompidou.fr/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace IRI\Bundle\WikiTagBundle\Command;


use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class GenerateDocumentClassCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        parent::configure();
        
        $this
            ->setName('wikitag:generate-document-class')
            ->setDescription('Generate the document class')
            ->addArgument('path', InputArgument::OPTIONAL, 'The generation path')
            ->addOption("simulate","S",InputOption::VALUE_NONE, "Simulate generation");
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $path = $input->getArgument('path');
        if(is_null($path) || strlen($path) == 0)
        {
            $path = realpath($this->getContainer()->get('kernel')->getRootDir()."/../src");
        }
        
        $schema_utils = $this->getContainer()->get("wikitag.shema_utils");
        
        $classCode = $schema_utils->generateDocumentClass();
        
        if($input->getOption('simulate'))
        {
            $output->writeln($classCode);
        }
        else
        {
            $file = "$path/IRI/Bundle/WikiTagBundle/Entity/Document.php";
            $output->writeln("Creating IRI\\Bundle\\WikiTagBundle\\Entity\\Document in $file");
            
            if(!file_exists(dirname($file)) && !mkdir(dirname($file),0777,true))
            {
                $output->writeln("Impossible to create folder exitiing.");
                die;
            }
            file_put_contents($file, $classCode);
        }

    }
}
PKҀ AOM: platform-45d814511958/virtualenv/res/lib/lib_create_env.pyUT #PPKҀ AvJI1 Wplatform-45d814511958/virtualenv/res/lib/patch.pyUT #PPKҀ A .Etwt: &platform-45d814511958/virtualenv/res/src/Django-1.4.tar.gzUT #PPKҀ A== Pltplatform-45d814511958/virtualenv/res/src/Imaging-1.1.7.tar.gzUT #PPKҀ ACaoB C |platform-45d814511958/virtualenv/res/src/MySQL-python-1.2.3.tar.gzUT #PPKҀ AsxO v}platform-45d814511958/virtualenv/res/src/MySQL-python-1.2.3.win-amd64-py2.7.exeUT #PPKҀ AgEFXK platform-45d814511958/virtualenv/res/src/MySQL-python-1.2.3.win32-py2.7.exeUT #PPKҀ A{/] B P{platform-45d814511958/virtualenv/res/src/PIL-1.1.7.win32-py2.6.exeUT #PPKҀ AYy x A d٥platform-45d814511958/virtualenv/res/src/distribute-0.6.24.tar.gzUT #PPKҀ A'Dm&&E }Splatform-45d814511958/virtualenv/res/src/django-extensions-0.8.tar.gzUT #PPKҀ ALSJJE zplatform-45d814511958/virtualenv/res/src/django-guardian-1.0.3.tar.gzUT #PPKҀ AZF ŵplatform-45d814511958/virtualenv/res/src/django-haystack-v2.0.0.tar.gzUT #PPKҀ A`-F>>A 1Ĺplatform-45d814511958/virtualenv/res/src/django-oauth-plus.tar.gzUT #PPKҀ A쭍L hplatform-45d814511958/virtualenv/res/src/django-openid-consumer-0.1.1.tar.gzUT #PPKҀ A~R "platform-45d814511958/virtualenv/res/src/django-piston-7c90898072ce-modifed.tar.gzUT #PPKҀ A~G platform-45d814511958/virtualenv/res/src/django-registration-0.8.tar.gzUT #PPKҀ A5{+{D  platform-45d814511958/virtualenv/res/src/django-tagging-0.3.1.tar.gzUT #PPKҀ A J< /platform-45d814511958/virtualenv/res/src/fabric-1.4.2.tar.gzUT #PPKҀ AGy<8> {platform-45d814511958/virtualenv/res/src/httplib2-0.7.4.tar.gzUT #PPKҀ A!q6h ; *platform-45d814511958/virtualenv/res/src/jpegsrc.v8d.tar.gzUT #PPKҀ AUیx&!&C wJplatform-45d814511958/virtualenv/res/src/lxml-2.2.2-py2.6-win32.eggUT #PPKҀ A^ X ; iYplatform-45d814511958/virtualenv/res/src/lxml-2.3.4.tar.bz2UT #PPKҀ Abw\||4]4? platform-45d814511958/virtualenv/res/src/mercurial-2.2.3.tar.gzUT #PPKҀ A?h[~Q~> u/platform-45d814511958/virtualenv/res/src/oauth2-1.5.211.tar.gzUT #PPKҀ A?A2X Eplatform-45d814511958/virtualenv/res/src/omab-django-social-auth-v0.3.10-modified.tar.gzUT #PPKҀ A_i m X Kplatform-45d814511958/virtualenv/res/src/psycopg2-2.0.14.win32-py2.6-pg8.4.3-release.zipUT #PPKҀ AM6 > platform-45d814511958/virtualenv/res/src/psycopg2-2.4.5.tar.gzUT #PPKҀ AH5< %platform-45d814511958/virtualenv/res/src/pycrypto-2.6.tar.gzUT #PPKҀ A;? bM,platform-45d814511958/virtualenv/res/src/pyelasticsearch.tar.gzUT #PPK9m,