Skip to content
Permalink
Browse files

Fixes bug with view cell caching & template names

  • Loading branch information...
garethellis36 committed Sep 29, 2016
1 parent ed513cd commit 96ca33f489328c64e530f81f6193f34cc7579346
Showing with 5 additions and 4 deletions.
  1. +4 −3 src/View/Cell.php
  2. +1 −1 tests/TestCase/View/CellTest.php
@@ -172,7 +172,7 @@ public function render($template = null)
{
$cache = [];
if ($this->_cache) {
$cache = $this->_cacheConfig($this->action);
$cache = $this->_cacheConfig($this->action, $template);
}
$render = function () use ($template) {
@@ -232,12 +232,13 @@ public function render($template = null)
* @param string $action The action invoked.
* @return array The cache configuration.
*/
protected function _cacheConfig($action)
protected function _cacheConfig($action, $template = null)
{
if (empty($this->_cache)) {
return [];
}
$key = 'cell_' . Inflector::underscore(get_class($this)) . '_' . $action;
$template = $template ?: "default";
$key = 'cell_' . Inflector::underscore(get_class($this)) . '_' . $action . '_' . $template;
$key = str_replace('\\', '_', $key);
$default = [
'config' => 'default',
@@ -479,7 +479,7 @@ public function testACachedViewCellReRendersWhenGivenADifferentTemplate()
'className' => 'File',
'path' => CACHE,
]);
$cell = $this->View->cell('Articles::customTemplateViewBuilder', [], ['cache' => ['key' => 'celltest']]);
$cell = $this->View->cell('Articles::customTemplateViewBuilder', [], ['cache' => true]);
$result = $cell->render("alternate_teaser_list");
$result2 = $cell->render("not_the_alternate_teaser_list");
$this->assertContains('This is the alternate template', $result);

0 comments on commit 96ca33f

Please sign in to comment.
You can’t perform that action at this time.