Ejemplo n.º 1
0
 /**
  * Wrap a field's callback to ensure that a reference to the helper is
  * always supplied as the first argument to the callback.
  *
  * @param callable $callable
  * @param FieldInterface $field
  * @return callable
  */
 protected function wrapCallable(callable $callable, FieldInterface $field = null)
 {
     return function () use($callable, $field) {
         $arguments = func_get_args();
         array_unshift($arguments, $this);
         $output = call_user_func_array($callable, $arguments);
         if ($field) {
             /* @var $filter callable */
             foreach ($field->getHelperFilters($this->name) as $filter) {
                 $filterArguments = $arguments;
                 array_unshift($filterArguments, $output);
                 $output = call_user_func_array($filter, $filterArguments);
             }
         }
         return $output;
     };
 }