protected function processRule(Rule $rule, $destination) { $sourceFile = dirname($destination) . DS . $rule->getSource(); $source = ""; if (is_file($sourceFile) && is_readable($sourceFile)) { $source = file_get_contents($sourceFile); } foreach ($rule->getRuleCollection() as $regex) { $source = preg_replace($regex[0], $regex[1], $source); } @$this->writeFile($destination, $source); }
public function doReadRules($rules, Rule $rule) { if (!is_array($rules)) { return; } if (!isset($rules["replace"]) || !is_array($rules["replace"])) { return; } foreach ($rules["replace"] as $replacement) { if (count($replacement) == 2) { $rule->addRule($replacement[0], $replacement[1]); } } }