/** * Execute certain hook handler * * @return void */ public function executeHookHandler() { // Remove old capsular directories if (\Includes\Decorator\Utils\CacheManager::isCapsular()) { $currentKey = \Includes\Decorator\Utils\CacheManager::getKey(); foreach (\Includes\Decorator\Utils\CacheManager::getCacheDirs(true) as $dir) { $list = glob(rtrim($dir, LC_DS) . '.*'); if ($list) { foreach ($list as $subdir) { list($main, $key) = explode('.', $subdir, 2); if ($key && $key != $currentKey) { \Includes\Utils\FileManager::unlinkRecursive($subdir); } } } } } \Includes\Decorator\Utils\CacheManager::cleanupCache(); // Load classes from "classes" (do not use cache) \Includes\Autoloader::switchLcAutoloadDir(); \Includes\Decorator\Plugin\Doctrine\Plugin\QuickData\Main::initializeCounter(); }
/** * Run handler for the current step * * :NOTE: method is public since it's called from * \Includes\Utils\Operator::executeWithCustomMaxExecTime() * * @return void */ public static function executeStepHandler1() { // Invoke plugins \Includes\Decorator\Utils\PluginManager::invokeHook(static::HOOK_BEFORE_CLEANUP); // Delete cache folders static::showStepMessage('Cleaning up the cache...'); static::cleanupCache(); static::showStepInfo(); // Load classes from "classes" (do not use cache) \Includes\Autoloader::switchLcAutoloadDir(); // Main procedure: build decorator chains static::showStepMessage('Building classes tree...'); static::getClassesTree(); static::showStepInfo(); // Invoke plugins \Includes\Decorator\Utils\PluginManager::invokeHook(static::HOOK_STEP_FIRST); }
/** * Check if class is already declared. * NOTE: this function does not use autoloader * * @param string $name Class name * * @return boolean */ public static function checkIfClassExists($name) { $result = class_exists($name, false); if (!$result) { $result = \Includes\Utils\FileManager::isFileReadable(\Includes\Autoloader::getLCAutoloadDir() . \Includes\Utils\Converter::getClassFile($name)); } return $result; }
/** * Get structures to save when module is disabled * * @param string $author Module author * @param string $name Module name * * @return array */ public static function getModuleProtectedStructures($author, $name) { $tables = array(); $columns = array(); $path = static::getAbsoluteDir($author, $name) . 'Model'; if (\Includes\Utils\FileManager::isExists($path)) { $filter = new \Includes\Utils\FileFilter($path, '/.*\\.php$/Si'); foreach ($filter->getIterator() as $path => $data) { // DO NOT call "getInterfaces()" after the "getFullClassName()" // DO NOT use reflection to get interfaces $interfaces = \Includes\Decorator\Utils\Tokenizer::getInterfaces($path); $class = \Includes\Decorator\Utils\Tokenizer::getFullClassName($path); // Do 'autoload' checking first since the class_exists tries to use autoloader // but fails into "cannot include file" warning when model class is not set to use (LC_Dependencies issue) if (\Includes\Autoloader::checkAutoload($class) && class_exists($class)) { // $reflectionClass = new \ReflectionClass($class); if ($class && is_subclass_of($class, '\\XLite\\Model\\AEntity')) { $class = ltrim($class, '\\'); $len = strlen(\Includes\Utils\Database::getTablesPrefix()); // DO NOT remove leading backslash in interface name if (in_array('\\XLite\\Base\\IDecorator', $interfaces)) { $parent = \Includes\Decorator\Utils\Tokenizer::getParentClassName($path); $parent = ltrim($parent, '\\'); $metadata = \XLite\Core\Database::getEM()->getClassMetadata($parent); $table = substr($metadata->getTableName(), $len); $tool = new \Doctrine\ORM\Tools\SchemaTool(\XLite\Core\Database::getEM()); $schema = $tool->getCreateSchemaSql(array($metadata)); foreach ((array) $metadata->reflFields as $field => $reflection) { $pattern = '/(?:, |\\()(' . $field . ' .+)(?:, [A-Za-z]|\\) ENGINE)/USsi'; if ($reflection->class === $class && !empty($metadata->fieldMappings[$field]) && preg_match($pattern, $schema[0], $matches)) { $columns[$table][$field] = $matches[1]; } } foreach ($metadata->associationMappings as $mapping) { if ($metadata->reflFields[$mapping['fieldName']]->class === $class) { if (isset($mapping['joinTable']) && $mapping['joinTable']) { $tables[] = substr($mapping['joinTable']['name'], $len); } elseif (isset($mapping['joinColumns']) && $mapping['joinColumns']) { foreach ($mapping['joinColumns'] as $col) { $pattern = '/(?:, |\\()(' . $col['name'] . ' .+)(?:, [A-Za-z]|\\) ENGINE)/USsi'; if (preg_match($pattern, $schema[0], $matches)) { $columns[$table][$col['name']] = $matches[1]; } } } } } } elseif (\XLite\Core\Database::getRepo($class)->canDisableTable()) { $tables[] = substr(\XLite\Core\Database::getEM()->getClassMetadata($class)->getTableName(), $len); $metadata = \XLite\Core\Database::getEM()->getClassMetadata($class); foreach ($metadata->associationMappings as $mapping) { if (isset($mapping['joinTable']) && $mapping['joinTable']) { $tables[] = substr($mapping['joinTable']['name'], $len); } } } } } } } return array('tables' => $tables, 'columns' => $columns); }
define('LC_DIR_BACKUP', LC_DIR_VAR . 'backup' . LC_DS); define('LC_DIR_DATA', LC_DIR_VAR . 'data' . LC_DS); define('LC_DIR_TMP', LC_DIR_VAR . 'tmp' . LC_DS); define('LC_DIR_LOCALE', LC_DIR_VAR . 'locale'); define('LC_DIR_DATACACHE', LC_DIR_VAR . 'datacache'); define('LC_DIR_LOG', LC_DIR_VAR . 'log' . LC_DS); define('LC_DIR_CACHE_IMAGES', LC_DIR_VAR . 'images' . LC_DS); define('LC_DIR_SERVICE', LC_DIR_FILES . 'service' . LC_DS); define('LC_OS_WINDOWS', 'WIN' === strtoupper(substr(PHP_OS, 0, 3))); // Disabled xdebug coverage for Selenium-based tests [DEVELOPMENT PURPOSE] if (isset($_COOKIE) && !empty($_COOKIE['no_xdebug_coverage']) && function_exists('xdebug_stop_code_coverage')) { @xdebug_stop_code_coverage(); } // Autoloading routines require_once LC_DIR_INCLUDES . 'Autoloader.php'; \Includes\Autoloader::registerAll(); // Fire the error if LC is not installed if (!defined('XLITE_INSTALL_MODE')) { \Includes\ErrorHandler::checkIsLCInstalled(); } // So called "developer" mode. Set it to "false" in production mode! define('LC_DEVELOPER_MODE', (bool) \Includes\Utils\ConfigParser::getOptions(array('performance', 'developer_mode'))); // Correct error handling mode ini_set('display_errors', LC_DEVELOPER_MODE); // Fatal error and exception handlers register_shutdown_function(array('\\Includes\\ErrorHandler', 'shutdown')); set_exception_handler(array('\\Includes\\ErrorHandler', 'handleException')); @umask(00); require_once LC_DIR_INCLUDES . 'prepend.php'; // Safe mode if (!defined('XLITE_INSTALL_MODE')) {