mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-20 03:26:16 +00:00
Fixing method dispatching errors in JsHelper with regards to Object::object, and PHP4 workarounds.
This commit is contained in:
parent
4e6aa35155
commit
856392e916
2 changed files with 26 additions and 1 deletions
|
@ -115,7 +115,7 @@ class JsHelper extends AppHelper {
|
||||||
* @param string $method Method to be called
|
* @param string $method Method to be called
|
||||||
* @param array $params Parameters for the method being called.
|
* @param array $params Parameters for the method being called.
|
||||||
* @access public
|
* @access public
|
||||||
* @return mixed
|
* @return mixed Depends on the return of the dispatched method, or it could be an instance of the EngineHelper
|
||||||
**/
|
**/
|
||||||
function call__($method, $params) {
|
function call__($method, $params) {
|
||||||
if (isset($this->{$this->__engineName}) && method_exists($this->{$this->__engineName}, $method)) {
|
if (isset($this->{$this->__engineName}) && method_exists($this->{$this->__engineName}, $method)) {
|
||||||
|
@ -150,6 +150,20 @@ class JsHelper extends AppHelper {
|
||||||
trigger_error(sprintf(__('JsHelper:: Missing Method %s is undefined', true), $method), E_USER_WARNING);
|
trigger_error(sprintf(__('JsHelper:: Missing Method %s is undefined', true), $method), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workaround for Object::Object() existing. Since Object::object exists, it does not
|
||||||
|
* fall into call__ and is not passed onto the engine helper. See JsBaseEngineHelper::object() for
|
||||||
|
* more information on this method.
|
||||||
|
*
|
||||||
|
* @param mixed $data Data to convert into JSON
|
||||||
|
* @param array $options Options to use for encoding JSON. See JsBaseEngineHelper::object() for more details.
|
||||||
|
* @return string encoded JSON
|
||||||
|
* @deprecated Remove when support for PHP4 and Object::object are removed.
|
||||||
|
**/
|
||||||
|
function object($data = array(), $options = array()) {
|
||||||
|
return $this->{$this->__engineName}->object($data, $options);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes all Javascript generated so far to a code block or
|
* Writes all Javascript generated so far to a code block or
|
||||||
* caches them to a file and returns a linked script.
|
* caches them to a file and returns a linked script.
|
||||||
|
|
|
@ -415,6 +415,17 @@ CODE;
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that Object::Object() is not breaking json output in JsHelper
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testObjectPassThrough() {
|
||||||
|
$result = $this->Js->object(array('one' => 'first', 'two' => 'second'));
|
||||||
|
$expected = '{"one":"first","two":"second"}';
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue