Пример #1
0
 public function testPublicPrivate()
 {
     $container = new Container('foo');
     $this->assertTrue($container->isPrivate(), 'New containers are private by default');
     $this->assertFalse($container->isPublic());
     $container->setPublic();
     $this->assertTrue($container->isPublic());
     $this->assertFalse($container->isPrivate());
     $container->setPrivate();
     $this->assertTrue($container->isPrivate());
     $this->assertFalse($container->isPublic());
 }
Пример #2
0
 /**
  * Create a container.
  *
  * @param string $name
  * @param bool   $private
  *
  * @throws SwiftException
  *
  * @return Container
  *
  * @see DriverInterface::createContainer()
  */
 public function createContainer($name, $private = true)
 {
     if (false === isset($this->containers[$name])) {
         $container = new Container($name);
         $private ? $container->setPrivate() : $container->setPublic();
         if (!$this->driver->createContainer($container)) {
             throw new SwiftException(sprintf('Could not create container %s', $name));
         }
         $this->containers[$name] = $container;
     }
     return $this->containers[$name];
 }