2017 © Pedro Peláez
 

library querylist-absolute-url

QueryList Plugin: Converting relative urls to absolute.QueryList插件:转换URL相对路径到绝对路径.

image

jaeger/querylist-absolute-url

QueryList Plugin: Converting relative urls to absolute.QueryList插件:转换URL相对路径到绝对路径.

  • Friday, December 22, 2017
  • by jae
  • Repository
  • 1 Watchers
  • 3 Stars
  • 703 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 14 % Grown

The README.md

QueryList-AbsoluteUrl

QueryList Plugin: Converting relative urls to absolute., (*1)

QueryList插件:转换URL相对路径到绝对路径., (*2)

QueryList:https://github.com/jae-jae/QueryList, (*3)

Installation for QueryList4

composer require jaeger/querylist-absolute-url

API

  • absoluteUrl($baseUrl): Convert Page All Url to Absolute Url,return QueryList
  • absoluteUrlHelper($baseUrl,$relativeUrl): Convert Helper Function,return string

Installation options

QueryList::use(AbsoluteUrl::class,$opt1,$opt2) - $opt1:absoluteUrl function alias. - $opt2:absoluteUrlHelper function alias., (*4)

Usage

  • Installation Plugin
use QL\QueryList;
use QL\Ext\AbsoluteUrl;

$ql = QueryList::getInstance();
$ql->use(AbsoluteUrl::class);
//or Custom function name
$ql->use(AbsoluteUrl::class,'absoluteUrl','absoluteUrlHelper');
  • Convert All Link
$data = $ql->get('https://toutiao.io/')
    ->absoluteUrl('https://toutiao.io/')
    ->find('a')->attrs('href');

print_r($data);

Out:, (*5)

Array
(
    [0] => https://toutiao.io/
    [1] => https://toutiao.io/explore
    [2] => https://toutiao.io/posts/hot/7
    [3] => https://toutiao.io/contribute
    [4] => https://toutiao.io/account/subscriptions
    //....
)
  • Convert Helper
$data = $ql->rules([
    'link' => ['a','href']
])->get('https://toutiao.io/')->query()->getData(function ($item) use($ql){
    $item['link'] = $ql->absoluteUrlHelper('https://toutiao.io/',$item['link']);
    return $item;
});

print_r($data);

Out:, (*6)

Array
(
    [0] => Array
        (
            [link] => https://toutiao.io/
        )
    [1] => Array
        (
            [link] => https://toutiao.io/explore
        )
    [2] => Array
        (
            [link] => https://toutiao.io/posts/hot/7
        )
    [3] => Array
        (
            [link] => https://toutiao.io/contribute
        )
    [4] => Array
        (
            [link] => https://toutiao.io/account/subscriptions
        )
    //...
)

The Versions

22/12 2017

dev-master

9999999-dev

QueryList Plugin: Converting relative urls to absolute.QueryList插件:转换URL相对路径到绝对路径.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jaeger

22/12 2017

4.0.1

4.0.1.0

QueryList Plugin: Converting relative urls to absolute.QueryList插件:转换URL相对路径到绝对路径.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jaeger

26/09 2017

4.0.0

4.0.0.0

QueryList Plugin: Converting relative urls to absolute.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jaeger