<?php namespace Sensio\Bridge\Phpmig; use Symfony\Component\DependencyInjection\ContainerInterface; /** * The ContainerAdapter allows the Symfony DIC to be used with phpmig. Phpmig is the tool that's used for executing * migrations on the application and expects a service container that implements \ArrayAccess. This is achieved by * wrapping Symfony's DIC with an adapter that implements \ArrayAccess and proxies to the DIC. * * @package Sensio\Bridge\Phpmig */ class ContainerAdapter implements \ArrayAccess { /** @var ContainerInterface */ private $dic; /** * @param ContainerInterface $container */ public function __construct(ContainerInterface $container) { $this->dic = $container; } /** * @param mixed $offset * @return bool */ public function offsetExists($offset) { return $this->dic->has($offset); } /** * @param mixed $offset * @return mixed|object */ public function offsetGet($offset) { return $this->dic->get($offset); } /** * @param mixed $offset * @param mixed $value */ public function offsetSet($offset, $value) { $this->dic->set($offset, $value); } /** * @param mixed $offset * @throws \RuntimeException */ public function offsetUnset($offset) { throw new \RuntimeException('Symfony DIC does not support the removal of services.'); } }