src/View/Renderer/YamlRenderer.php
/**
     * Processes a view script and returns the output.
     *
     * @param  string|ModelInterface $nameOrModel The script/resource process, or a view model
     * @param  null|array|\ArrayAccess $values Values to use during rendering
     * @return string The script output.
     */
Processes a view script and returns the output.
@param  string|ModelInterface $nameOrModel The script/resource process, or a view model
@param  null|array|\ArrayAccess $values Values to use during rendering
@return string The script output.
Processes a view script and returns the output . @param string|ModelInterface $nameOrModel The script / resource process or a view model @param null|array| \ ArrayAccess $values Values to use during rendering @return string The script output .
public function render($nameOrModel, $values = null)
    {
        if ($nameOrModel instanceof ModelInterface) {
            if ($nameOrModel instanceof YamlModel) {
                $children = $this->recurseModel($nameOrModel, false);
                $this->injectChildren($nameOrModel, $children);
                $values = $nameOrModel->serialize();
            } else {
                $values = $this->recurseModel($nameOrModel);
                $values = Yaml::dump($values);
            }
            return $values;
        }
        if (null === $values) {
            if (! is_object($nameOrModel)) {
                $return = Yaml::dump($nameOrModel);
            } elseif ($nameOrModel instanceof \Traversable) {
                $nameOrModel = ArrayUtils::iteratorToArray($nameOrModel);
                $return = Yaml::dump($nameOrModel);
            } else {
                $return = Yaml::dump(get_object_vars($nameOrModel));
            }
            return $return;
        }
        throw new DomainException(sprintf(
            '%s: Do not know how to handle operation when both $nameOrModel and $values are populated',
            __METHOD__
        ));
    }
public function render ( $ nameOrModel , $ values = null ) { if ( $ nameOrModel instanceof ModelInterface ) { if ( $ nameOrModel instanceof YamlModel ) { $ children = $ this -> recurseModel ( $ nameOrModel , false ) ; $ this -> injectChildren ( $ nameOrModel , $ children ) ; $ values = $ nameOrModel -> serialize ( ) ; } else { $ values = $ this -> recurseModel ( $ nameOrModel ) ; $ values = Yaml :: dump ( $ values ) ; } return $ values ; } if ( null === $ values ) { if ( ! is_object ( $ nameOrModel ) ) { $ return = Yaml :: dump ( $ nameOrModel ) ; } elseif ( $ nameOrModel instanceof \ Traversable ) { $ nameOrModel = ArrayUtils :: iteratorToArray ( $ nameOrModel ) ; $ return = Yaml :: dump ( $ nameOrModel ) ; } else { $ return = Yaml :: dump ( get_object_vars ( $ nameOrModel ) ) ; } return $ return ; } throw new DomainException ( sprintf ( '%s: Do not know how to handle operation when both $nameOrModel and $values are populated' , __METHOD__ ) ) ; }
Processes a view script and returns the output.
Processes a view script and returns the output .
// use case 1: View Models // Serialize variables in view model // use case 2: $nameOrModel is populated, $values is not // Serialize $nameOrModel // use case 3: Both $nameOrModel and $values are populated