From 32a0f84c4fbfd5998d739181d7cece96ce200bf2 Mon Sep 17 00:00:00 2001 From: Oli Griffiths Date: Sun, 8 May 2016 23:35:30 -0400 Subject: [PATCH 1/2] Define undefined variables --- code/object/bootstrapper/bootstrapper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/object/bootstrapper/bootstrapper.php b/code/object/bootstrapper/bootstrapper.php index c5d08372ad..2bcbcfef8a 100644 --- a/code/object/bootstrapper/bootstrapper.php +++ b/code/object/bootstrapper/bootstrapper.php @@ -222,6 +222,8 @@ public function bootstrap() } } + $identifiers = array(); + $aliases = array(); foreach($this->_files as $path) { $array = $factory->fromFile($path, false); From e4ed28051cbcd7198aeddcf089dc918f8dad9c28 Mon Sep 17 00:00:00 2001 From: Oli Griffiths Date: Sun, 8 May 2016 23:36:31 -0400 Subject: [PATCH 2/2] Ensure bootstrapper only re-iterates components being extended --- code/object/bootstrapper/bootstrapper.php | 82 ++++++++++++----------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/code/object/bootstrapper/bootstrapper.php b/code/object/bootstrapper/bootstrapper.php index 2bcbcfef8a..476ab3a4b5 100644 --- a/code/object/bootstrapper/bootstrapper.php +++ b/code/object/bootstrapper/bootstrapper.php @@ -145,6 +145,7 @@ public function bootstrap() { $factory = $this->getObject('object.config.factory'); + $extended_components = array(); foreach($this->_manifests as $manifest) { if (isset($manifest['identifier'])) @@ -165,59 +166,60 @@ public function bootstrap() $this->_namespaces[$identifier] = array($namespace => $manifest['paths']); } } + + if (isset($manifest['extends'])) { + $extended_components[] = $manifest; + } } - foreach($this->_manifests as $manifest) + foreach($extended_components as $manifest) { - if (isset($manifest['extends'])) + $extends = $manifest['extends']; + + if (!isset($this->_components[$extends])) { + throw new \RuntimeException(sprintf('Component: %s not found', $extends)); + } + + if(isset($manifest['identifier'])) { - $extends = $manifest['extends']; + $identifier = $manifest['identifier']; - if (!isset($this->_components[$extends])) { - throw new \RuntimeException(sprintf('Component: %s not found', $extends)); - } + //Append paths + $this->_components[$identifier] = array_merge( + $this->_components[$identifier], + $this->_components[$extends] + ); - if(isset($manifest['identifier'])) + //Set the namespace + if (isset($manifest['namespace'])) { - $identifier = $manifest['identifier']; + $namespace = $manifest['namespace']; - //Append paths - $this->_components[$identifier] = array_merge( - $this->_components[$identifier], + //Append the namespace + $this->_namespaces[$identifier] = array_merge( + $this->_namespaces[$identifier], $this->_components[$extends] ); - - //Set the namespace - if (isset($manifest['namespace'])) - { - $namespace = $manifest['namespace']; - - //Append the namespace - $this->_namespaces[$identifier] = array_merge( - $this->_namespaces[$identifier], - $this->_components[$extends] - ); - } } - else + } + else + { + //Prepend paths + $this->_components[$extends] = array_merge( + $manifest['paths'], + $this->_components[$extends] + ); + + //Set the namespace + if (isset($manifest['namespace'])) { - //Prepend paths - $this->_components[$extends] = array_merge( - $manifest['paths'], - $this->_components[$extends] - ); + $namespace = $manifest['namespace']; - //Set the namespace - if (isset($manifest['namespace'])) - { - $namespace = $manifest['namespace']; - - //Prepend the namespace - $this->_namespaces[$extends] = array_merge( - array($namespace => $manifest['paths']), - $this->_namespaces[$extends] - ); - } + //Prepend the namespace + $this->_namespaces[$extends] = array_merge( + array($namespace => $manifest['paths']), + $this->_namespaces[$extends] + ); } } }