private function jsCommon() { $params['url'] = PsUrl::current(); $params['userId'] = AuthManager::getUserIdOrNull(); $params['isAuthorized'] = AuthManager::isAuthorized(); $params['isDOA'] = PsSettings::DEVMODE_OR_ADMIN(); $params['isLogging'] = PsSettings::DEVMODE_OR_ADMIN(); $params['currentSubmitTimeout'] = ActivityWatcher::getWaitTime(); $params['tzOffset'] = PsTimeZone::inst()->getCurrentDateTimeZone()->getOffset(new DateTime()); $params['marker'] = AuthManager::getUserSessoinMarker(); $params['foldings'] = FoldedStorage::listEntitiesRel(); return $params; }
protected function registerPluginsImpl() { foreach (FoldedStorage::listFoldedTypes() as $foldingType) { $this->registerPluginImpl($foldingType); } $this->registerPluginImpl(''); }
/** * Основной метод, получающий абсолютный путь к классу. * * @param str $class * @return str - Путь к файлу */ private function getClassPathImpl($class) { /* @var $classPathDir AutoloadDir */ foreach ($this->DIRS as $classPathDir) { //ИЩЕМ КЛАСС $path = $classPathDir->getClassPath($class); if ($path) { /* * Мы нашли класс! * Если он отмечен, как исключённый для всех - сборосим список исключённых. * Могло так случиться, что класс загружался без подключённой директорией (например admin). */ if ($this->isCommonExcluded($class)) { $this->LOGGER->info("Class [{$class}] was marked as excluded, but now found in {$classPathDir}. Clearing excluded."); $this->cleanCommonExcluded(); } return $path; } } //ПОПРОБУЕМ ВОСПОЛЬЗОВАТЬСЯ ФОЛДИНГАМИ $path = FoldedStorage::tryGetEntityClassPath($class); if ($path) { $this->LOGGER->info("Class path for [{$class}] found with folded resources."); return $path; } //МЫ НЕ НАШЛИ НАШ КЛАСС В ПУТЯХ, А МОЖЕТ ОН ИСКЛЮЧЁН ДЛЯ ВСЕХ? if ($this->isCommonExcluded($class)) { $this->LOGGER->info("Class [{$class}] is common excluded."); return null; } //КЛАСС НЕ ЯВЛЯЕТСЯ КЛАССОМ СУЩНОСТИ ФОЛДИНГА. ПЕРЕСТРОИМ КЛАССПАСЫ ДЛЯ ЗАКЕШОРОВАННЫХ ДИРЕКТОРИЙ ИЛИ ОТМЕТИМ КЛАСС, КАК ИСКЛЮЧЁННЫЙ /* @var $classPathDir AutoloadDir */ foreach ($this->DIRS as $classPathDir) { if ($classPathDir->isRebuilded()) { //Данную директорию уже перезагружали, в ней класса точно нет continue; } //Если файл не найден, но при этом класспас не перестраивался, то необходимо поискать его заново $this->LOGGER->info("Class [{$class}] not excluded, need to check {$classPathDir} again."); $path = $classPathDir->rebuild()->getClassPath($class); if ($path) { //Ура, наши класс в одной из директорий $this->LOGGER->info("Class [{$class}] found for {$classPathDir} after rebuild."); return $path; } } $this->saveCommonExcluded($class); $this->LOGGER->info("Class [{$class}] is marked as excluded, null is returned."); return null; }
/** * В конструкторе зарегистрируем все страницы */ protected final function __construct() { //Инициализируем хранилище, чтобы честно замерять время создания регистрации самих экземпляров FoldedStorage::init(); $class = get_called_class(); $basic = __CLASS__ == $class; //Логгер $this->LOGGER = PsLogger::inst(__CLASS__); $this->LOGGER->info('USING {} STORAGE: {}', $basic ? 'SDK' : 'CUSTOM', $class); //Стартуем профайлер $this->PROFILER = PsProfiler::inst(__CLASS__); $this->PROFILER->start('Loading folding insts'); //Регистрируем фолдинги SDK $this->LOGGER->info(); $this->LOGGER->info('FOLDINGS SDK:'); $this->registerSdkFoldings(); //Если используем не SDK провайдер, вызываем регистратор if (!$basic) { $this->LOGGER->info(); $this->LOGGER->info('FOLDINGS PROJECT:'); $this->registerProjectFoldings(); } //Отсортируем фолдинги по идентификаторам ksort($this->FOLDINGS); //Останавливаем профайлер $sec = $this->PROFILER->stop(); //Логируем $this->LOGGER->info(); $this->LOGGER->info('COLLECTING TIME: {} sec', $sec->getTotalTime()); }
echo TestUtils::testProductivity(function () { FoldedStorage::getEntities('lib-s'); }, 200); br(); echo FoldedStorage::extractInfoFromClassName('PL_slib', $classPrefix, $entity); br(); echo $classPrefix; br(); echo $entity; die; $prefix = 'PL_math'; echo preg_match('/^[A-Z]+\\_/', $prefix, $matches); br(); print_r($matches); die; FoldedStorage::extractFoldedTypeAndSubtype('lib-xxxx-', $type, $subtype); echo "{$type}, {$subtype}"; die; class A { public static $a = array(); public static function test() { self::$a[] = '1'; } final function __construct($a) { } } class B extends A {
/** * КОНСТРУКТОР */ protected function __construct() { $this->CLASS = get_called_class(); $this->UNIQUE = self::unique($this->getFoldingType(), $this->getFoldingSubType()); $this->LOGGER = PsLogger::inst(__CLASS__ . '-' . $this->UNIQUE); $this->PROFILER = PsProfiler::inst(__CLASS__); $this->CLASS_PREFIX = FoldedStorage::getFoldingClassPrefix($this->UNIQUE); $this->SMARTY_PREFIX = FoldedStorage::getFoldingSourcePrefix($this->UNIQUE); $this->RESOURCE_TYPES_LINKED = array_intersect($this->RESOURCE_TYPES_ALLOWED, $this->RESOURCE_TYPES_LINKED); $this->RESOURCE_TYPES_CHECK_CHANGE = array_intersect($this->RESOURCE_TYPES_ALLOWED, $this->RESOURCE_TYPES_CHECK_CHANGE); //Получим текстовое описание $this->TO_STRING = $this->getTextDescr(); /* * Проверим, что заданы размеры обложки по умолчанию, если мы работаем с картинками */ if ($this->isImagesFactoryEnabled() && !$this->defaultDim()) { raise_error("Не заданы размеры обложки по умолчанию для фолдинга {$this}"); } //Разберём настройки хранения фолдингов в базе if ($this->isWorkWithTable()) { $dbs = explode('.', trim($this->foldingTable())); $this->TABLE_VIEW = array_get_value(0, $dbs); $this->TABLE = cut_string_start($this->TABLE_VIEW, 'v_'); $this->TABLE_COLUMN_IDENT = array_get_value(1, $dbs); $this->TABLE_COLUMN_STYPE = array_get_value(2, $dbs); check_condition(!!$this->TABLE && !!$this->TABLE_COLUMN_IDENT, "Некорректные настройки работы с базой для фолдинга {$this}"); if ($this->TABLE_COLUMN_STYPE) { check_condition($this->hasSubType(), "Некорректные настройки работы с базой. Фолдинг {$this} не имеет подтипа."); } } }