Skip to content
Permalink
Browse files

Merge pull request #2972 from ADmad/3.0-controller-view

3.0 Remove Controller::$ext
  • Loading branch information...
lorenzo committed Mar 8, 2014
2 parents 4afda71 + f55fceb commit ca2a4fb62124eb0d187318b6cf5985f39972b219
Showing with 20 additions and 80 deletions.
  1. +0 −7 src/Controller/Controller.php
  2. +8 −8 src/View/View.php
  3. +12 −13 tests/TestCase/Utility/DebuggerTest.php
  4. +0 −52 tests/TestCase/View/ViewTest.php
@@ -225,13 +225,6 @@ class Controller extends Object implements EventListener {
*/
public $View;
/**
* File extension for view templates. Defaults to CakePHP's conventional ".ctp".
*
* @var string
*/
public $ext = '.ctp';
/**
* Automatically set to the name of a plugin.
*
@@ -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;
@@ -323,7 +323,6 @@ public function testExportVar() {
layout => 'default'
layoutPath => null
autoLayout => true
ext => '.ctp'
subDir => null
theme => null
cacheAction => false
@@ -339,21 +338,21 @@ public function testExportVar() {
Form => object(Cake\View\Helper\FormHelper) {}
int => (int) 2
float => (float) 1.333
[protected] _ext => '.ctp'
[protected] _passedVars => array(
(int) 0 => 'viewVars',
(int) 1 => 'autoLayout',
(int) 2 => 'ext',
(int) 3 => 'helpers',
(int) 4 => 'view',
(int) 5 => 'layout',
(int) 6 => 'name',
(int) 7 => 'theme',
(int) 8 => 'layoutPath',
(int) 9 => 'viewPath',
(int) 10 => 'request',
(int) 11 => 'plugin',
(int) 12 => 'passedArgs',
(int) 13 => 'cacheAction'
(int) 2 => 'helpers',
(int) 3 => 'view',
(int) 4 => 'layout',
(int) 5 => 'name',
(int) 6 => 'theme',
(int) 7 => 'layoutPath',
(int) 8 => 'viewPath',
(int) 9 => 'request',
(int) 10 => 'plugin',
(int) 11 => 'passedArgs',
(int) 12 => 'cacheAction'
)
[protected] _scripts => array()
[protected] _paths => array()
@@ -793,21 +793,6 @@ public function testMagicGet() {
$this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $View->Html);
}
/**
* 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
*
@@ -1164,43 +1149,6 @@ public function testRenderStrippingNoCacheTagsOnlyCacheCheck() {
$this->assertNotRegExp('/cake:nocache/', $result);
}
/**
* 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.
*

0 comments on commit ca2a4fb

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