/** * SymfonyApplicationContext constructor. * Note, Bounce's import code currently will NOT use Symfony's config loaders, it will use a bounce internal file * loader. Non bounce configs cannot be imported from a bounce context. * However, by passing a different LoaderFactory to this constructor you can load something that isn't a bounce * context into a new container wrapped to look like bounce.... potentially that config could include a bounce * context itself... Though your Loader will need to deal with both Symfony's XMLFileLoader and the BounceFileLoader * claiming the .xml file extension! * * @param string $contextFile Bounce context to load * @param string[] $customNamespaces Map of namespace names to ValueProvider of any custom namespaces. * @param string $cacheDir Directory that cached proxies and the compiled context should be loaded into. If this is * null, you will have no caching. Compilation will be required every single time this is constructed, and be slow. * @param bool $isDebug If true, check that the compiled context cache isn't stale every request. * @param LoaderFactory $loaderFactory Alternative Symfony config loader to use to load $contextFile. */ public function __construct($contextFile, array $customNamespaces = [], $cacheDir = null, $isDebug = false, LoaderFactory $loaderFactory = null) { if ($loaderFactory === null) { if ($cacheDir) { $proxyStore = new FilesProxyStore($cacheDir . DIRECTORY_SEPARATOR . 'proxies'); } else { $proxyStore = new InMemoryProxyStore(); } $proxyGeneratorFactory = new ProxyGeneratorFactory($proxyStore); $loaderFactory = new DefaultLoaderFactory($customNamespaces, $proxyGeneratorFactory); } if ($cacheDir) { $containerBuilder = $this->getContainerBuilderCached($contextFile, $cacheDir, $isDebug, $loaderFactory); } else { $containerBuilder = $this->buildContainer($contextFile, $loaderFactory); } parent::__construct(new SymfonyContainerBeanFactory($containerBuilder)); }
/** * @param $xmlFilePath * @param bool $shareBeanCache whether to share the bean cache when the context's uniqueID (file path) is the same. * @param ValueTagProvider[] $customNamespaces * @throws \MooDev\Bounce\Exception\BounceException */ public function __construct($xmlFilePath, $shareBeanCache = true, $customNamespaces = array()) { $contextConfig = (new XmlContextParser($xmlFilePath, $customNamespaces))->getContext(); //Create the bean factory parent::__construct(BeanFactory::getInstance($contextConfig, $shareBeanCache)); }
/** * @param $xmlFilePath * @param bool $shareBeanCache whether to share the bean cache when the context's uniqueID (file path) is the same. * @param ValueTagProvider[] $customNamespaces * @param array $logFactory */ public function __construct($xmlFilePath, $shareBeanCache = true, $customNamespaces = array(), $logFactory = array('\\MooDev\\Bounce\\Logger\\NullLogFactory', 'getLog')) { $contextConfig = (new XmlContextParser($xmlFilePath, $customNamespaces))->getContext(); //Create the bean factory parent::__construct(BeanFactory::getInstance($contextConfig, $shareBeanCache)); }