Last active
December 11, 2015 22:49
-
-
Save jaytaph/4672123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppKernel extends Kernel | |
{ | |
... | |
/** | |
* Add loader to load settings from /etc/bigproject/settings.conf | |
*/ | |
protected function getContainerLoader(ContainerInterface $container) | |
{ | |
$cl = parent::getContainerLoader($container); | |
// Add additional loader to the resolver | |
$resolver = $cl->getResolver(); | |
$resolver->addLoader(new BigProject\MainBundle\ConfFileLoader($container, new FileLocator(array()))); | |
return $cl; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace BigProject\MainBundle; | |
use Symfony\Component\Config\Resource\FileResource; | |
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | |
use Symfony\Component\DependencyInjection\Loader\FileLoader; | |
class ConfFileLoader extends FileLoader | |
{ | |
/** | |
* Loads a resource. | |
* | |
* @param mixed $file The resource | |
* @param string $type The resource type | |
* | |
* @throws InvalidArgumentException When ini file is not valid | |
*/ | |
public function load($file, $type = null) | |
{ | |
$path = $this->locator->locate($file); | |
$this->container->addResource(new FileResource($path)); | |
$result = parse_ini_file($path, true); | |
if (false === $result || array() === $result) { | |
throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $file)); | |
} | |
foreach ($result as $key => $section) { | |
foreach ($section as $name => $value) { | |
$this->container->setParameter($key.".".$name, $value); | |
} | |
} | |
} | |
/** | |
* Returns true if this class supports the given resource. | |
* | |
* @param mixed $resource A resource | |
* @param string $type The resource type | |
* | |
* @return Boolean true if this class supports the given resource, false otherwise | |
*/ | |
public function supports($resource, $type = null) | |
{ | |
return is_string($resource) && 'conf' === pathinfo($resource, PATHINFO_EXTENSION); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imports: | |
- { resource: parameters.yml } | |
.... | |
markup_solarium: | |
clients: | |
default: | |
host: %solr.host% | |
port: %solr.port% | |
path: %solr.path% | |
core: %solr.core% | |
timeout: 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[solr] | |
host = 10.10.1.10 | |
port = 8080 | |
path = /solr | |
core = mycore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameters: | |
solr.host: 10.10.1.10 | |
solr.port: 8080 | |
solr.path: /solr | |
solr.core: mycore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment