Exemplo n.º 1
0
 /**
  * Get contents of bin/db.sql files
  * @return string
  */
 public static function getGoalSQL()
 {
     $paths = \Difra\Plugger::getPaths();
     $paths[] = DIR_FW;
     $paths[] = DIR_ROOT;
     $tables = [];
     foreach ($paths as $path) {
         if (is_readable($path . '/bin/db.sql')) {
             $tables[] = file_get_contents($path . '/bin/db.sql');
         }
         if (is_dir($path . '/bin/db')) {
             $files = scandir($path . '/bin/db');
             if (!empty($files)) {
                 foreach ($files as $file) {
                     if (is_readable($path . '/bin/db/' . $file) and $file[0] !== '.') {
                         $tables[] = file_get_contents($path . '/bin/db/' . $file);
                     }
                 }
             }
         }
     }
     return implode("\n", $tables);
 }
Exemplo n.º 2
0
 /**
  * Find all possible instances for selected resource
  * Warning: this is slow! Do not use it except for administrator area or cron scripts etc.
  * @return array|bool
  */
 public function findInstances()
 {
     $parents = [DIR_FW . $this->type, DIR_ROOT . $this->type, DIR_SITE . $this->type];
     $paths = Plugger::getPaths();
     if (!empty($paths)) {
         foreach ($paths as $dir) {
             $parents[] = "{$dir}/{$this->type}";
         }
     }
     if (empty($parents)) {
         return false;
     }
     $instances = [];
     foreach ($parents as $path) {
         if (!is_dir($path)) {
             continue;
         }
         $dir = opendir($path);
         while (false !== ($subdir = readdir($dir))) {
             if ($subdir[0] != '.' and is_dir($path . '/' . $subdir)) {
                 $instances[$subdir] = 1;
             }
         }
     }
     return array_keys($instances);
 }
Exemplo n.º 3
0
 /**
  * Get list of controllers directories
  * @return string[]
  */
 public static function getControllerPaths()
 {
     static $controllerDirs = null;
     if (!is_null($controllerDirs)) {
         return $controllerDirs;
     }
     $controllerDirs = Plugger::getPaths();
     $controllerDirs = array_merge([DIR_SITE, DIR_ROOT, DIR_FW], $controllerDirs);
     foreach ($controllerDirs as $k => $v) {
         $controllerDirs[$k] = $v . 'controllers/';
     }
     return $controllerDirs;
 }