Browse Source

Merge pull request #4020 from cakephp/issue-3945-plugin-cell

Fix cell paths in plugins not being able to use relative paths.
José Lorenzo Rodríguez 11 years ago
parent
commit
63d0df39ae
2 changed files with 13 additions and 0 deletions
  1. 2 0
      src/View/View.php
  2. 11 0
      tests/TestCase/View/CellTest.php

+ 2 - 0
src/View/View.php

@@ -852,6 +852,8 @@ class View {
 				$name = trim($name, DS);
 			} elseif (!$plugin || $this->viewPath !== $this->name) {
 				$name = $this->viewPath . DS . $subDir . $name;
+			} else {
+				$name = DS . $subDir . $name;
 			}
 		}
 

+ 11 - 0
tests/TestCase/View/CellTest.php

@@ -158,6 +158,17 @@ class CellTest extends TestCase {
 	}
 
 /**
+ * Test that plugin cells can render other view templates.
+ *
+ * @return void
+ */
+	public function testPluginCellAlternateTemplate() {
+		$cell = $this->View->cell('TestPlugin.Dummy::echoThis', ['msg' => 'hello world!']);
+		$cell->template = '../../Element/translate';
+		$this->assertContains('This is a translatable string', "{$cell}");
+	}
+
+/**
  * Tests that using an unexisting cell throws an exception.
  *
  * @expectedException \Cake\View\Error\MissingCellException