Commit c6ebde43 authored by alexpott's avatar alexpott

Issue #2026367 by Berdir: Use static caches for parsed .services.yml and .info.yml files.

parent de3558c2
......@@ -5376,7 +5376,7 @@ function element_set_attributes(array &$element, array $map) {
* The info array.
*/
function drupal_parse_info_file($filename) {
$info = &drupal_static(__FUNCTION__, array());
static $info = array();
if (!isset($info[$filename])) {
if (!file_exists($filename)) {
......
......@@ -23,6 +23,15 @@
*/
class YamlFileLoader {
/**
* Statically cached yaml files.
*
* Especially during tests, yaml files are re-parsed often.
*
* @var array
*/
static protected $yaml = array();
/**
* @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
*/
......@@ -39,7 +48,10 @@ public function __construct(ContainerBuilder $container) {
* The name of the file to load.
*/
public function load($filename) {
$content = $this->loadFile($filename);
if (!isset(static::$yaml[$filename])) {
static::$yaml[$filename] = $this->loadFile($filename);
}
$content = static::$yaml[$filename];
$content += array('parameters' => array(), 'services' => array());
// parameters
foreach ($content['parameters'] as $key => $value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment