public static final function factory($class) { if (!rex_autoload::autoload($class)) { return $class; } return new $class(); }
public function addTestFolder($folder) { if (is_dir($folder)) { rex_autoload::addDirectory($folder); $this->testFoldersIterator->append(rex_finder::factory($folder)->recursive()->filesOnly()->getIterator()); } }
/** * @param string $dir */ private static function _addDirectory($dir) { if (!is_dir($dir)) { return; } if (!isset(self::$dirs[$dir])) { self::$dirs[$dir] = []; } $files = self::$dirs[$dir]; $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS)); foreach ($iterator as $path => $file) { /** @var SplFileInfo $file */ if (!$file->isFile() || !in_array($file->getExtension(), ['php', 'inc'])) { continue; } unset($files[$path]); $checksum = md5_file($path); if (isset(self::$dirs[$dir][$path]) && self::$dirs[$dir][$path] === $checksum) { continue; } self::$dirs[$dir][$path] = $checksum; self::$cacheChanged = true; $classes = self::findClasses($path); foreach ($classes as $class) { $class = strtolower($class); if (!isset(self::$classes[$class])) { self::$classes[$class] = $path; } } } foreach ($files as $path) { unset(self::$dirs[$path]); self::$cacheChanged = true; } }
/** * Deactivates a package. * * @return bool TRUE on success, FALSE on error */ public function deactivate() { $state = $this->checkDependencies(); if ($state === true) { $this->package->setProperty('status', false); $this->saveConfig(); } if ($state === true) { // reload autoload cache when addon is deactivated, // so the index doesn't contain outdated class definitions rex_autoload::removeCache(); if ($this->generatePackageOrder) { self::generatePackageOrder(); } $this->message = $this->i18n('deactivated', $this->package->getName()); return true; } $this->message = $this->i18n('no_deactivation', $this->package->getName()) . '<br />' . $this->message; return false; }
// add package path for fragment loading if (is_readable($folder . 'fragments')) { rex_fragment::addDirectory($folder . 'fragments' . DIRECTORY_SEPARATOR); } // add addon path for class-loading if (is_readable($folder . 'lib')) { rex_autoload::addDirectory($folder . 'lib'); } if (is_readable($folder . 'vendor')) { rex_autoload::addDirectory($folder . 'vendor'); } $autoload = $package->getProperty('autoload'); if (is_array($autoload) && isset($autoload['classes']) && is_array($autoload['classes'])) { foreach ($autoload['classes'] as $dir) { $dir = $package->getPath($dir); if (is_readable($dir)) { rex_autoload::addDirectory($dir); } } } } // now we actually include the addons logic foreach ($packageOrder as $packageId) { $package = rex_package::get($packageId); // include the addon itself if (is_readable($package->getPath(rex_package::FILE_BOOT))) { $package->includeFile(rex_package::FILE_BOOT); } } // ----- all addons configs included rex_extension::registerPoint(new rex_extension_point('PACKAGES_INCLUDED'));
// start output buffering as early as possible, so we can be sure // we can set http header whenever we want/need to ob_start(); ob_implicit_flush(0); mb_internal_encoding('UTF-8'); // deactivate session cache limiter session_cache_limiter(false); // set arg_separator to get valid html output if session.use_trans_sid is activated ini_set('arg_separator.output', '&'); require_once __DIR__ . '/lib/util/path.php'; rex_path::init($REX['HTDOCS_PATH'], $REX['BACKEND_FOLDER']); require_once rex_path::core('lib/autoload.php'); // register core-classes as php-handlers rex_autoload::register(); // add core base-classpath to autoloader rex_autoload::addDirectory(rex_path::core('lib')); rex_url::init($REX['HTDOCS_PATH'], $REX['BACKEND_FOLDER']); // start timer at the very beginning rex::setProperty('timer', new rex_timer($_SERVER['REQUEST_TIME_FLOAT'])); // add backend flag to rex rex::setProperty('redaxo', $REX['REDAXO']); // add core lang directory to rex_i18n rex_i18n::addDirectory(rex_path::core('lang')); // add core base-fragmentpath to fragmentloader rex_fragment::addDirectory(rex_path::core('fragments/')); // ----------------- FUNCTIONS require_once rex_path::core('functions/function_rex_globals.php'); require_once rex_path::core('functions/function_rex_other.php'); // ----------------- VERSION rex::setProperty('version', '5.0.0-alpha7'); $cacheFile = rex_path::cache('config.yml.cache');
public static function getTypeArray() { $return = []; $arr = ['value' => 'rex_yform_value_', 'validate' => 'rex_yform_validate_', 'action' => 'rex_yform_action_']; foreach ($arr as $arr_key => $arr_split) { foreach (rex_autoload::getClasses() as $class) { $exploded = explode($arr_split, $class); if (count($exploded) == 2) { $name = $exploded[1]; if ($name != 'abstract') { $class = new $class(); $d = $class->getDefinitions(); if (count($d) > 0) { $return[$arr_key][$d['name']] = $d; } } } } } return $return; }