Important
You are browsing documentation for version 5.1 of OroCommerce, supported until March 2026. Read the documentation for version 6.0 (the latest LTS version) to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
Resources Loader Factory
This class provides methods for creating an instance of CumulativeConfigLoader, which allows you to load configuration files from any bundle or application level.
Specification
Resources Loader Factory provides the CumulativeConfigLoaderFactory::create('acme_data' and 'Resources/config/oro/acme.yml')
method.
This method prepares an instance of CumulativeConfigLoader with configured configuration loaders. Under the hood, the factory transforms the incoming path to configuration files with the ability to load configs from the application layer.
CumulativeConfigLoaderFactory::create('acme_data', 'Resources/config/oro/acme.yml')
It should be load configuration from:
[
# Load configuration from all bundles
"BarBundle/Resources/config/oro/acme.yml",
"FooBundle/Resources/config/oro/acme.yml",
...
# Load configuration from application-level
"config/oro/acme/app_acme.yml",
"config/oro/acme/app_acme_new.yml",
...
]
Usage Example
The following example shows how to create a new CumulativeConfigLoader instance using the CumulativeConfigLoaderFactory::create('acme_data', 'Resources/config/oro/acme.yml')
static factory method on a simple configuration provider:
namespace Oro\Bundle\AcmeBundle\Configuration;
use Oro\Component\Config\Cache\PhpArrayConfigProvider;
use Oro\Component\Config\Loader\CumulativeConfigProcessorUtil;
use Oro\Component\Config\Loader\Factory\CumulativeConfigLoaderFactory;
use Oro\Component\Config\ResourcesContainerInterface;
class AcmeConfigurationProvider extends PhpArrayConfigProvider
{
protected const CONFIG_FILE = 'Resources/config/oro/acme.yml';
public function doLoadConfig(ResourcesContainerInterface $resourcesContainer)
{
$acmeConfig = [];
/** @var CumulativeConfigLoader $configLoader */
$configLoader = CumulativeConfigLoaderFactory::create('acme_data', self::CONFIG_FILE);
$resources = $configLoader->load($resourcesContainer);
foreach ($resources as $resource) {
$acmeConfig[] = $resource->data;
}
return CumulativeConfigProcessorUtil::processConfiguration(
self::CONFIG_FILE,
new LocaleDataConfiguration(),
$acmeConfig
);
}
}