- Some more documentation made / fixed
This commit is contained in:
1 parent
46535c2734
commit
58f73d914b
9 files changed
+49
-41
No files matched your search
@@ -4,7 +4,7 @@ namespace Picea\Extension;
|
||||
|
||||
use Picea\Compiler\Context;
|
||||
|
||||
class UrlExtension implements Extension {
|
||||
class UrlExtension implements Extension, FunctionExtension {
|
||||
|
||||
public const URLIZE_PATTERN_URL = <<<PATTERN
|
||||
~(?<!href=['"])https?://[\w/._\-&?]*(?!</a>)(?=[^\w/._\-&])~s
|
||||
@@ -24,10 +24,9 @@ PATTERN;
|
||||
|
||||
public array $tokens = [ "url" , "route", "route.cacheless", "asset", "url.current", "url.parameters", "slug" ];
|
||||
|
||||
public function __construct(Context $context, string $urlBase = "", string $assetToken = "") {
|
||||
public function __construct(string $urlBase = "", string $assetToken = "") {
|
||||
$this->urlBase = trim($urlBase, "/");
|
||||
$this->assetToken = $assetToken;
|
||||
$this->register($context);
|
||||
}
|
||||
|
||||
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) : ?string
|
||||
@@ -54,15 +53,17 @@ PATTERN;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function register(Context $context) : void
|
||||
|
||||
public function exportFunctions(): array
|
||||
{
|
||||
$context->pushFunction("url", [ $this, 'buildUrl' ]);
|
||||
$context->pushFunction("current_url", [ $this, 'currentUrl' ]);
|
||||
$context->pushFunction("asset", [ $this, 'buildAssetUrl' ]);
|
||||
$context->pushFunction("route", [ $this, 'buildRouteUrl' ]);
|
||||
$context->pushFunction("slug", [ $this, 'slug' ]);
|
||||
$context->pushFunction("urlize", [ $this, 'urlize' ]);
|
||||
return [
|
||||
"url" => [ $this, 'buildUrl' ],
|
||||
"current_url" => [ $this, 'currentUrl' ],
|
||||
"asset" => [ $this, 'buildAssetUrl' ],
|
||||
"route" => [ $this, 'buildRouteUrl' ],
|
||||
"slug" => [ $this, 'slug' ],
|
||||
"urlize" => [ $this, 'urlize' ]
|
||||
];
|
||||
}
|
||||
|
||||
public function getRouteList(bool $full = false) : array
|
||||
|
||||
Reference in new issue
Block a user