public function register(ServiceManager $manager) { $manager['example'] = $manager->share(function () use($manager) { return $manager['example.options.message']; }); }
<?php use Moriony\ServiceManager; require_once "../vendor/autoload.php"; $manager = new ServiceManager(); $manager['protected_callable'] = $manager->protect(function () { return 'Hello world!'; }); echo $manager['protected_callable']();
public function testOptionsSet() { $this->manager->register($this->serviceMock, array('test' => 'value')); $this->assertEquals('value', $this->manager['test']); }
<?php use Moriony\ServiceManager; require_once "../vendor/autoload.php"; $manager = new ServiceManager(); $manager['lazy_shared_service'] = $manager->share(function () { return 'Hello world!'; }); echo $manager['lazy_shared_service'];