getConvertor() public static method

public static getConvertor ( $source, $dest ) : callable
return callable
Beispiel #1
0
 /**
  * Renders block.
  * @param  string
  * @param  array
  * @param  string|\Closure content-type name or modifier closure
  * @return void
  * @internal
  */
 protected function renderBlock($name, array $params, $mod = NULL)
 {
     if (empty($this->blockQueue[$name])) {
         $hint = isset($this->blockQueue) && ($t = Latte\Helpers::getSuggestion(array_keys($this->blockQueue), $name)) ? ", did you mean '{$t}'?" : '.';
         throw new \RuntimeException("Cannot include undefined block '{$name}'{$hint}");
     }
     $block = reset($this->blockQueue[$name]);
     if ($mod && $mod !== ($blockType = $this->blockTypes[$name])) {
         if ($filter = is_string($mod) ? Filters::getConvertor($blockType, $mod) : $mod) {
             echo $filter($this->capture(function () use($block, $params) {
                 $block($params);
             }), $blockType);
             return;
         }
         trigger_error("Including block {$name} with content type " . strtoupper($blockType) . ' into incompatible type ' . strtoupper($mod) . '.', E_USER_WARNING);
     }
     $block($params);
 }