mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Rename CoreConfigCreator to CoreConfigFactory
Fix rebase regressions
This commit is contained in:
parent
e2064b5cc8
commit
c452d5f6cd
@ -25,7 +25,6 @@
|
|||||||
"swiftmailer/swiftmailer": "~5.4",
|
"swiftmailer/swiftmailer": "~5.4",
|
||||||
"symfony/cache": "^3.3@dev",
|
"symfony/cache": "^3.3@dev",
|
||||||
"symfony/config": "^2.8",
|
"symfony/config": "^2.8",
|
||||||
"symfony/cache": "^3.1",
|
|
||||||
"symfony/translation": "^2.8",
|
"symfony/translation": "^2.8",
|
||||||
"vlucas/phpdotenv": "^2.4",
|
"vlucas/phpdotenv": "^2.4",
|
||||||
"silverstripe/config": "^1@dev"
|
"silverstripe/config": "^1@dev"
|
||||||
|
@ -17,7 +17,7 @@ use Symfony\Component\Finder\Finder;
|
|||||||
/**
|
/**
|
||||||
* Factory for silverstripe configs
|
* Factory for silverstripe configs
|
||||||
*/
|
*/
|
||||||
class CoreConfigCreator
|
class CoreConfigFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var static
|
* @var static
|
@ -10,24 +10,24 @@ use SilverStripe\Core\ClassInfo;
|
|||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Object;
|
use SilverStripe\Core\Object;
|
||||||
|
|
||||||
class ExtensionMiddleware implements \SilverStripe\Config\Middleware\Middleware
|
class ExtensionMiddleware implements Middleware
|
||||||
{
|
{
|
||||||
use MiddlewareCommon;
|
use MiddlewareCommon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get config for a class
|
* Get config for a class
|
||||||
*
|
*
|
||||||
* @param string $class
|
* @param string $class Name of class
|
||||||
* @param mixed $options
|
* @param int|true $excludeMiddleware Middleware disable flags
|
||||||
* @param callable $next
|
* @param callable $next Callback to next middleware
|
||||||
* @return string
|
* @return array Complete class config
|
||||||
*/
|
*/
|
||||||
public function getClassConfig($class, $options, $next)
|
public function getClassConfig($class, $excludeMiddleware, $next)
|
||||||
{
|
{
|
||||||
// Get base config
|
// Get base config
|
||||||
$config = $next($class, $options);
|
$config = $next($class, $excludeMiddleware);
|
||||||
|
|
||||||
if (!$this->enabled($options)) {
|
if (!$this->enabled($excludeMiddleware)) {
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,22 +13,22 @@ class InheritanceMiddleware implements Middleware
|
|||||||
/**
|
/**
|
||||||
* Get config for a class
|
* Get config for a class
|
||||||
*
|
*
|
||||||
* @param string $class
|
* @param string $class Name of class
|
||||||
* @param mixed $options
|
* @param int|true $excludeMiddleware Middleware disable flags
|
||||||
* @param callable $next
|
* @param callable $next Callback to next middleware
|
||||||
* @return string
|
* @return array Complete class config
|
||||||
*/
|
*/
|
||||||
public function getClassConfig($class, $options, $next)
|
public function getClassConfig($class, $excludeMiddleware, $next)
|
||||||
{
|
{
|
||||||
// Check if enabled
|
// Check if enabled
|
||||||
if (!$this->enabled($options)) {
|
if (!$this->enabled($excludeMiddleware)) {
|
||||||
return $next($class, $options);
|
return $next($class, $excludeMiddleware);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge hierarchy
|
// Merge hierarchy
|
||||||
$config = [];
|
$config = [];
|
||||||
foreach (ClassInfo::ancestry($class) as $nextClass) {
|
foreach (ClassInfo::ancestry($class) as $nextClass) {
|
||||||
$nextConfig = $next($nextClass, $options);
|
$nextConfig = $next($nextClass, $excludeMiddleware);
|
||||||
$config = Priority::mergeArray($nextConfig, $config);
|
$config = Priority::mergeArray($nextConfig, $config);
|
||||||
}
|
}
|
||||||
return $config;
|
return $config;
|
||||||
|
@ -19,22 +19,21 @@ trait MiddlewareCommon
|
|||||||
$this->disableFlag = $disableFlag;
|
$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;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$this->disableFlag) {
|
if (!$this->disableFlag) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (is_array($options)) {
|
return ($excludeMiddleware & $this->disableFlag) !== $this->disableFlag;
|
||||||
if (!isset($options['disableFlag'])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$options = $options['disableFlag'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ($options & $this->disableFlag) !== $this->disableFlag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serialize()
|
public function serialize()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Config\CoreConfigCreator;
|
use SilverStripe\Core\Config\CoreConfigFactory;
|
||||||
use SilverStripe\Core\Config\ConfigLoader;
|
use SilverStripe\Core\Config\ConfigLoader;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Core\Injector\SilverStripeServiceConfigurationLocator;
|
use SilverStripe\Core\Injector\SilverStripeServiceConfigurationLocator;
|
||||||
@ -83,7 +83,7 @@ $moduleManifest = new ModuleManifest(BASE_PATH, false, $flush);
|
|||||||
ModuleLoader::instance()->pushManifest($moduleManifest);
|
ModuleLoader::instance()->pushManifest($moduleManifest);
|
||||||
|
|
||||||
// Build config manifest
|
// Build config manifest
|
||||||
$configManifest = CoreConfigCreator::inst()->createRoot($flush);
|
$configManifest = CoreConfigFactory::inst()->createRoot($flush);
|
||||||
ConfigLoader::instance()->pushManifest($configManifest);
|
ConfigLoader::instance()->pushManifest($configManifest);
|
||||||
|
|
||||||
// After loading config, boot _config.php files
|
// After loading config, boot _config.php files
|
||||||
|
@ -13,7 +13,7 @@ use SilverStripe\Control\Tests\FakeController;
|
|||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
use SilverStripe\Core\Config\ConfigLoader;
|
use SilverStripe\Core\Config\ConfigLoader;
|
||||||
use SilverStripe\Core\Config\CoreConfigCreator;
|
use SilverStripe\Core\Config\CoreConfigFactory;
|
||||||
use SilverStripe\Core\Config\DefaultConfig;
|
use SilverStripe\Core\Config\DefaultConfig;
|
||||||
use SilverStripe\Core\Config\Middleware\ExtensionMiddleware;
|
use SilverStripe\Core\Config\Middleware\ExtensionMiddleware;
|
||||||
use SilverStripe\Core\Flushable;
|
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
|
// Once new class loader is registered, push a new uncached config
|
||||||
$config = CoreConfigCreator::inst()->createCore();
|
$config = CoreConfigFactory::inst()->createCore();
|
||||||
ConfigLoader::instance()->pushManifest($config);
|
ConfigLoader::instance()->pushManifest($config);
|
||||||
|
|
||||||
// Invalidate classname spec since the test manifest will now pull out new subclasses for each internal class
|
// Invalidate classname spec since the test manifest will now pull out new subclasses for each internal class
|
||||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Core\Tests\Manifest;
|
|||||||
use Dotenv\Loader;
|
use Dotenv\Loader;
|
||||||
use SilverStripe\Config\Collections\MemoryConfigCollection;
|
use SilverStripe\Config\Collections\MemoryConfigCollection;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Core\Config\CoreConfigCreator;
|
use SilverStripe\Core\Config\CoreConfigFactory;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
class ConfigManifestTest extends SapphireTest
|
class ConfigManifestTest extends SapphireTest
|
||||||
@ -29,7 +29,7 @@ class ConfigManifestTest extends SapphireTest
|
|||||||
public function getTestConfig()
|
public function getTestConfig()
|
||||||
{
|
{
|
||||||
$config = new MemoryConfigCollection();
|
$config = new MemoryConfigCollection();
|
||||||
$transformer = CoreConfigCreator::inst()->buildYamlTransformerForPath(dirname(__FILE__) . '/fixtures/configmanifest');
|
$transformer = CoreConfigFactory::inst()->buildYamlTransformerForPath(dirname(__FILE__) . '/fixtures/configmanifest');
|
||||||
$config->transform([$transformer]);
|
$config->transform([$transformer]);
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user