chg: [internal] Element file cache

pull/7975/head
Jakub Onderka 2021-11-21 18:05:51 +01:00
parent e2a0644111
commit 5aa1e0cb3b
2 changed files with 33 additions and 0 deletions

View File

@ -1413,4 +1413,14 @@ class AppController extends Controller
return true;
}
}
/**
* Override View class
* @return AppView
*/
protected function _getViewObject()
{
App::uses('AppView', 'View');
return new AppView($this);
}
}

23
app/View/AppView.php Normal file
View File

@ -0,0 +1,23 @@
<?php
class AppView extends View
{
/**
* Negative results of `file_exists` methods are not cached, so we provide our cache
* @var array
*/
private $elementFileCache = [];
/**
* @param string $name
* @return false|string
*/
protected function _getElementFileName($name)
{
if (isset($this->elementFileCache[$name])) {
return $this->elementFileCache[$name];
}
$result = parent::_getElementFileName($name);
$this->elementFileCache[$name] = $result;
return $result;
}
}