示例#1
0
文件: Main.php 项目: kingsj/core
 /**
  * Execute certain hook handle
  *
  * @return void
  */
 public function executeHookHandler()
 {
     foreach (\Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::getFixtures() as $fixture) {
         \XLite\Core\Database::getInstance()->loadFixturesFromYaml($fixture);
     }
     \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::removeFixtures();
 }
示例#2
0
 /**
  * Execute certain hook handle
  *
  * @return void
  */
 public function executeHookHandler()
 {
     $list = \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::getFixtures();
     if ($list) {
         \Includes\Utils\Operator::showMessage('', true, false);
         foreach ($list as $fixture) {
             $message = '...Load ' . substr($fixture, strlen(LC_DIR_ROOT));
             \Includes\Utils\Operator::showMessage($message, true, true);
             \Includes\Decorator\Utils\CacheManager::logMessage(PHP_EOL);
             \Includes\Decorator\Utils\CacheManager::logMessage($message);
             if (static::isYAML($fixture)) {
                 // Load YAML fixture
                 \XLite\Core\Database::getInstance()->loadFixturesFromYaml($fixture);
             } else {
                 // Load SQL queries
                 \Includes\Utils\Database::uploadSQLFromFile($fixture);
             }
             \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::removeFixtureFromList($fixture);
             if (\Includes\Decorator\Utils\CacheManager::isTimeExceeds(static::STEP_TTL)) {
                 break;
             }
         }
     }
     \Includes\Decorator\Utils\CacheManager::logMessage(PHP_EOL);
     \XLite\Core\Database::getEM()->clear();
 }
示例#3
0
 /**
  * Execute certain hook handle
  *
  * @return void
  */
 public function executeHookHandler()
 {
     // Postprocess step (Load fixtures)
     if (\Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::getFixtures()) {
         \Includes\Decorator\Utils\CacheManager::$skipStepCompletion = true;
     } else {
         \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::removeFixtures();
     }
 }
示例#4
0
/**
 * 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;
}
示例#5
0
 /**
  * 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);
         }
     }
 }