Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace public property View::$ext with protected View::$_ext.

The view file extension can longer be changed through controller.
  • Loading branch information...
commit 6feb0798c642eb53260890465ef4d920a54e8208 1 parent 0953c3d
@ADmad ADmad authored
Showing with 8 additions and 60 deletions.
  1. +8 −8 src/View/View.php
  2. +0 −52 tests/TestCase/View/ViewTest.php
View
16 src/View/View.php
@@ -148,7 +148,7 @@ class View extends Object {
*
* @var string
*/
- public $ext = '.ctp';
+ protected $_ext = '.ctp';
/**
* Sub-directory for this view file. This is often used for extension based routing.
@@ -235,7 +235,7 @@ class View extends Object {
* @var array
*/
protected $_passedVars = array(
- 'viewVars', 'autoLayout', 'ext', 'helpers', 'view', 'layout', 'name', 'theme',
+ 'viewVars', 'autoLayout', 'helpers', 'view', 'layout', 'name', 'theme',
'layoutPath', 'viewPath', 'request', 'plugin', 'passedArgs', 'cacheAction'
);
@@ -411,7 +411,7 @@ public function element($name, $data = array(), $options = array()) {
if (empty($options['ignoreMissing'])) {
list ($plugin, $name) = pluginSplit($name, true);
$name = str_replace('/', DS, $name);
- $file = $plugin . 'Element' . DS . $name . $this->ext;
+ $file = $plugin . 'Element' . DS . $name . $this->_ext;
trigger_error(sprintf('Element Not Found: %s', $file), E_USER_NOTICE);
}
}
@@ -706,7 +706,7 @@ public function extend($name) {
$defaultPath = $paths[0] . 'Element' . DS;
throw new \LogicException(sprintf(
'You cannot extend an element which does not exist (%s).',
- $defaultPath . $name . $this->ext
+ $defaultPath . $name . $this->_ext
));
}
break;
@@ -949,7 +949,7 @@ protected function _getViewFileName($name = null) {
}
}
}
- throw new Error\MissingViewException(array('file' => $defaultPath . $name . $this->ext));
+ throw new Error\MissingViewException(array('file' => $defaultPath . $name . $this->_ext));
}
/**
@@ -1002,7 +1002,7 @@ protected function _getLayoutFileName($name = null) {
}
}
}
- throw new Error\MissingLayoutException(array('file' => $paths[0] . $file . $this->ext));
+ throw new Error\MissingLayoutException(array('file' => $paths[0] . $file . $this->_ext));
}
/**
@@ -1011,8 +1011,8 @@ protected function _getLayoutFileName($name = null) {
* @return array Array of extensions view files use.
*/
protected function _getExtensions() {
- $exts = array($this->ext);
- if ($this->ext !== '.ctp') {
+ $exts = array($this->_ext);
+ if ($this->_ext !== '.ctp') {
$exts[] = '.ctp';
}
return $exts;
View
52 tests/TestCase/View/ViewTest.php
@@ -794,21 +794,6 @@ public function testMagicGet() {
}
/**
- * Test that ctp is used as a fallback file extension for elements
- *
- * @return void
- */
- public function testElementCtpFallback() {
- $View = new TestView($this->PostsController);
- $View->ext = '.missing';
- $element = 'test_element';
- $expected = 'this is the test element';
- $result = $View->element($element);
-
- $this->assertEquals($expected, $result);
- }
-
-/**
* Test loadHelpers method
*
* @return void
@@ -1165,43 +1150,6 @@ public function testRenderStrippingNoCacheTagsOnlyCacheCheck() {
}
/**
- * testBadExt method
- *
- * @expectedException \Cake\Error\MissingViewException
- * @return void
- */
- public function testBadExt() {
- $this->PostsController->action = 'something';
- $this->PostsController->ext = '.whatever';
-
- $View = new TestView($this->PostsController);
- $View->render('this_is_missing');
- }
-
-/**
- * testAltExt method
- *
- * @return void
- */
- public function testAltExt() {
- $this->PostsController->ext = '.alt';
- $View = new TestView($this->PostsController);
- $result = $View->render('alt_ext', false);
- $this->assertEquals('alt ext', $result);
- }
-
-/**
- * testAltBadExt method
- *
- * @expectedException \Cake\Error\MissingViewException
- * @return void
- */
- public function testAltBadExt() {
- $View = new TestView($this->PostsController);
- $View->render('alt_ext');
- }
-
-/**
* Test creating a block with capturing output.
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.