/**
  * Resolve url's from any type of input.
  *
  * This method MUST either return a `\League\URL\URL` when a url is resolved
  * or null when a url cannot be resolved.
  *
  * If the arguments list contains a page object, we will use that to determine the canonical URL
  *
  * @param array                    $arguments A list of the arguments
  * @param \League\URL\URLInterface $resolved
  *
  * @return \League\URL\URLInterface
  */
 public function resolve(array $arguments, $resolved = null)
 {
     if ($resolved) {
         // We don't need to do any post processing on urls.
         return $resolved;
     }
     $page = null;
     foreach ($arguments as $key => $argument) {
         if ($argument instanceof Page) {
             $page = $argument;
             break;
         }
     }
     if ($page) {
         unset($arguments[$key]);
     }
     $args = $arguments;
     $path = array_shift($args);
     if (is_scalar($path) || is_object($path) && method_exists($path, '__toString')) {
         $path = rtrim($path, '/');
         $url = $this->canonical->resolve([$page]);
         $url = $this->handlePath($url, $path, $args);
         return $url;
     }
     return null;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function resolve(array $arguments, $resolved = null)
 {
     if ($resolved) {
         // We don't need to do any post processing on urls.
         return $resolved;
     }
     $args = $arguments;
     $path = array_shift($args);
     if (is_scalar($path) || is_object($path) && method_exists($path, '__toString')) {
         $path = rtrim($path, '/');
         $url = $this->canonical->resolve(array());
         $url = $this->handlePath($url, $path, $args);
         return $url;
     }
     return null;
 }