Flintstones\Rest\ServiceProvider::register PHP Method

register() public method

public register ( Silex\Application $app )
$app Silex\Application
    public function register(Application $app)
    {
        $app['rest.serializer'] = $app->share(function () {
            $encoders = array('json' => new JsonEncoder(), 'xml' => new XmlEncoder());
            $serializer = new Serializer(array(), $encoders);
            return $serializer;
        });
        if (!isset($app['rest.priorities'])) {
            $app['rest.priorities'] = array('json', 'xml');
        }
        $app['rest.format_negotiator'] = function ($app) {
            return new FormatNegotiator($app['request'], $app['rest.priorities']);
        };
        $app['rest.decoder.json'] = function ($app) {
            return new JsonDecoder();
        };
        $app['rest.decoder.xml'] = function ($app) {
            return new XmlDecoder();
        };
        $app['rest.decoders'] = isset($app['rest.decoders']) ? $app['rest.decoders'] : array('json' => 'rest.decoder.json', 'xml' => 'rest.decoder.xml');
        if (isset($app['rest.fos.class_path'])) {
            $app['autoloader']->registerNamespace('FOS\\RestBundle', $app['rest.fos.class_path']);
        }
        if (isset($app['rest.serializer.class_path'])) {
            $app['autoloader']->registerNamespace('Symfony\\Component\\Serializer', $app['rest.serializer.class_path']);
        }
        $listener = new BodyListener(new PimpleDecoderProvider($app, $app['rest.decoders']));
        $app['dispatcher']->addListener(HttpKernelEvents::REQUEST, array($listener, 'onKernelRequest'));
        $listener = new FormatListener($app['rest.format_negotiator'], 'html', $app['rest.priorities']);
        $app['dispatcher']->addListener(HttpKernelEvents::CONTROLLER, array($listener, 'onKernelController'), 10);
    }
ServiceProvider