31 $this->prototypes =
array();
40 $tokens = token_get_all(
'<?php '.$prototype);
48 if (!$nbProtos = count($this->prototypes)) {
49 throw new \LogicException(
'There are no prototypes registered.');
52 $buffers = array_fill(0, $nbProtos,
'');
53 $bufferLevels = array_fill(0, $nbProtos, 0);
54 $buffersInWildcard =
array();
56 $tokens = token_get_all($resource->
getContent());
59 while ($token = array_shift($tokens)) {
60 $current = self::tokenToString($token);
62 foreach (array_keys($this->prototypes) as $i) {
63 $prototype = & $this->prototypes[$i][0];
65 $buffer = & $buffers[$i];
66 $level = & $bufferLevels[$i];
68 if (isset($buffersInWildcard[$i])) {
70 case '(': ++$level;
break;
71 case ')': --$level;
break;
79 unset($buffersInWildcard[$i]);
81 } elseif ($current == self::tokenToString(current($prototype))) {
83 if (
'*' == self::tokenToString(next($prototype))) {
84 $buffersInWildcard[$i] =
true;
89 unset($buffersInWildcard[$i]);
96 foreach ($calls as $call) {
97 $formulae += call_user_func_array(
array($this,
'processCall'), $call);
106 file_put_contents($tmp, implode(
"\n",
array(
110 'echo serialize($_call);',
112 $args = unserialize(shell_exec(
'php '.escapeshellarg($tmp)));
115 $inputs = isset($args[0]) ? self::argumentToArray($args[0]) :
array();
116 $filters = isset($args[1]) ? self::argumentToArray($args[1]) :
array();
120 $options[
'debug'] = $this->factory->isDebug();
124 throw new \RuntimeException(
'The third argument must be omitted, null or an array.');
131 $options[
'name'] = $this->factory->generateAssetName($inputs, $filters,
$options);
153 return is_array($token) ? $token[1] : $token;
158 return is_array($argument) ? $argument : array_filter(array_map(
'trim', explode(
',', $argument)));
static createTemporaryFile($prefix)
Creates a temporary file.
getContent()
Returns the content of the resource.
A resource is something formulae can be loaded from.
if(!is_array($argv)) $options
Create styles array
The data for the language used.
The asset factory creates asset objects.