mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding parameters to helper callbacks, these allow helpers to introspect more on the view/layout being rendered.
Updating tests.
This commit is contained in:
parent
882efa883e
commit
1b19ad48b4
4 changed files with 17 additions and 11 deletions
|
@ -801,9 +801,10 @@ class Helper extends Object {
|
|||
*
|
||||
* Overridden in subclasses.
|
||||
*
|
||||
* @param string $viewFile The view file that is going to be rendered
|
||||
* @return void
|
||||
*/
|
||||
public function beforeRender() {
|
||||
public function beforeRender($viewFile) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -812,9 +813,11 @@ class Helper extends Object {
|
|||
*
|
||||
* Overridden in subclasses.
|
||||
*
|
||||
* @param string $viewFile The view file that was rendered.
|
||||
* @param string $content The content of the rendered view.
|
||||
* @return void
|
||||
*/
|
||||
public function afterRender() {
|
||||
public function afterRender($viewFile, $content) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -822,9 +825,10 @@ class Helper extends Object {
|
|||
*
|
||||
* Overridden in subclasses.
|
||||
*
|
||||
* @param string $layoutFile The layout about to be rendered.
|
||||
* @return void
|
||||
*/
|
||||
public function beforeLayout() {
|
||||
public function beforeLayout($layoutFile) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -832,9 +836,11 @@ class Helper extends Object {
|
|||
*
|
||||
* Overridden in subclasses.
|
||||
*
|
||||
* @param string $layoutFile The layout file that was rendered.
|
||||
* @param string $content The content of the rendered layout.
|
||||
* @return void
|
||||
*/
|
||||
public function afterLayout() {
|
||||
public function afterLayout($layoutFile, $content) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -110,10 +110,10 @@ class PaginatorHelper extends AppHelper {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function beforeRender() {
|
||||
public function beforeRender($viewFile) {
|
||||
$this->options['url'] = array_merge($this->request->params['pass'], $this->request->params['named']);
|
||||
|
||||
parent::beforeRender();
|
||||
parent::beforeRender($viewFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -391,9 +391,9 @@ class View extends Object {
|
|||
}
|
||||
|
||||
if ($action !== false && $viewFileName = $this->_getViewFileName($action)) {
|
||||
$this->Helpers->trigger('beforeRender', array($this, $viewFileName));
|
||||
$this->Helpers->trigger('beforeRender', array($viewFileName));
|
||||
$out = $this->_render($viewFileName);
|
||||
$this->Helpers->trigger('afterRender', array($this, $viewFileName, $out));
|
||||
$this->Helpers->trigger('afterRender', array($viewFileName, $out));
|
||||
}
|
||||
|
||||
if ($layout === null) {
|
||||
|
@ -437,7 +437,7 @@ class View extends Object {
|
|||
if (!$this->_helpersLoaded) {
|
||||
$this->loadHelpers();
|
||||
}
|
||||
$this->Helpers->trigger('beforeLayout', array(&$this, $layoutFileName));
|
||||
$this->Helpers->trigger('beforeLayout', array($layoutFileName));
|
||||
|
||||
$this->viewVars = array_merge($this->viewVars, array(
|
||||
'content_for_layout' => $content_for_layout,
|
||||
|
@ -454,7 +454,7 @@ class View extends Object {
|
|||
throw new RuntimeException(sprintf(__("Error in layout %s, got no content."), $layoutFileName));
|
||||
}
|
||||
|
||||
$this->Helpers->trigger('afterLayout', array(&$this, $layoutFileName, $this->output));
|
||||
$this->Helpers->trigger('afterLayout', array($layoutFileName, $this->output));
|
||||
|
||||
return $this->output;
|
||||
}
|
||||
|
|
|
@ -657,7 +657,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$this->Paginator->request->params['pass'] = array(2);
|
||||
$this->Paginator->request->params['named'] = array('foo' => 'bar');
|
||||
$this->Paginator->beforeRender();
|
||||
$this->Paginator->beforeRender('posts/index');
|
||||
|
||||
$result = $this->Paginator->sort('title');
|
||||
$expected = array(
|
||||
|
|
Loading…
Add table
Reference in a new issue