An Aura.Session module for Ray.Di.
$ composer require ray/aura-session-module
useRay\Di\AbstractModule;
useRay\AuraSessionModule\AuraSessionModule;
class AppModule extends AbstractModule
{
protectedfunctionconfigure(): void
{
$this->install(newAuraSessionModule);
}
}useAura\Session\Session;
useMyVendor\MyPackage\MyClass;
class Index extends ResourceObject
{
publicfunction__construct(
privatereadonlySession$session
) {}
publicfunctiononGet() : static
{
// get a _Segment_ object$segment = $this->session->getSegment(MyClass::class);
// try to get a value from the segment;// if it does not exist, return an alternative valueecho$segment->get('foo'); // nullecho$segment->get('baz', 'not set'); // 'not set'
}
}