<?php

/*
 * This file is part of PHP-SwfTools.
 *
 * (c) Alchemy <info@alchemy.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace SwfTools;

use SwfTools\Binary\DriverContainer;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use SwfTools\Processor\FlashFile;
use SwfTools\Processor\PDFFile;

class SwfToolsServiceProvider implements ServiceProviderInterface
{
    public function register(Container $app)
    {
        $app['swftools.default.configuration'] = array(
            'pdf2swf.binaries'    => 'pdf2swf',
            'swfrender.binaries'  => 'swfrender',
            'swfextract.binaries' => 'swfextract',
            'timeout'             => 60,
        );
        $app['swftools.configuration'] = array();
        $app['swftools.logger'] = null;

        $app['swftools.driver-container'] = function ($c) {
            $app['swftools.configuration'] = array_replace(
                $c['swftools.default.configuration'], 
                $c['swftools.configuration']
            );

            return DriverContainer::create($app['swftools.configuration'], $c['swftools.logger']);
        };

        $app['swftools.pdf-file'] = function ($c) {
            return new PDFFile($c['swftools.driver-container']);
        };

        $app['swftools.flash-file'] = function ($c) {
            return new FlashFile($c['swftools.driver-container']);
        };
    }

    public function boot(Container $app)
    {
    }
}
