Skip to content

Commit

Permalink
Remove backwards compatibility feature.
Browse files Browse the repository at this point in the history
It's not necessary to check for .ctp extension as fallback if alternate
extension is set.
  • Loading branch information
ADmad committed Jun 1, 2014
1 parent 67c3bbd commit 927146b
Showing 1 changed file with 15 additions and 36 deletions.
51 changes: 15 additions & 36 deletions src/View/View.php
Expand Up @@ -335,10 +335,11 @@ class View {
/**
* Constructor
*
* @param Request $request
* @param Response $response
* @param EventManager $eventManager
* @param array $viewOptions
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*/
public function __construct(Request $request = null, Response $response = null,
EventManager $eventManager = null, array $viewOptions = []) {
Expand Down Expand Up @@ -384,7 +385,7 @@ public function getEventManager() {
*
* Primarily useful for testing.
*
* @param \Cake\Event\EventManager $eventManager.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @return void
*/
public function setEventManager(EventManager $eventManager) {
Expand Down Expand Up @@ -957,12 +958,9 @@ protected function _getViewFileName($name = null) {
}
}
$paths = $this->_paths($plugin);
$exts = $this->_getExtensions();
foreach ($exts as $ext) {
foreach ($paths as $path) {
if (file_exists($path . $name . $ext)) {
return $path . $name . $ext;
}
foreach ($paths as $path) {
if (file_exists($path . $name . $this->_ext)) {
return $path . $name . $this->_ext;
}
}
$defaultPath = $paths[0];
Expand Down Expand Up @@ -1021,30 +1019,14 @@ protected function _getLayoutFileName($name = null) {
$paths = $this->_paths($plugin);
$file = 'Layout' . DS . $subDir . $name;

$exts = $this->_getExtensions();
foreach ($exts as $ext) {
foreach ($paths as $path) {
if (file_exists($path . $file . $ext)) {
return $path . $file . $ext;
}
foreach ($paths as $path) {
if (file_exists($path . $file . $this->_ext)) {
return $path . $file . $this->_ext;
}
}
throw new Error\MissingLayoutException(array('file' => $paths[0] . $file . $this->_ext));
}

/**
* Get the extensions that view files can use.
*
* @return array Array of extensions view files use.
*/
protected function _getExtensions() {
$exts = array($this->_ext);
if ($this->_ext !== '.ctp') {
$exts[] = '.ctp';
}
return $exts;
}

/**
* Finds an element filename, returns false on failure.
*
Expand All @@ -1055,12 +1037,9 @@ protected function _getElementFileName($name) {
list($plugin, $name) = $this->pluginSplit($name);

$paths = $this->_paths($plugin);
$exts = $this->_getExtensions();
foreach ($exts as $ext) {
foreach ($paths as $path) {
if (file_exists($path . 'Element' . DS . $name . $ext)) {
return $path . 'Element' . DS . $name . $ext;
}
foreach ($paths as $path) {
if (file_exists($path . 'Element' . DS . $name . $this->_ext)) {
return $path . 'Element' . DS . $name . $this->_ext;
}
}
return false;
Expand Down

0 comments on commit 927146b

Please sign in to comment.