Пример #1
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ('development' != $input->getArgument('environment') && 'production' != $input->getArgument('environment')) {
         return $output->writeln($input->getArgument('environment') . ' environment not found');
     }
     $jsMinifier = new JS();
     $cssMinifier = new CSS();
     $output->writeln('Building environment: ' . $input->getArgument('environment'));
     $output->write('Generating JavaScript build file...');
     $jsFiles = FileSystem::listDirectoryRecursive(Application::webRoot() . '/js', '/^.+\\.js$/i');
     $buildFile = fopen(Application::webRoot() . '/min/build.js', 'w');
     foreach ($jsFiles as $filePath) {
         fwrite($buildFile, file_get_contents($filePath) . "\n\n");
     }
     fclose($buildFile);
     $output->writeln('done');
     $output->write('Shrinking JavaScript...');
     $jsMinifier->add(Application::webRoot() . '/min/build.js');
     $jsMinifier->minify(Application::webRoot() . '/min/build.min.js');
     $output->writeln('done');
     $output->write('Compiling less files...');
     $less = new \lessc();
     $less->compileFile(Application::webRoot() . '/media/importer.less', Application::webRoot() . '/min/build.css');
     $output->writeln('done');
     $output->write('Shrinking css files...');
     $cssMinifier->add(Application::webRoot() . '/min/build.css');
     $cssMinifier->minify(Application::webRoot() . '/min/build.min.css');
     $output->writeln('done');
     return null;
 }
Пример #2
0
 /**
  * @return $this
  */
 private function applyHelpers()
 {
     $this->response->getLayout()->getEngine()->addHelper('statistics', function () {
         return 'Time: ' . Application::stats()->getTime() . ' Memory: ' . Application::stats()->getMemory() . ' Peak memory: ' . Application::stats()->getMemoryPeak();
     });
     $this->response->getLayout()->statistics = static::stats();
     return $this;
 }
Пример #3
0
 /**
  * @return View
  */
 public function getLayout()
 {
     return Application::response()->getLayout();
 }
Пример #4
0
 /**
  * Saves the current model
  *
  * @return bool
  */
 public function save()
 {
     $data = get_object_vars($this);
     unset($data['dateUpdate']);
     if (is_null($this->id)) {
         unset($data['id']);
         $data['dateCreate'] = date(Application::config('db.dateFormat'));
         return Application::getDb()->insert(static::tableName(), $data);
     }
     unset($data['dateCreate']);
     return Application::getDb()->update(static::tableName(), $data);
 }