/** * Applies all registered searchAndReplace operations. * * @return void */ protected function applySearchAndReplaceOperations() { foreach (Files::getRecursiveDirectoryGenerator($this->targetPackageData['path'], null, true) as $pathAndFilename) { $pathInfo = pathinfo($pathAndFilename); if (!isset($pathInfo['filename'])) { continue; } if (strpos($pathAndFilename, 'Migrations/Code') !== false) { continue; } foreach ($this->operations['searchAndReplace'] as $operation) { list($search, $replacement, $filter, $regularExpression) = $operation; if (is_array($filter)) { if ($filter !== array() && (!isset($pathInfo['extension']) || !in_array($pathInfo['extension'], $filter, true))) { continue; } } elseif (substr($pathAndFilename, -strlen($filter)) !== $filter) { continue; } Tools::searchAndReplace($search, $replacement, $pathAndFilename, $regularExpression); } } }
/** * Initialize the manager: read package information and register migrations. * * @return void */ protected function initialize() { if ($this->packagesData !== null) { return; } $this->packagesData = Tools::getPackagesData($this->packagesPath); $this->migrations = array(); foreach ($this->packagesData as $packageKey => $packageData) { $this->registerMigrationFiles(Files::concatenatePaths(array($this->packagesPath, $packageData['category'], $packageKey))); } ksort($this->migrations); }