Files
Phraseanet/lib/classes/binaryAdapter/adapterAbstract.class.php
Romain Neutron 4c5b7eb658 V 3.5 RC 1
2011-12-05 00:23:28 +01:00

81 lines
1.8 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Abastract adapter object for binaryAdapter
*
* @package binaryAdapter
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
abstract class binaryAdapter_adapterAbstract extends binaryAdapter_abstract implements binaryAdapter_adapterInterface
{
/**
*
* @param registry $registry
* @return binaryAdapter_adapterAbstract
*/
public function __construct(registry $registry)
{
$this->registry = $registry;
return $this;
}
/**
*
* @param system_file $origine
* @param string $dest
* @param array $options
* @return system_file
*/
public function execute(system_file $origine, $dest, Array $options)
{
$processors = array();
foreach ($this->processors as $k => $proc)
{
try
{
$processors[$k] = new $proc($this->registry);
$this->log("" . $proc . " disponible");
}
catch (Exception $e)
{
unset($processors[$k]);
$this->log($proc . " indisponible : " . $e->getMessage());
}
}
$done = $resized = false;
while (!$done && count($processors) > 0)
{
try
{
$proc = array_shift($processors);
$resized = $proc->execute($origine, $dest, $options);
$done = true;
$this->log("effectuee ! ");
}
catch (Exception $e)
{
$this->log($e->getMessage());
}
}
if ($resized instanceof system_file)
return $resized;
throw new Exception('None of the processor where able to perform ' . $this->get_name());
}
abstract public function get_name();
}