Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implementation for AbsoluteUrlPackage::getUrl()
  • Loading branch information
inoryy committed Apr 19, 2013
commit 89c47e9b4fc385cb55fb8248ac2138cd149e790c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ public function __construct(RequestContext $context, $version = null, $format =

public function getUrl($path)
{
return null;
if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
return $path;
}

$url = ltrim($path, '/');
if ($baseUrl = $this->context->getBaseUrl()) {
$url = trim($baseUrl, '/').'/'.$url;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we are not leaving spaces between the contactenating .'s, thought i just saw @bschussek using them for his PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question!
I was under the same impression originally, but it's this way in other *Package classes and neither phpcsfixer nor scrutinizer seem to have caught that...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cordoval I was pushing a few old PRs recently that I probably forgot to scan for this convention change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bschussek sorry, i'm still confused. Is it $string.$string2 or $string . $string2?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$string.$string :)

}

// get scheme, host and port from RequestContext
// based on \Symfony\Component\Routing\Generator\UrlGenerator::doGenerate()
$schemeAuthority = '';
if ($host = $this->context->getHost()) {
$scheme = $this->context->getScheme();

$port = '';
if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
$port = ':'.$this->context->getHttpPort();
} elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
$port = ':'.$this->context->getHttpsPort();
}

$schemeAuthority .= $scheme.'://'.$host.$port;
}

$url = $schemeAuthority.'/'.$url;

$url = $this->applyVersion($url);

return $url;
}
}