add method getFromWithTo()

This commit is contained in:
Uwe Steinmann 2023-04-13 09:05:03 +02:00
parent 762ccbb373
commit a067cc9949

View File

@ -38,23 +38,39 @@ class SeedDMS_ConversionMgr {
*/ */
protected $success; protected $success;
public function __construct() { public function __construct() { /* {{{ */
$this->services = array(); $this->services = array();
$this->success = true; $this->success = true;
} } /* }}} */
public function addService($service) { public function addService($service) { /* {{{ */
$service->setConversionMgr($this); $service->setConversionMgr($this);
$this->services[$service->from][$service->to][] = $service; $this->services[$service->from][$service->to][] = $service;
return $service; return $service;
} } /* }}} */
public function hasService($from, $to) { public function hasService($from, $to) { /* {{{ */
if(!empty($this->services[$from][$to])) if(!empty($this->services[$from][$to]))
return true; return true;
else else
return false; return false;
} } /* }}} */
/**
* Return the list of mimetypes which can be converted
* into the given mimetype
*
* @param string $askto mimetype to be converted into
* @return array list of from mimetypes
*/
public function getFromWithTo($askto) { /* {{{ */
$fromret = [];
foreach($this->services as $from=>$toservices)
foreach($toservices as $to=>$service)
if($to == $askto)
$fromret[] = $from;
return $fromret;
} /* }}} */
/** /**
* Return the service that would be tried first for converting * Return the service that would be tried first for converting