Ejemplo n.º 1
0
 /**
  * Load url rewrite entity by request_path
  *
  * @param array $paths
  * @return Enterprise_UrlRewrite_Model_Url_Rewrite
  */
 public function loadByRequestPath($paths)
 {
     $this->setId(null);
     $rewriteRows = $this->_getResource()->getRewrites($paths);
     $matchers = $this->_factory->getSingleton('enterprise_urlrewrite/system_config_source_matcherPriority')->getRewriteMatchers();
     foreach ($matchers as $matcherIndex) {
         $matcher = $this->_factory->getSingleton($this->_factory->getConfig()->getNode(sprintf(self::REWRITE_MATCHERS_MODEL_PATH, $matcherIndex), 'default'));
         foreach ($rewriteRows as $row) {
             if ($matcher->match($row, $paths['request'])) {
                 $this->setData($row);
                 break 2;
             }
         }
     }
     $this->_afterLoad();
     $this->setOrigData();
     $this->_hasDataChanges = false;
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Fetch rewrite matchers names sorted by priority
  *
  * @return mixed
  *
  * @throws Mage_Core_Exception
  */
 public function getRewriteMatchers()
 {
     if (!empty($this->_matchersOrder)) {
         return $this->_matchersOrder;
     }
     $nodes = $this->_factory->getConfig()->getNode(Enterprise_UrlRewrite_Model_Url_Rewrite::REWRITE_MATCHERS_PATH);
     foreach ($nodes->children() as $node) {
         $priority = (int) $node->priority;
         if (isset($this->_matchersOrder[$priority])) {
             throw new Mage_Core_Exception($this->_factory->getHelper('enterprise_urlrewrite')->__('URL matcher "%s" has same priority as "%s".', $node->getName(), $this->_matchersOrder[$priority]));
         }
         $this->_matchersOrder[$priority] = $node->getName();
     }
     ksort($this->_matchersOrder);
     return $this->_matchersOrder;
 }