Skip to content

Commit

Permalink
Fix extensions not being able to register other extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
colinodell committed Apr 11, 2019
1 parent 35de254 commit a3b96d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi

- Added the missing `addExtension()` method to the new `ConfigurableEnvironmentInterface`

### Fixed

- Fixed extensions not being able to register other extensions

## [0.19.0] - 2019-04-10

### Added
Expand Down
13 changes: 11 additions & 2 deletions src/Environment.php
Expand Up @@ -32,6 +32,11 @@ final class Environment implements EnvironmentInterface, ConfigurableEnvironment
*/
private $extensions = [];

/**
* @var ExtensionInterface[]
*/
private $uninitializedExtensions = [];

/**
* @var bool
*/
Expand Down Expand Up @@ -308,6 +313,7 @@ public function addExtension(ExtensionInterface $extension): ConfigurableEnviron
$this->assertUninitialized('Failed to add extension.');

$this->extensions[] = $extension;
$this->uninitializedExtensions[] = $extension;

return $this;
}
Expand All @@ -320,8 +326,11 @@ private function initializeExtensions()
}

// Ask all extensions to register their components
foreach ($this->extensions as $extension) {
$extension->register($this);
while (!empty($this->uninitializedExtensions)) {
foreach ($this->uninitializedExtensions as $i => $extension) {
$extension->register($this);
unset($this->uninitializedExtensions[$i]);
}
}

$this->extensionsInitialized = true;
Expand Down

0 comments on commit a3b96d2

Please sign in to comment.