Phprest\Service\Hateoas\Service::register PHP Method

register() public method

public register ( League\Container\ContainerInterface $container, Phprest\Service\Configurable $config ) : void
$container League\Container\ContainerInterface
$config Phprest\Service\Configurable
return void
    public function register(ContainerInterface $container, Configurable $config)
    {
        if (!$config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }
        $hateoas = HateoasBuilder::create();
        $hateoas->setDebug($config->debug);
        $hateoas->setUrlGenerator(null, new CallableUrlGenerator($config->urlGenerator));
        if (!$config->debug) {
            $hateoas->setCacheDir($config->cacheDir);
            $hateoas->addMetadataDir($config->metadataDir);
        }
        $container->add($config->getServiceName(), $hateoas->build());
    }

Usage Example

Example #1
0
 public function setUp()
 {
     $this->container = new Container();
     $service = new Service();
     $service->register($this->container, new Config(true));
 }
All Usage Examples Of Phprest\Service\Hateoas\Service::register
Service