SessionBagProxy example

$this->usageReporter)();
        }

        return $this->storage->getMetadataBag();
    }

    /** * @return void */
    public function registerBag(SessionBagInterface $bag)
    {
        $this->storage->registerBag(new SessionBagProxy($bag$this->data, $this->usageIndex, $this->usageReporter));
    }

    public function getBag(string $name): SessionBagInterface
    {
        $bag = $this->storage->getBag($name);

        return method_exists($bag, 'getBag') ? $bag->getBag() : $bag;
    }

    /** * Gets the flashbag interface. */
$this->usageReporter)();
        }

        return $this->storage->getMetadataBag();
    }

    /** * @return void */
    public function registerBag(SessionBagInterface $bag)
    {
        $this->storage->registerBag(new SessionBagProxy($bag$this->data, $this->usageIndex, $this->usageReporter));
    }

    public function getBag(string $name): SessionBagInterface
    {
        $bag = $this->storage->getBag($name);

        return method_exists($bag, 'getBag') ? $bag->getBag() : $bag;
    }

    /** * Gets the flashbag interface. */
$this->assertSame($bag(new Session($storage))->getBag('foo'));
    }

    public function testGetBagWithBagNotImplementingGetBag()
    {
        $data = [];

        $bag = new AttributeBag();
        $bag->setName('foo');

        $storage = new MockArraySessionStorage();
        $storage->registerBag(new SessionBagProxy($bag$data$usageIndex, null));

        $this->assertSame($bag(new Session($storage))->getBag('foo'));
    }
}
Home | Imprint | This part of the site doesn't use cookies.