-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from pulse00/feature/guzzle
Added guzzle support
- Loading branch information
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the HBStampieBundle package. | ||
* | ||
* (c) Henrik Bjornskov <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace HB\StampieBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* Class AdapterCompilerPass | ||
* @package HB\StampieBundle\DependencyInjection\Compiler | ||
*/ | ||
class AdapterCompilerPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$adapterMapping = array( | ||
'buzz' =>'hb_stampie.adapter.buzz', | ||
'guzzle.client' => 'hb_stampie.adapter.guzzle' | ||
); | ||
|
||
$this->addAdapterIfAvailable($container, $adapterMapping); | ||
} | ||
|
||
|
||
/** | ||
* @param ContainerBuilder $container | ||
* @param array $adapterMapping | ||
*/ | ||
private function addAdapterIfAvailable(ContainerBuilder $container, array $adapterMapping) | ||
{ | ||
foreach ($adapterMapping as $serviceId => $adapterId) { | ||
if ($container->has($serviceId)) { | ||
$container->getDefinition($adapterId) | ||
->addArgument(new Reference($serviceId)); | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,21 @@ | |
*/ | ||
|
||
namespace HB\StampieBundle; | ||
use HB\StampieBundle\DependencyInjection\Compiler\AdapterCompilerPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* @author Henrik Bjornskov <[email protected]> | ||
*/ | ||
class HBStampieBundle extends \Symfony\Component\HttpKernel\Bundle\Bundle | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function build(ContainerBuilder $container) | ||
{ | ||
parent::build($container); | ||
|
||
$container->addCompilerPass(new AdapterCompilerPass()); | ||
} | ||
} |
This file contains 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
This file contains 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