Example #1
0
 public function get($cUriComponent)
 {
     $sRewritedUrl = '';
     $aGetParams = [];
     if ($cUriComponent === self::URI_PATH) {
         $aTmpGetParams = ['basepath' => '', 'path' => ''];
         foreach ($this->_getConfByAscPriority() as $aConf) {
             if ($aConf[self::_FINAL_URL_COMPONENT][self::URI_BASEPATH]) {
                 $aRewritedUrl['basepath'] = $aConf[self::_FINAL_URL_COMPONENT][self::URI_BASEPATH];
                 $aTmpGetParams['basepath'] = $aConf[self::_GET_PARAM][self::URI_BASEPATH];
             }
             if ($aConf[self::_FINAL_URL_COMPONENT][self::URI_PATH]) {
                 $aRewritedUrl['path'] = $aConf[self::_FINAL_URL_COMPONENT][self::URI_PATH];
                 $aTmpGetParams['path'] = $aConf[self::_GET_PARAM][self::URI_PATH];
             }
         }
         if (!isset($aRewritedUrl['basepath'])) {
             throw new RuntimeException("Aucune base d'url n'a été réécrite");
         }
         $sRewritedUrl = $aRewritedUrl['basepath'] . (isset($aRewritedUrl['path']) ? $aRewritedUrl['path'] : '');
         $aGetParams = array_merge($aTmpGetParams['basepath'], $aTmpGetParams['path']);
     } else {
         foreach ($this->_getConfByAscPriority() as $aConf) {
             if ($aConf[self::_FINAL_URL_COMPONENT][$cUriComponent]) {
                 $sRewritedUrl = $aConf[self::_FINAL_URL_COMPONENT][$cUriComponent];
                 $aGetParams = $aConf[self::_GET_PARAM][$cUriComponent];
             }
         }
     }
     return Url::createFromUrl($sRewritedUrl)->setQuery($aGetParams);
 }
Example #2
0
 /**
  * Stocke l'URI pour laquelle il faut générer une route.
  * 
  * @param mixed $mUri URI sous la forme d'une chaîne de caractères ou d'un objet implémentant la méthode magique __toString().
  * @return Route
  * @throws InvalidArgumentException
  */
 public function setUri($mUri)
 {
     if (!is_string($mUri) && (is_object($mUri) && !method_exists($mUri, '__toString'))) {
         throw new InvalidArgumentException("Argument #1 doit être une chaîne de caractères.");
     }
     $this->_oUri = Url::createFromUrl((string) $mUri);
     // Si les conditions sont réunies pour matcher URI et définitions
     if ($this->_hasConditionToFind()) {
         // on recherche dans les dictionnaires les définitions correspondant à l'URI
         $this->_findUriDefinitions();
     }
     return $this;
 }