Esempio n. 1
0
 public function configure()
 {
     parent::configure();
     $this->_slot = new Slot();
     $this->_slot->setTemplateDir($this->_view->getTemplatesPath());
     $this->_slot->setCompileDir(DC::getEnvironment()->getTmpRoot() . 'templates/' . DC::getApplication()->getName() . '/');
     $fs = new FSService();
     DC::getAutoloader()->registerSharedPath(DC::getEnvironment()->getUserClassesRoot() . 'helpers');
     if ($files = $fs->in(DC::getEnvironment()->getUserClassesRoot() . 'helpers')->find('*Block.php')) {
         foreach ($files as $file) {
             $this->_slot->registerBlock(Inflector::underscore(substr($file, strrpos($file, DIRECTORY_SEPARATOR) + 1, -9)), '\\');
         }
     }
 }
Esempio n. 2
0
 public static function onPostPackageInstall(CommandEvent $event)
 {
     $projectRoot = realpath(__DIR__ . '/../../../..') . '/';
     $packageRoot = __DIR__ . '/';
     $appRoot = $projectRoot . 'app/Admin/';
     $io = $event->getIO();
     if ($io->askConfirmation('Would you like to install admin panel? (Y/n) ', true)) {
         if (!is_dir($projectRoot . 'app')) {
             die('Solve project is not found in ' . $projectRoot . ', exiting...');
         }
         $name = $io->ask('Enter the app name (admin): ', 'admin');
         $kernel = Kernel::getMainInstance();
         $appRoot = $projectRoot . 'app/' . ucfirst($name) . '/';
         $kernel->getEnvironment()->setProjectRoot($projectRoot);
         $config = DC::getProjectConfig();
         while ($name && $config->get('applications/' . $name)) {
             $name = $io->ask('Application exists, specify other name(or type exit): ');
         }
         $config->set('applications/' . $name, $name);
         $config->save();
     }
     if ($io->askConfirmation('Would you like to update assets? (Y/n) ', true)) {
         FSService::makeWritable($appRoot);
         FSService::makeWritable($projectRoot . 'web/admin/');
         FSService::copyRecursive($packageRoot . 'app/', $appRoot);
         FSService::copyRecursive($packageRoot . 'assets/', $projectRoot . 'web/admin/');
         exec('cd ' . $projectRoot . 'web/admin/ && npm install');
     }
 }
Esempio n. 3
0
 public function tmpFileAction()
 {
     if ($path = $this->request->getVar('p')) {
         if (!FSService::showFileAndExit(DC::getEnvironment()->getTmpRoot() . $path)) {
             $response = new Response('<h1>Requested content not found</h1>', 404);
             $response->send();
             die;
         }
     }
 }
Esempio n. 4
0
 public function buildTestStructure()
 {
     FSService::makeWritable(array(__DIR__ . '/project/app/Frontend/Controllers', __DIR__ . '/project/app/Frontend/Views', __DIR__ . '/project/app/Admin', __DIR__ . '/project/src/classes', __DIR__ . '/project/src/db', __DIR__ . '/project/src/helpers', __DIR__ . '/project/src/libs', __DIR__ . '/project/tmp/log', __DIR__ . '/project/tmp/cache'));
     $pdo = new \PDO('mysql:host=127.0.0.1', 'root', 'root');
     $pdo->query('create database if not exists test_project_db');
 }
Esempio n. 5
0
 public static function getImageInfo($path)
 {
     if (!is_file($path)) {
         return null;
     }
     $image_info = array();
     list($width, $height, $type, $attr) = getimagesize($path, $image_info);
     $info = FSService::getFileInfo($path);
     $info['width'] = $width;
     $info['height'] = $height;
     return $info;
 }
Esempio n. 6
0
File: Slot.php Progetto: solve/slot
 /**
  * @param string $compileDir
  */
 public function setCompileDir($compileDir)
 {
     $this->_compileDir = $compileDir;
     $this->_tplVars = array();
     FSService::makeWritable($this->_compileDir);
 }
Esempio n. 7
0
 public function getModelValue($storagePath, $aliasInfo)
 {
     $filesToInfo = GLOB($storagePath . '*', GLOB_MARK);
     $value = array();
     foreach ($filesToInfo as $file) {
         if (is_dir($file)) {
             continue;
         }
         $fileInfo = FSService::getFileInfo($file);
         if (!empty($aliasInfo['sizes'])) {
             foreach ($aliasInfo['sizes'] as $sizeAlias => $sizeInfo) {
                 $fileInfo[$sizeAlias] = FSService::getFileInfo($storagePath . $sizeAlias . '/' . $fileInfo['full_name']);
             }
         }
         $value[] = $fileInfo;
     }
     return empty($aliasInfo['multiple']) && count($value) ? $value[0] : $value;
 }
Esempio n. 8
0
 /**
  * Dumps current database data to YML files
  * @param string|array $models
  */
 public function dataDump($models = null)
 {
     if (!empty($models)) {
         if (!is_array($models)) {
             $models = array($models);
         }
     } else {
         $models = array_keys($this->_structures);
     }
     $data_dir = $this->_storagePath . 'data/';
     FSService::makeWritable($data_dir);
     foreach ($models as $model) {
         $model = ucfirst($model);
         $file_name = $data_dir . strtolower($model) . '.yml';
         if (!isset($this->_structures[$model])) {
             continue;
         }
         if (is_file($file_name)) {
             unlink($file_name);
         }
         $data = QC::create($this->_structures[$model]['table'])->execute();
         file_put_contents($file_name, Yaml::dump($data, 6, 2));
     }
 }
Esempio n. 9
0
 public static function tearDownAfterClass()
 {
     DBOperator::getInstance()->dropDB(self::$_DBName);
     FSService::unlinkRecursive(self::$_storagePath);
 }
Esempio n. 10
0
 protected function createCV($params)
 {
     $appPath = DC::getEnvironment()->getApplicationRoot() . $params['app'];
     FSService::makeWritable($appPath . '/Views/' . strtolower($params['name']));
     FSService::makeWritable($appPath . '/Controllers/');
     $this->safeCreateFromTemplate($appPath . '/Controllers/' . $params['name'] . 'Controller.php', '_controller', $params);
     $this->safeCreateFromTemplate($appPath . '/Views/' . strtolower($params['name']) . '/default.slot', '_view_default', $params);
 }
Esempio n. 11
0
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     FSService::unlinkRecursive(__DIR__ . '/upload');
 }