src/Controller.php
public function addPhpToJs($key, $value)
    {
        if (is_bool($value)) {
            $value = $value ? "true" : "false";
        } elseif (is_string($value)) {
            $value = "\"$value\"";
        } elseif (is_array($value)) {
            $value = json_encode($value);
        } elseif (is_object($value) && method_exists($value, "toArray")) {
            $value = json_encode($value->toArray());
        } else {
            throw new \Exception("Can not translate a parameter from PHP to JS\n".print_r($value, true));
        }

        $this->_themeExtras['phpToJs'][$key] = $value;
    }
public function addPhpToJs($key, $value)
    {
        if (is_bool($value)) {
            $value = $value ? "true" : "false";
        } elseif (is_string($value)) {
            $value = "\"$value\"";
        } elseif (is_array($value)) {
            $value = json_encode($value);
        } elseif (is_object($value) && method_exists($value, "toArray")) {
            $value = json_encode($value->toArray());
        } else {
            throw new \Exception("Can not translate a parameter from PHP to JS\n".print_r($value, true));
        }

        $this->_themeExtras['phpToJs'][$key] = $value;
    }
public function addPhpToJs ( $ key , $ value ) { if ( is_bool ( $ value ) ) { $ value = $ value ? "true" : "false" ; } elseif ( is_string ( $ value ) ) { $ value = "\"$value\"" ; } elseif ( is_array ( $ value ) ) { $ value = json_encode ( $ value ) ; } elseif ( is_object ( $ value ) && method_exists ( $ value , "toArray" ) ) { $ value = json_encode ( $ value -> toArray ( ) ) ; } else { throw new \ Exception ( "Can not translate a parameter from PHP to JS\n" . print_r ( $ value , true ) ) ; } $ this -> _themeExtras [ 'phpToJs' ] [ $ key ] = $ value ; }
Add phpToJs variable to be set on the current page

@param mixed $key
@param mixed $value
Add phpToJs variable to be set on the current page