/** * Prepare the fixtures: the list of yaml files for uploading to the database * * @param array $params Database access data and other parameters * @param bool $silentMode Do not display any output during installing * * @return bool */ function doPrepareFixtures(&$params, $silentMode = false) { global $lcSettings; $result = true; if (!$silentMode) { echo '<div style="text-align: left; margin-bottom: 20px;">' . xtr('Preparing data for cache generation...'); } $enabledModules = array(); $moduleYamlFiles = array(); foreach ((array) glob(LC_DIR_MODULES . '*', GLOB_ONLYDIR) as $authorDir) { $author = basename($authorDir); foreach ((array) glob(LC_DIR_MODULES . $author . '/*/Main.php') as $f) { $moduleName = basename(dirname($f)); $enabledModules[$author][$moduleName] = intval(!empty($lcSettings['enable_modules'][$author]) && in_array($moduleName, $lcSettings['enable_modules'][$author])); $dir = 'classes' . LC_DS . 'XLite' . LC_DS . 'Module' . LC_DS . $author . LC_DS . $moduleName; $moduleFile = $dir . LC_DS . 'install.yaml'; if (file_exists(LC_DIR_ROOT . $moduleFile)) { $moduleYamlFiles[] = $moduleFile; } foreach ((array) glob(LC_DIR_ROOT . $dir . LC_DIR . 'install_*.yaml') as $translationFile) { if (file_exists(LC_DIR_ROOT . $translationFile) && is_file(LC_DIR_ROOT . $translationFile)) { $moduleYamlFiles[] = $translationFile; } } } } sort($moduleYamlFiles, SORT_STRING); \Includes\Utils\ModulesManager::saveModulesToFile($enabledModules); // Generate fixtures list $yamlFiles = $lcSettings['yaml_files']['base']; foreach ($moduleYamlFiles as $f) { // Add module fixtures $yamlFiles[] = $f; } if (!empty($params['demo'])) { // Add demo dump to the fixtures foreach ($lcSettings['yaml_files']['demo'] as $f) { $yamlFiles[] = $f; } } // Remove fixtures file (if exists) \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::removeFixtures(); // Add fixtures list foreach ($yamlFiles as $file) { \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::addFixtureToList($file); } if (!$silentMode) { echo status($result) . '</div>'; } return $result; }
/** * Add module's install.yaml file to the fixtures list file * * @param string $author Module author * @param string $name Module name * * @return void */ protected static function addModuleYamlFile($author, $name) { $dir = 'classes' . LC_DS . LC_NAMESPACE . LC_DS . 'Module' . LC_DS . $author . LC_DS . $name; $file = $dir . LC_DS . 'install.yaml'; if (\Includes\Utils\FileManager::isFileReadable($file)) { \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::addFixtureToList($file); } foreach ((array) glob($dir . LC_DS . 'install_*.yaml') as $translationFile) { if (\Includes\Utils\FileManager::isFileReadable($translationFile)) { \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::addFixtureToList($translationFile); } } }