*/ class AclInitCommand extends SqlInsertCommand { protected function configure() { $this ->setDescription('Initialize "Access Control Lists" model and SQL') ->addOption('force', null, InputOption::VALUE_NONE, 'Set this parameter to execute this action.') ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use') ->setHelp(<<%command.name% command connects to the database and executes all SQL statements required to setup the ACL database, it also generates the ACL model. php %command.full_name% The --force parameter has to be used to actually insert SQL. The --connection parameter allows you to change the connection to use. The default connection is the active connection (propel.dbal.default_connection). EOT ) ->setName('propel:acl:init') ; } protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('verbose')) { $this->additionalPhingArgs[] = 'verbose'; } // Generate ACL model if (true == $result = $this->callPhing('om')) { $output->writeln(sprintf( '>> %20s Generated model classes from %s', $this->getApplication()->getKernel()->getBundle('PropelBundle')->getName(), 'acl_schema.xml' )); } else { $this->writeTaskError($output, 'om'); return 1; } // Prepare SQL directory $sqlDirectory = $this->getSqlDir(); $filesystem = new Filesystem(); $filesystem->remove($sqlDirectory); $filesystem->mkdir($sqlDirectory); if (true == $result = $this->callPhing('build-sql', array('propel.sql.dir' => $sqlDirectory))) { $this->writeSection( $output, '1 SQL file has been generated.' ); } else { $this->writeTaskError($output, 'build-sql'); return 2; } return parent::execute($input, $output); } protected function getFinalSchemas(KernelInterface $kernel, BundleInterface $bundle = null) { $aclSchema = new \SplFileInfo($kernel->locateResource('@PropelBundle/Resources/acl_schema.xml')); return array((string) $aclSchema => array($kernel->getBundle('PropelBundle'), $aclSchema)); } protected function getSqlDir() { return sprintf('%s/cache/%s/propel/acl/sql', $this->getApplication()->getKernel()->getRootDir(), $this->getApplication()->getKernel()->getEnvironment() ); } }