Skip to content

Commit

Permalink
bundle cleanup, followed by http://php-and-symfony.matthiasnoback.nl/…
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Preusner committed Dec 12, 2013
1 parent 91c7965 commit 5eb2dc7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.DS_STORE
coverage

# Ignore IDE settings
/.idea
/atlassian-ide-plugin.xml

# Ignore potentially sensitive phpunit file
phpunit.xml

Expand All @@ -12,4 +16,4 @@ composer-test.lock
vendor/

# Ignore subsplit working directory
.subsplit
.subsplit
20 changes: 16 additions & 4 deletions DependencyInjection/GuzzleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ class GuzzleExtension extends Extension {
*/
public function load(array $configs, ContainerBuilder $container) {

$loader = new XmlFileLoader(
$container,
new FileLocator(implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', 'Resources', 'config')))
);
$configPath = implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', 'Resources', 'config'));
$loader = new XmlFileLoader($container, new FileLocator($configPath));

$loader->load('services.xml');

Expand Down Expand Up @@ -103,4 +101,18 @@ protected function setUpWsse(array $config, ContainerBuilder $container) {
->addMethodCall('addSubscriber', array($container->getDefinition('guzzle.plugin.wsse')));
}
} // end: setUpWsse

/**
* Returns alias of class
*
* @author Florian Preusner
* @version 1.1
* @since 2013-12
*
* @return string
*/
public function getAlias() {

return 'guzzle';
} // end: getAlias
} // end: GuzzleExtension
38 changes: 37 additions & 1 deletion GuzzleBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace EightPoints\Bundle\GuzzleBundle;

use EightPoints\Bundle\GuzzleBundle\DependencyInjection\GuzzleExtension;

use Symfony\Component\HttpKernel\Bundle\Bundle,
Symfony\Component\DependencyInjection\ContainerBuilder;
Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\DependencyInjection\Extension\ExtensionInterface;

/**
* Class GuzzleBundle
Expand Down Expand Up @@ -32,4 +35,37 @@ public function build(ContainerBuilder $container) {

parent::build($container);
} // end: build

/**
* Overwrite getContainerExtension
* - no naming convention of alias needed
* - extension class can be moved easily now
*
* @see getContainerExtension
*
* @author Florian Preusner
* @version 1.1
* @since 2013-12
*
* @return ExtensionInterface|null The container extension
* @throws \LogicException
*/
public function getContainerExtension() {

if(null === $this->extension) {

$extension = new GuzzleExtension();

if(!$extension instanceof ExtensionInterface) {

$message = sprintf('%s is not a instance of ExtensionInterface', $extension->getClass());

throw new \LogicException($message);
}

$this->extension = $extension;
}

return $this->extension;
} // end: getContainerExtension
} // end: GuzzleBundle

0 comments on commit 5eb2dc7

Please sign in to comment.