@ 2015-10-09T18:19:46Z <?php
namespace PortlandLabs\DomainMapper\Url;
use Concrete\Core\Url\Components\Path;
use Concrete\Core\Url\Resolver\PathUrlResolver;
use Concrete\Core\Url\Resolver\UrlResolverInterface;
use PortlandLabs\DomainMapper\Map\DomainMap;
/**
* Class Resolver
* URL Resolver for handling domain mapped urls, this will intercept mapped paths and alter the outputted links to
* remove the prefix and set the proper host.
*
* @package PortlandLabs\DomainMapper\Url
*/
class Resolver implements UrlResolverInterface
{
public function resolve(array $arguments, $resolved = null)
{
$args = $arguments;
$path = array_shift($args);
/** @var DomainMap $map */
$map = \Core::make('domain_mapper/config_map');
if ($path instanceof \Page) {
$path = $path->getCollectionPath();
$arguments[0] = $path;
}
if (is_scalar($path) && $path) {
$path = (string)$path;
$resolved_url = $resolved;
if (!$resolved) {
/** @var PathUrlResolver $path_resolver */
$path_resolver = \URL::getResolver('concrete.path');
$resolved_url = $path_resolver->resolve($arguments);
}
$url = $resolved_url;
if ($url) {
if ($prefix = $map->getPath($url->getHost())) {
$prefix_path = new Path($prefix);
$real_path = $url->getPath();
if (substr(strtolower($real_path), 0, strlen($prefix_path)) === strtolower($prefix_path)) {
$relative_path = $real_path->getRelativePath($prefix_path);
$url = $url->setPath($relative_path);
} else {
$url = $url->setHost(\Config::get('concrete.seo.canonical_host'));
}
return $url;
}
if ($domain = $map->getDomain($url->getPath())) {
$map_path = new Path(rtrim($map->getPath($domain), '/'));
$url_path = new Path(rtrim($url->getPath(), '/'));
foreach ($map_path->toArray() as $key => $path_node) {
$url_path->offsetUnset($key);
}
$url = $url->setPath($url_path);
$url = $url->setHost($domain);
return $url;
}
}
}
return $resolved;
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.7 Fatal error: Uncaught Error: Interface "Concrete\Core\Url\Resolver\UrlResolverInterface" not found in /in/sJA4Z:16
Stack trace:
#0 {main}
thrown in /in/sJA4Z on line 16
Process exited with code 255 . Output for 7.4.0 - 7.4.33 Fatal error: Uncaught Error: Interface 'Concrete\Core\Url\Resolver\UrlResolverInterface' not found in /in/sJA4Z:16
Stack trace:
#0 {main}
thrown in /in/sJA4Z on line 16
Process exited with code 255 . Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 Fatal error: Interface 'Concrete\Core\Url\Resolver\UrlResolverInterface' not found in /in/sJA4Z on line 16
Process exited with code 255 . Output for 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 Fatal error: Interface 'Concrete\Core\Url\Resolver\UrlResolverInterface' not found in /in/sJA4Z on line 17
Process exited with code 255 . preferences:dark mode live preview
236.08 ms | 402 KiB | 377 Q