<?php

namespace Acms\Services\View;

use Acms\Contracts\ServiceProvider;
use Acms\Services\Container;

class ViewServiceProvider extends ServiceProvider
{
    /**
     * register service
     *
     * @param \Acms\Services\Container $container
     *
     * @return void
     */
    public function register(Container $container)
    {
        $container->bind('view', 'Acms\Services\View\Engine');
        $container->singleton('view.build-context', 'Acms\Services\View\BuildContext');
        $container->singleton('view.js-modules', function () use ($container) {
            /** @var \Acms\Services\Url\ManagedDomainRegistry $managedDomainRegistry */
            $managedDomainRegistry = $container->make('url.managed-domain');
            /** @var \Acms\Services\Url\DeliveryUrlRewriter $deliveryUrlRewriter */
            $deliveryUrlRewriter = $container->make('url.delivery-rewriter');
            return new JsModulesBuilder($managedDomainRegistry, $deliveryUrlRewriter);
        });
    }

    /**
     * initialize service
     *
     * @return void
     */
    public function init()
    {
    }
}
