本文整理汇总了PHP中Net_URL2::getNormalizedURL方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_URL2::getNormalizedURL方法的具体用法?PHP Net_URL2::getNormalizedURL怎么用?PHP Net_URL2::getNormalizedURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_URL2
的用法示例。
在下文中一共展示了Net_URL2::getNormalizedURL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$cc = new \Console_CommandLine();
$cc->description = 'phinde URL processor';
$cc->version = '0.0.1';
$cc->addOption('force', array('short_name' => '-f', 'long_name' => '--force', 'description' => 'Always process URL, even when it did not change', 'action' => 'StoreTrue', 'default' => false));
$cc->addOption('showLinksOnly', array('short_name' => '-s', 'long_name' => '--show-links', 'description' => 'Only show which URLs were found', 'action' => 'StoreTrue', 'default' => false));
$cc->addArgument('url', array('description' => 'URL to process', 'multiple' => false));
$cc->addArgument('actions', array('description' => 'Actions to take', 'multiple' => true, 'optional' => true, 'choices' => array('index', 'crawl'), 'default' => array('index', 'crawl')));
try {
$res = $cc->parse();
} catch (\Exception $e) {
$cc->displayError($e->getMessage());
}
$url = $res->args['url'];
$url = Helper::addSchema($url);
$urlObj = new \Net_URL2($url);
$url = $urlObj->getNormalizedURL();
if (!Helper::isUrlAllowed($url)) {
Log::error("Domain is not allowed; not crawling");
exit(2);
}
try {
$actions = array();
foreach ($res->args['actions'] as $action) {
if ($action == 'crawl') {
$crawler = new Crawler();
$crawler->setShowLinksOnly($res->options['showLinksOnly']);
$actions[$action] = $crawler;
} else {
if ($action == 'index') {
$actions[$action] = new Indexer();
}
示例2: getNormalizedFileInfo
/**
* @param $path
* @param null $document
* @return array
* @throws \Exception
*/
public static function getNormalizedFileInfo($path, $document = null)
{
if ($document && $document instanceof Model\Document == false) {
throw new \Exception('$document has to be an instance of Document');
}
$fileInfo = array();
$hostUrl = Tool::getHostUrl();
if ($path[0] != '/') {
$fileInfo['fileUrl'] = $hostUrl . $document . "/{$path}";
//relative eg. ../file.css
} else {
$fileInfo['fileUrl'] = $hostUrl . $path;
}
$fileInfo['fileExtension'] = substr($path, strrpos($path, '.') + 1);
$netUrl = new \Net_URL2($fileInfo['fileUrl']);
$fileInfo['fileUrlNormalized'] = $netUrl->getNormalizedURL();
$fileInfo['filePathNormalized'] = PIMCORE_DOCUMENT_ROOT . str_replace($hostUrl, '', $fileInfo['fileUrlNormalized']);
return $fileInfo;
}
示例3: testNoUserinfoAndNormalize
/**
* Tests an URL with no userinfo and normalization
*
* Also: Regression test for Bug #20385
*
* @covers Net_URL2::getUserinfo
* @covers Net_URL2::normalize
* @covers Net_URL2::getNormalizedURL
* @return void
* @link https://pear.php.net/bugs/bug.php?id=20385
*/
public function testNoUserinfoAndNormalize()
{
$testUrl = 'http://www.example.com/';
$url = new Net_URL2($testUrl);
$this->assertFalse($url->getUserinfo());
$url->normalize();
$this->assertFalse($url->getUserinfo());
$this->assertEquals($testUrl, $url->getURL());
$this->assertEquals($testUrl, $url->getNormalizedURL());
}