- Token name and options are now passed through parse() method
This commit is contained in:
1 parent
e9b2f0ece3
commit
b3a8e3aca2
29 files changed
+70
-59
No files matched your search
@@ -29,10 +29,8 @@ PATTERN;
|
||||
$this->assetToken = $assetToken;
|
||||
}
|
||||
|
||||
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token) : ?string
|
||||
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string
|
||||
{
|
||||
$opt = $context->tokenOptions($token);
|
||||
|
||||
switch($token) {
|
||||
case "asset":
|
||||
return "<?php echo \$picea->compiler->getExtensionFromToken('$token')->buildAssetUrl($arguments) ?>";
|
||||
@@ -41,10 +39,10 @@ PATTERN;
|
||||
return "<?php echo \$picea->compiler->getExtensionFromToken('$token')->buildRouteUrl($arguments) ?>";
|
||||
|
||||
case "url":
|
||||
if ( in_array('parameters', $opt) ) {
|
||||
if ( in_array('parameters', $options) ) {
|
||||
return "<?php echo \$picea->compiler->getExtensionFromToken('$token')->setUrlParameters($arguments) ?>";
|
||||
}
|
||||
elseif ( in_array('current', $opt) ) {
|
||||
elseif ( in_array('current', $options) ) {
|
||||
return "<?php echo \$picea->compiler->getExtensionFromToken('$token')->currentUrl($arguments) ?>";
|
||||
}
|
||||
|
||||
@@ -54,7 +52,7 @@ PATTERN;
|
||||
return "<?php echo \$picea->compiler->getExtensionFromToken('$token')->slug($arguments) ?>";
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new \ParseExtensionException("Unknown token given $token in UrlExtension.");
|
||||
}
|
||||
|
||||
public function exportFunctions(): array
|
||||
|
||||
Reference in new issue
Block a user