original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Add phpToJs variable to be set on the current page
  
  @param mixed $key
  @param mixed $value
docstring_tokens: Add phpToJs variable to be set on the current page