/** * Find all bootatble instances and set it to object map */ public function compileBootableClasses() { // list app root's foreach ($this->appRoots as $app) { $app .= '/Apps/Controller/' . env_name; $files = File::listFiles($app, ['.php'], true); foreach ($files as $file) { // define full class name with namespace $class = 'Apps\\Controller\\' . env_name . '\\' . Str::cleanExtension($file); // check if class exists (must be loaded over autoloader), boot method exist and this is controller instanceof if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\\Core\\Arch\\Controller', true)) { $this->objects[] = $class; } } } // list widget root's foreach ($this->widgetRoots as $widget) { $widget .= '/Widgets/' . env_name; // widgets are packed in directory, classname should be the same with root directory name $dirs = Directory::scan($widget, GLOB_ONLYDIR, true); if (!Obj::isArray($dirs)) { continue; } foreach ($dirs as $instance) { $class = 'Widgets\\' . env_name . '\\' . $instance . '\\' . $instance; if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\\Core\\Arch\\Widget', true)) { $this->objects[] = $class; } } } }
/** * Find update files with sql queries */ public function findUpdateFiles() { // find all file with update sql queries between $dbVersion<->scriptVersion (dbVer <= x <= scriptVer) $all = File::listFiles('/Private/Database/Updates/', ['.php'], true); foreach ($all as $file) { $file = Str::cleanExtension(basename($file)); // $file="3.0.0-3.0.1" become to $start = 3.0.0,$end=3.0.1 list($start, $end) = explode('-', $file); // true: start <= db & script >= $end if (version_compare($this->dbVersion, $start) !== 1 && version_compare($this->scriptVersion, $end) !== -1) { $this->updateQueries[] = $file; } } sort($this->updateQueries); }
/** * Get poster thumbnail uri * @return null|string */ public function getPosterThumbUri() { $pName = $this->poster; if ($pName === null || Str::likeEmpty($pName)) { return null; } // remove extension, thumbs always in jpeg ;D $pName = Str::cleanExtension($pName); $path = '/upload/gallery/' . $this->id . '/thumb/' . $pName . '.jpg'; if (!File::exist($path)) { return null; } return $path; }