コード例 #1
0
 /**
  * Executes the command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return object|\Symfony\Component\Console\Output\OutputInterface
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = Tools::stripTableSchema(plural($input->getArgument('name')));
     if ($input->getOption('keep')) {
         $name = Tools::stripTableSchema($input->getArgument('name'));
     }
     $validator = new ViewValidator($name);
     if ($validator->fails()) {
         $message = $validator->getMessage();
         return $output->writeln('<error>' . $message . '</error>');
     }
     $data = ['isBootstrap' => $input->getOption('bootstrap'), 'isCamel' => $input->getOption('camel'), 'name' => $input->getArgument('name')];
     $generator = new ViewGenerator($this->describe, $data);
     $result = $generator->generate();
     $results = ['create' => $this->renderer->render('Views/create.tpl', $result), 'edit' => $this->renderer->render('Views/edit.tpl', $result), 'index' => $this->renderer->render('Views/index.tpl', $result), 'show' => $this->renderer->render('Views/show.tpl', $result)];
     $filePath = APPPATH . 'views/' . $name;
     $create = new File($filePath . '/create.php');
     $edit = new File($filePath . '/edit.php');
     $index = new File($filePath . '/index.php');
     $show = new File($filePath . '/show.php');
     $create->putContents($results['create']);
     $edit->putContents($results['edit']);
     $index->putContents($results['index']);
     $show->putContents($results['show']);
     $create->close();
     $edit->close();
     $index->close();
     $show->close();
     $message = 'The views folder "' . $name . '" has been created successfully!';
     return $output->writeln('<info>' . $message . '</info>');
 }
コード例 #2
0
 /**
  * Executes the command.
  *
  * @param  \Symfony\Component\Console\Input\InputInterface   $input
  * @param  \Symfony\Component\Console\Output\OutputInterface $output
  * @return object|\Symfony\Component\Console\Output\OutputInterface
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->addLibrary('wildfire');
     $template = $this->renderer->render('Libraries/Wildfire.tpl');
     $wildfire = new File(APPPATH . 'libraries/Wildfire.php');
     $wildfire->putContents($template);
     $wildfire->close();
     Tools::ignite();
     $message = 'Wildfire is now installed successfully!';
     return $output->writeln('<info>' . $message . '</info>');
 }
コード例 #3
0
 /**
  * Executes the command.
  * 
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @return object|OutputInterface
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fileName = $input->getOption('keep') ? ucfirst($input->getArgument('name')) : ucfirst(plural($input->getArgument('name')));
     $fileInformation = ['name' => $fileName, 'type' => 'controller', 'path' => APPPATH . 'controllers' . DIRECTORY_SEPARATOR . $fileName . '.php'];
     $validator = new Validator($input->getOption('doctrine'), $input->getOption('wildfire'), $input->getOption('camel'), $fileInformation);
     if ($validator->fails()) {
         $message = $validator->getMessage();
         return $output->writeln('<error>' . $message . '</error>');
     }
     $data = ['file' => $fileInformation, 'isCamel' => $input->getOption('camel'), 'name' => $input->getArgument('name'), 'title' => strtolower($fileName), 'type' => $validator->getLibrary()];
     $generator = new ControllerGenerator($this->describe, $data);
     $result = $generator->generate();
     $controller = $this->renderer->render('Controller.template', $result);
     $message = 'The controller "' . $fileInformation['name'] . '" has been created successfully!';
     $file = new File($fileInformation['path'], 'wb');
     $file->putContents($controller);
     $file->close();
     return $output->writeln('<info>' . $message . '</info>');
 }
コード例 #4
0
 /**
  * Executes the command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return object|\Symfony\Component\Console\Output\OutputInterface
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fileName = ucfirst(singular($input->getArgument('name')));
     $path = APPPATH . 'models' . DIRECTORY_SEPARATOR . $fileName . '.php';
     $info = ['name' => $fileName, 'type' => 'model', 'path' => $path];
     $validator = new ModelValidator($input->getOption('camel'), $info);
     if ($validator->fails()) {
         $message = $validator->getMessage();
         return $output->writeln('<error>' . $message . '</error>');
     }
     $data = ['file' => $info, 'isCamel' => $input->getOption('camel'), 'name' => $input->getArgument('name'), 'type' => $validator->getLibrary()];
     $generator = new ModelGenerator($this->describe, $data);
     $result = $generator->generate();
     $model = $this->renderer->render('Model.tpl', $result);
     $message = 'The model "' . $fileName . '" has been created successfully!';
     $file = new File($path);
     $file->putContents($model);
     $file->close();
     return $output->writeln('<info>' . $message . '</info>');
 }
コード例 #5
0
 /**
  * Executes the command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return object|\Symfony\Component\Console\Output\OutputInterface
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $layoutPath = APPPATH . 'views/layout';
     $data = [];
     $data['bootstrapContainer'] = '';
     $data['scripts'] = [];
     $data['styleSheets'] = [];
     $css = '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css';
     if (!is_dir('bower_components/font-awesome') && system('bower install font-awesome')) {
         $css = '<?php echo base_url(\'bower_components/font-awesome/css/font-awesome.min.css\'); ?>';
     }
     $data['styleSheets'][0] = $css;
     if ($input->getOption('bootstrap')) {
         $data['bootstrapContainer'] = 'container';
         $css = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css';
         $js = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.js';
         $jquery = 'https://code.jquery.com/jquery-2.1.1.min.js';
         if (!is_dir('bower_components/bootstrap') && system('bower install bootstrap')) {
             $css = '<?php echo base_url(\'bower_components/bootstrap/dist/css/bootstrap.min.css\'); ?>';
             $js = '<?php echo base_url(\'bower_components/bootstrap/dist/js/bootstrap.min.js\'); ?>';
             $jquery = '<?php echo base_url(\'bower_components/jquery/dist/jquery.min.js\'); ?>';
         }
         array_push($data['styleSheets'], $css);
         array_push($data['scripts'], $jquery);
         array_push($data['scripts'], $js);
     }
     if (!@mkdir($layoutPath, 0777, true)) {
         $message = 'The layout directory already exists!';
         return $output->writeln('<error>' . $message . '</error>');
     }
     $header = $this->renderer->render('Views/Layout/header.tpl', $data);
     $footer = $this->renderer->render('Views/Layout/footer.tpl', $data);
     $headerFile = new File($layoutPath . '/header.php');
     $footerFile = new File($layoutPath . '/footer.php');
     $headerFile->putContents($header);
     $footerFile->putContents($footer);
     $headerFile->close();
     $footerFile->close();
     $message = 'The layout folder has been created successfully!';
     return $output->writeln('<info>' . $message . '</info>');
 }
コード例 #6
0
 /**
  * Executes the command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return object|\Symfony\Component\Console\Output\OutputInterface
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     system('composer require doctrine/orm');
     $cli = $this->renderer->render('DoctrineCLI.tpl');
     $doctrine = new File(APPPATH . 'libraries/Doctrine.php');
     $template = $this->renderer->render('Libraries/Doctrine.tpl');
     $vendor = realpath('vendor');
     // Modifies the contents of vendor/bin/doctrine.php, creates the
     // Doctrine library and creates a "proxies" directory for lazy loading.
     file_put_contents($vendor . '/bin/doctrine.php', $cli);
     file_put_contents($vendor . '/doctrine/orm/bin/doctrine.php', $cli);
     $doctrine->putContents($template);
     $doctrine->close();
     $this->addLibrary('doctrine');
     if (!is_dir(APPPATH . 'models/proxies')) {
         mkdir(APPPATH . 'models/proxies');
         chmod(APPPATH . 'models/proxies', 0777);
     }
     $abstractCommandPath = $vendor . '/doctrine/orm/lib/Doctrine/ORM/' . 'Tools/Console/Command/SchemaTool/AbstractCommand.php';
     // Includes the Base Model class in Doctrine CLI
     $abstractCommand = file_get_contents($abstractCommandPath);
     $search = 'use Doctrine\\ORM\\Tools\\SchemaTool;';
     $replace = $search . "\n" . 'include BASEPATH . \'core/Model.php\';';
     $contents = $abstractCommand;
     $schemaTool = 'use Doctrine\\ORM\\Tools\\SchemaTool;';
     $coreModel = 'include BASEPATH . \'core/Model.php\';';
     if (strpos($abstractCommand, $schemaTool) !== false) {
         if (strpos($abstractCommand, $coreModel) === false) {
             $contents = str_replace($search, $replace, $abstractCommand);
         }
     }
     file_put_contents($abstractCommandPath, $contents);
     Tools::ignite();
     $message = 'Doctrine ORM is now installed successfully!';
     return $output->writeln('<info>' . $message . '</info>');
 }
コード例 #7
0
ファイル: Tools.php プロジェクト: NaszvadiG/combustor
 /**
  * "Ignites" the post installation process.
  * 
  * @return void
  */
 public static function ignite()
 {
     // Gets the config.php from application/config directory.
     $config = new File(APPPATH . 'config/config.php', 'wb');
     $search = ['$config[\'composer_autoload\'] = false;'];
     $replace = ['$config[\'composer_autoload\'] = realpath(\'vendor\') . \'/autoload.php\';'];
     // Removes the index.php from $config['index_page'].
     if (strpos($config->getContents(), '$config[\'index_page\'] = \'index.php\';') !== false) {
         array_push($search, '$config[\'index_page\'] = \'index.php\';');
         array_push($replace, '$config[\'index_page\'] = \'\';');
     }
     // Adds an encryption key from the configuration.
     if (strpos($config->getContents(), '$config[\'encryption_key\'] = \'\';') !== false) {
         array_push($search, '$config[\'encryption_key\'] = \'\';');
         array_push($replace, '$config[\'encryption_key\'] = \'' . md5('rougin') . '\';');
     }
     $config->putContents(str_replace($search, $replace, $config->getContents()));
     $config->close();
     // Gets the autoload.php from application/config directory.
     $autoload = new File(APPPATH . 'config/autoload.php', 'wb');
     // Gets currently included libraries.
     preg_match_all('/\\$autoload\\[\'libraries\'\\] = array\\((.*?)\\)/', $autoload->getContents(), $match);
     $libraries = explode(', ', end($match[1]));
     // Includes "session" library.
     if (!in_array('\'session\'', $libraries)) {
         array_push($libraries, '\'session\'');
     }
     $libraries = array_filter($libraries);
     // Includes the added libraries all back to autoload.php.
     $autoload->putContents(preg_replace('/\\$autoload\\[\'libraries\'\\] = array\\([^)]*\\);/', '$autoload[\'libraries\'] = array(' . implode(', ', $libraries) . ');', $autoload->getContents()));
     // Get currently included helpers
     preg_match_all('/\\$autoload\\[\'helper\'\\] = array\\((.*?)\\)/', $autoload, $match);
     $helpers = explode(', ', end($match[1]));
     // Include "form" helper
     if (!in_array('\'form\'', $helpers)) {
         array_push($helpers, '\'form\'');
     }
     // Include "inflector" helper
     if (!in_array('\'inflector\'', $helpers)) {
         array_push($helpers, '\'inflector\'');
     }
     // Include "url" helper
     if (!in_array('\'url\'', $helpers)) {
         array_push($helpers, '\'url\'');
     }
     $helpers = array_filter($helpers);
     // Include the added helpers all back to autoload.php
     $autoload->putContents(preg_replace('/\\$autoload\\[\'helper\'\\] = array\\([^)]*\\);/', '$autoload[\'helper\'] = array(' . implode(', ', $helpers) . ');', $autoload->getContents()));
     $autoload->close();
     // Creates a new .htaccess file if it does not exists.
     if (!file_exists('.htaccess')) {
         $htaccess = new File('.htaccess', 'wb');
         $htaccess->putContents(file_get_contents(__DIR__ . '/../Templates/Htaccess.template'));
         $htaccess->chmod(0777);
         $htaccess->close();
     }
     // Creates a configuration for the Pagination library.
     if (!file_exists(APPPATH . 'config/pagination.php')) {
         $pagination = new File(APPPATH . 'config/pagination.php', 'wb');
         $pagination->putContents(file_get_contents(__DIR__ . '/../Templates/Pagination.template'));
         $pagination->chmod(0664);
         $pagination->close();
     }
     return;
 }