/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { if (file_exists($targetDir = $input->getArgument('path'))) { throw new \RuntimeException(sprintf('The directory "%s" already exists.', $targetDir)); } if (!file_exists($webDir = $input->getArgument('web_path'))) { mkdir($webDir, 0777, true); } $parameters = array('class' => $input->getArgument('name'), 'application' => strtolower($input->getArgument('name'))); $format = $input->getOption('yaml') ? 'yaml' : 'xml'; $filesystem = new Filesystem(); $filesystem->mirror(__DIR__ . '/../Resources/skeleton/application/' . $format, $targetDir); Mustache::renderDir($targetDir, $parameters); $filesystem->chmod($targetDir . '/console', 0777); $filesystem->chmod($targetDir . '/logs', 0777); $filesystem->chmod($targetDir . '/cache', 0777); $filesystem->rename($targetDir . '/Kernel.php', $targetDir . '/' . $input->getArgument('name') . 'Kernel.php'); $filesystem->rename($targetDir . '/Cache.php', $targetDir . '/' . $input->getArgument('name') . 'Cache.php'); $filesystem->copy(__DIR__ . '/../Resources/skeleton/web/front_controller.php', $file = $webDir . '/' . (file_exists($webDir . '/index.php') ? strtolower($input->getArgument('name')) : 'index') . '.php'); Mustache::renderFile($file, $parameters); $filesystem->copy(__DIR__ . '/../Resources/skeleton/web/front_controller_debug.php', $file = $webDir . '/' . strtolower($input->getArgument('name')) . '_dev.php'); Mustache::renderFile($file, $parameters); }
/** * @see Command * * @throws \InvalidArgumentException When the target directory does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { $this->callPhing('sql', array('propel.packageObjectModel' => false)); $filesystem = new Filesystem(); $basePath = $this->application->getKernel()->getRootDir() . DIRECTORY_SEPARATOR . 'propel' . DIRECTORY_SEPARATOR . 'sql'; $sqlMap = file_get_contents($basePath . DIRECTORY_SEPARATOR . 'sqldb.map'); foreach ($this->tempSchemas as $schemaFile => $schemaDetails) { $sqlFile = str_replace('.xml', '.sql', $schemaFile); $targetSqlFile = $schemaDetails['bundle'] . '-' . str_replace('.xml', '.sql', $schemaDetails['basename']); $targetSqlFilePath = $basePath . DIRECTORY_SEPARATOR . $targetSqlFile; $sqlMap = str_replace($sqlFile, $targetSqlFile, $sqlMap); $filesystem->remove($targetSqlFilePath); $filesystem->rename($basePath . DIRECTORY_SEPARATOR . $sqlFile, $targetSqlFilePath); $output->writeln(sprintf('Wrote SQL file for bundle "<info>%s</info>" in "<info>%s</info>"', $schemaDetails['bundle'], $targetSqlFilePath)); } file_put_contents($basePath . DIRECTORY_SEPARATOR . 'sqldb.map', $sqlMap); }