API Rename CoreConfigCreator to CoreConfigFactory

Fix rebase regressions
This commit is contained in:
Damian Mooyman 2017-02-26 16:52:33 +13:00
parent e2064b5cc8
commit c452d5f6cd
8 changed files with 32 additions and 34 deletions

View File

@ -25,7 +25,6 @@
"swiftmailer/swiftmailer": "~5.4",
"symfony/cache": "^3.3@dev",
"symfony/config": "^2.8",
"symfony/cache": "^3.1",
"symfony/translation": "^2.8",
"vlucas/phpdotenv": "^2.4",
"silverstripe/config": "^1@dev"

View File

@ -17,7 +17,7 @@ use Symfony\Component\Finder\Finder;
/**
* Factory for silverstripe configs
*/
class CoreConfigCreator
class CoreConfigFactory
{
/**
* @var static

View File

@ -10,24 +10,24 @@ use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Object;
class ExtensionMiddleware implements \SilverStripe\Config\Middleware\Middleware
class ExtensionMiddleware implements Middleware
{
use MiddlewareCommon;
/**
* Get config for a class
*
* @param string $class
* @param mixed $options
* @param callable $next
* @return string
* @param string $class Name of class
* @param int|true $excludeMiddleware Middleware disable flags
* @param callable $next Callback to next middleware
* @return array Complete class config
*/
public function getClassConfig($class, $options, $next)
public function getClassConfig($class, $excludeMiddleware, $next)
{
// Get base config
$config = $next($class, $options);
$config = $next($class, $excludeMiddleware);
if (!$this->enabled($options)) {
if (!$this->enabled($excludeMiddleware)) {
return $config;
}

View File

@ -13,22 +13,22 @@ class InheritanceMiddleware implements Middleware
/**
* Get config for a class
*
* @param string $class
* @param mixed $options
* @param callable $next
* @return string
* @param string $class Name of class
* @param int|true $excludeMiddleware Middleware disable flags
* @param callable $next Callback to next middleware
* @return array Complete class config
*/
public function getClassConfig($class, $options, $next)
public function getClassConfig($class, $excludeMiddleware, $next)
{
// Check if enabled
if (!$this->enabled($options)) {
return $next($class, $options);
if (!$this->enabled($excludeMiddleware)) {
return $next($class, $excludeMiddleware);
}
// Merge hierarchy
$config = [];
foreach (ClassInfo::ancestry($class) as $nextClass) {
$nextConfig = $next($nextClass, $options);
$nextConfig = $next($nextClass, $excludeMiddleware);
$config = Priority::mergeArray($nextConfig, $config);
}
return $config;

View File

@ -19,22 +19,21 @@ trait MiddlewareCommon
$this->disableFlag = $disableFlag;
}
protected function enabled($options)
/**
* Check if this middlware is enabled
*
* @param int|true $excludeMiddleware
* @return bool
*/
protected function enabled($excludeMiddleware)
{
if ($options === true) {
if ($excludeMiddleware === true) {
return false;
}
if (!$this->disableFlag) {
return true;
}
if (is_array($options)) {
if (!isset($options['disableFlag'])) {
return true;
}
$options = $options['disableFlag'];
}
return ($options & $this->disableFlag) !== $this->disableFlag;
return ($excludeMiddleware & $this->disableFlag) !== $this->disableFlag;
}
public function serialize()

View File

@ -1,7 +1,7 @@
<?php
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Config\CoreConfigCreator;
use SilverStripe\Core\Config\CoreConfigFactory;
use SilverStripe\Core\Config\ConfigLoader;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Injector\SilverStripeServiceConfigurationLocator;
@ -83,7 +83,7 @@ $moduleManifest = new ModuleManifest(BASE_PATH, false, $flush);
ModuleLoader::instance()->pushManifest($moduleManifest);
// Build config manifest
$configManifest = CoreConfigCreator::inst()->createRoot($flush);
$configManifest = CoreConfigFactory::inst()->createRoot($flush);
ConfigLoader::instance()->pushManifest($configManifest);
// After loading config, boot _config.php files

View File

@ -13,7 +13,7 @@ use SilverStripe\Control\Tests\FakeController;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\ConfigLoader;
use SilverStripe\Core\Config\CoreConfigCreator;
use SilverStripe\Core\Config\CoreConfigFactory;
use SilverStripe\Core\Config\DefaultConfig;
use SilverStripe\Core\Config\Middleware\ExtensionMiddleware;
use SilverStripe\Core\Flushable;
@ -1028,7 +1028,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
));
// Once new class loader is registered, push a new uncached config
$config = CoreConfigCreator::inst()->createCore();
$config = CoreConfigFactory::inst()->createCore();
ConfigLoader::instance()->pushManifest($config);
// Invalidate classname spec since the test manifest will now pull out new subclasses for each internal class

View File

@ -5,7 +5,7 @@ namespace SilverStripe\Core\Tests\Manifest;
use Dotenv\Loader;
use SilverStripe\Config\Collections\MemoryConfigCollection;
use SilverStripe\Control\Director;
use SilverStripe\Core\Config\CoreConfigCreator;
use SilverStripe\Core\Config\CoreConfigFactory;
use SilverStripe\Dev\SapphireTest;
class ConfigManifestTest extends SapphireTest
@ -29,7 +29,7 @@ class ConfigManifestTest extends SapphireTest
public function getTestConfig()
{
$config = new MemoryConfigCollection();
$transformer = CoreConfigCreator::inst()->buildYamlTransformerForPath(dirname(__FILE__) . '/fixtures/configmanifest');
$transformer = CoreConfigFactory::inst()->buildYamlTransformerForPath(dirname(__FILE__) . '/fixtures/configmanifest');
$config->transform([$transformer]);
return $config;
}