Skip to content

Instantly share code, notes, and snippets.

@cherifGsoul cherifGsoul/Container.php
Last active Jan 3, 2017

Embed
What would you like to do?
Yii2 container decorated with container-interop
<?php
use Interop\Container\ContainerInterface;
$container = Yii::$container;
$container->set(ContainerInterface::class, function($container){
return new \app\components\Container($container);
});
<?php
namespace app\components;
use Interop\Container\ContainerInterface;
class Container implements ContainerInterface
{
private $wrappedContainer;
function __construct($container)
{
$this->wrappedContainer = $container;
}
public function get($id)
{
return $this->wrappedContainer->get($id);
}
public function has($id)
{
return $this->wrappedContainer->has($id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.