private function BasePhpFormulaLoader::processCall

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/Loader/BasePhpFormulaLoader.php, line 102

Class

BasePhpFormulaLoader
Loads asset formulae from PHP files.

Namespace

Assetic\Factory\Loader

Code

private function processCall($call, array $protoOptions = array()) {
  $tmp = tempnam(sys_get_temp_dir(), 'assetic');
  file_put_contents($tmp, implode("\n", array(
    '<?php',
    $this
      ->registerSetupCode(),
    $call,
    'echo serialize($_call);',
  )));
  $args = unserialize(shell_exec('php ' . escapeshellarg($tmp)));
  unlink($tmp);
  $inputs = isset($args[0]) ? self::argumentToArray($args[0]) : array();
  $filters = isset($args[1]) ? self::argumentToArray($args[1]) : array();
  $options = isset($args[2]) ? $args[2] : array();
  if (!isset($options['debug'])) {
    $options['debug'] = $this->factory
      ->isDebug();
  }
  if (!is_array($options)) {
    throw new \RuntimeException('The third argument must be omitted, null or an array.');
  }

  // apply the prototype options
  $options += $protoOptions;
  if (!isset($options['name'])) {
    $options['name'] = $this->factory
      ->generateAssetName($inputs, $filters, $options);
  }
  return array(
    $options['name'] => array(
      $inputs,
      $filters,
      $options,
    ),
  );
}