From e01088d38d062a505c6f9b0d9627605f9ff6a86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Thu, 3 Mar 2016 19:34:56 +0100 Subject: [PATCH 1/9] Add RecordReference into record_adapter --- .../Phrasea/Record/RecordReference.php | 84 ++++++++++ lib/classes/record/adapter.php | 149 ++++++++++-------- 2 files changed, 164 insertions(+), 69 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Record/RecordReference.php diff --git a/lib/Alchemy/Phrasea/Record/RecordReference.php b/lib/Alchemy/Phrasea/Record/RecordReference.php new file mode 100644 index 0000000000..5c91a7650e --- /dev/null +++ b/lib/Alchemy/Phrasea/Record/RecordReference.php @@ -0,0 +1,84 @@ +databoxId = (int)$databoxId; + $this->recordId = (int)$recordId; + } + + /** + * @param int $databoxId + * @param int $recordId + * @return RecordReference + */ + public static function createFromDataboxIdAndRecordId($databoxId, $recordId) + { + return new self($databoxId, $recordId); + } + + /** + * @param string $reference + * @return RecordReference + */ + public static function createFromRecordReference($reference) + { + $array = explode('_', $reference); + + Assertion::count($array, 2); + + list($databoxId, $recordId) = $array; + + return new self($databoxId, $recordId); + } + + /** + * @return string + */ + public function getId() + { + return sprintf('%d_%d', $this->databoxId, $this->recordId); + } + + /** + * @return int + */ + public function getDataboxId() + { + return $this->databoxId; + } + + /** + * @return int + */ + public function getRecordId() + { + return $this->recordId; + } +} diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 0119b13db2..8318b48efb 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -29,11 +29,14 @@ use Alchemy\Phrasea\Media\TechnicalData; use Alchemy\Phrasea\Media\TechnicalDataSet; use Alchemy\Phrasea\Metadata\Tag\TfBasename; use Alchemy\Phrasea\Metadata\Tag\TfFilename; +use Alchemy\Phrasea\Model\Entities\OrderElement; use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\RecordInterface; use Alchemy\Phrasea\Model\Serializer\CaptionSerializer; +use Alchemy\Phrasea\Record\RecordReference; use Alchemy\Phrasea\SearchEngine\SearchEngineInterface; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; +use Doctrine\DBAL\Connection; use Doctrine\ORM\EntityManager; use MediaVorus\MediaVorus; use Ramsey\Uuid\Uuid; @@ -60,9 +63,23 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return $app['phraseanet.filesystem']; } + /** + * @var Application + */ + protected $app; + + /** + * @var RecordReference; + */ + private $reference; + + /** + * @var Connection|null + */ + private $connection; + private $base_id; private $collection_id; - private $record_id; private $mime; private $number; private $status; @@ -71,8 +88,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface private $sha256; private $isStory; private $duration; - /** @var databox */ - private $databox; /** @var DateTime */ private $created; /** @var string */ @@ -83,8 +98,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface private $uuid; /** @var DateTime */ private $updated; - /** @var Application */ - protected $app; /** * @param Application $app @@ -96,9 +109,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function __construct(Application $app, $sbas_id, $record_id, $number = null, $load = true) { $this->app = $app; - $this->databox = $this->app->findDataboxById((int) $sbas_id); + $this->reference = RecordReference::createFromDataboxIdAndRecordId($sbas_id, $record_id); $this->number = (int) $number; - $this->record_id = (int) $record_id; if ($load) { $this->load(); @@ -107,8 +119,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface protected function load() { - if (null === $record = $this->getDatabox()->getRecordRepository()->find($this->record_id)) { - throw new Exception_Record_AdapterNotFound('Record ' . $this->record_id . ' on database ' . $this->getDataboxId() . ' not found '); + if (null === $record = $this->getDatabox()->getRecordRepository()->find($this->getRecordId())) { + throw new Exception_Record_AdapterNotFound('Record ' . $this->getRecordId() . ' on database ' . $this->getDataboxId() . ' not found '); } $this->mirror($record); @@ -222,10 +234,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface throw new Exception('unrecognized document type'); } - $connbas = $this->databox->get_connection(); - $sql = 'UPDATE record SET moddate = NOW(), type = :type WHERE record_id = :record_id'; - $connbas->executeUpdate($sql, ['type' => $type, 'record_id' => $this->getRecordId()]); + $this->getDataboxConnection()->executeUpdate($sql, ['type' => $type, 'record_id' => $this->getRecordId()]); if ($old_type !== $type) { $this->rebuild_subdefs(); @@ -239,7 +249,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function touch() { - $this->databox->get_connection()->executeUpdate( + $this->getDatabox()->get_connection()->executeUpdate( 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id', ['record_id' => $this->getRecordId()] ); @@ -280,7 +290,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface throw new \Exception(sprintf('Unrecognized mime type %s', $mime)); } - if ($this->databox->get_connection()->executeUpdate( + if ($this->getDatabox()->get_connection()->executeUpdate( 'UPDATE record SET moddate = NOW(), mime = :mime WHERE record_id = :record_id', array(':mime' => $mime, ':record_id' => $this->getRecordId()) )) { @@ -363,7 +373,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function get_collection() { - return \collection::getByCollectionId($this->app, $this->databox, $this->collection_id); + return \collection::getByCollectionId($this->app, $this->getDatabox(), $this->collection_id); } /** @@ -379,7 +389,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function getRecordId() { - return $this->record_id; + return $this->reference->getRecordId(); } /** @@ -396,7 +406,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function getDatabox() { - return $this->databox; + return $this->app->findDataboxById($this->reference->getDataboxId()); } /** @@ -458,7 +468,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $params = [ ':coll_id' => $collection->get_coll_id(), - ':record_id' => $this->getRecordId() + ':record_id' => $this->getRecordId(), ]; $stmt = $this->getDatabox()->get_connection()->prepare($sql); @@ -609,7 +619,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $type = $this->isStory() ? 'image' : $this->getType(); - foreach ($this->databox->get_subdef_structure() as $group => $databoxSubdefs) { + foreach ($this->getDatabox()->get_subdef_structure() as $group => $databoxSubdefs) { if ($type != $group) { continue; @@ -673,9 +683,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return $data; } - $connbas = $this->getDatabox()->get_connection(); - - $rs = $connbas->fetchAll( + $rs = $this->getDataboxConnection()->fetchAll( 'SELECT name FROM subdef s LEFT JOIN record r ON s.record_id = r.record_id WHERE r.record_id = :record_id', ['record_id' => $this->getRecordId()] ); @@ -917,13 +925,12 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ protected function set_xml(DOMDocument $dom_doc) { - $connbas = $this->getDatabox()->get_connection(); $sql = 'UPDATE record SET moddate = NOW(), xml = :xml WHERE record_id= :record_id'; - $stmt = $connbas->prepare($sql); + $stmt = $this->getDataboxConnection()->prepare($sql); $stmt->execute( [ ':xml' => $dom_doc->saveXML(), - ':record_id' => $this->record_id + ':record_id' => $this->getRecordId(), ] ); $stmt->closeCursor(); @@ -1013,7 +1020,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface continue; } - $this->set_metadata($param, $this->databox); + $this->set_metadata($param, $this->getDatabox()); } $xml = new DOMDocument(); @@ -1032,10 +1039,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function rebuild_subdefs() { - $databox = $this->app->findDataboxById($this->getDataboxId()); - $connbas = $databox->get_connection(); $sql = 'UPDATE record SET jeton=(jeton | :make_subdef_mask) WHERE record_id = :record_id'; - $stmt = $connbas->prepare($sql); + $stmt = $this->getDataboxConnection()->prepare($sql); $stmt->execute([ ':record_id' => $this->getRecordId(), 'make_subdef_mask' => PhraseaTokens::MAKE_SUBDEF, @@ -1083,9 +1088,9 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function write_metas() { $tokenMask = PhraseaTokens::WRITE_META_DOC | PhraseaTokens::WRITE_META_SUBDEF; - $this->databox->get_connection()->executeUpdate( + $this->getDatabox()->get_connection()->executeUpdate( 'UPDATE record SET jeton = jeton | :tokenMask WHERE record_id= :record_id', - ['tokenMask' => $tokenMask, 'record_id' => $this->record_id] + ['tokenMask' => $tokenMask, 'record_id' => $this->getRecordId()] ); return $this; @@ -1097,11 +1102,11 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function set_binary_status($status) { - $connection = $this->databox->get_connection(); + $connection = $this->getDatabox()->get_connection(); $connection->executeUpdate( 'UPDATE record SET moddate = NOW(), status = :status WHERE record_id= :record_id', - ['status' => bindec($status), 'record_id' => $this->record_id] + ['status' => bindec($status), 'record_id' => $this->getRecordId()] ); $this->delete_data_from_cache(self::CACHE_STATUS); @@ -1156,7 +1161,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $stmt->execute([ ':log_id' => $log_id, ':record_id' => $story_id, - ':coll_id' => $collection->get_coll_id() + ':coll_id' => $collection->get_coll_id(), ]); $stmt->closeCursor(); } catch (\Exception $e) { @@ -1209,7 +1214,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $stmt->execute([ ':log_id' => $log_id, ':record_id' => $record_id, - ':coll_id' => $file->getCollection()->get_coll_id() + ':coll_id' => $file->getCollection()->get_coll_id(), ]); $stmt->closeCursor(); } catch (\Exception $e) { @@ -1270,7 +1275,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface 'null', $connection->quote($this->getRecordId()), $connection->quote($name), - $connection->quote($value) + $connection->quote($value), )); } $sql = "INSERT INTO technical_datas (id, record_id, name, value)" @@ -1348,7 +1353,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function delete() { - $connbas = $this->getDatabox()->get_connection(); + $connection = $this->getDataboxConnection(); $ftodel = []; foreach ($this->get_subdefs() as $subdef) { @@ -1376,58 +1381,58 @@ class record_adapter implements RecordInterface, cache_cacheableInterface ->log($this, Session_Logger::EVENT_DELETE, $origcoll, $xml); $sql = "DELETE FROM record WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM metadatas WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM prop WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM idx WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM permalinks WHERE subdef_id IN (SELECT subdef_id FROM subdef WHERE record_id=:record_id)"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM subdef WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM technical_datas WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM thit WHERE record_id = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM regroup WHERE rid_parent = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $sql = "DELETE FROM regroup WHERE rid_child = :record_id"; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); $stmt->closeCursor(); $orderElementRepository = $this->app['repo.order-elements']; - /* @var $repository Alchemy\Phrasea\Model\Repositories\OrderElementRepository */ + /** @var OrderElement $order_element */ foreach ($orderElementRepository->findBy(['recordId' => $this->getRecordId()]) as $order_element) { if ($order_element->getSbasId($this->app) == $this->getDataboxId()) { $this->app['orm.em']->remove($order_element); @@ -1436,7 +1441,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $basketElementRepository = $this->app['repo.basket-elements']; - /* @var $repository Alchemy\Phrasea\Model\Repositories\BasketElementRepository */ foreach ($basketElementRepository->findElementsByRecord($this) as $basket_element) { $this->app['orm.em']->remove($basket_element); } @@ -1458,7 +1462,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function get_cache_key($option = null) { - return 'record_' . $this->get_serialize_key() . ($option ? '_' . $option : ''); + return 'record_' . $this->getId() . ($option ? '_' . $option : ''); } public function clearSubdefCache($subdefname) @@ -1513,9 +1517,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function log_view($log_id, $referrer, $gv_sit) { - $databox = $this->app->findDataboxById($this->getDataboxId()); - $connbas = $databox->get_connection(); - $sql = "INSERT INTO log_view (id, log_id, date, record_id, referrer, site_id)" . " VALUES (null, :log_id, now(), :rec, :referrer, :site)"; @@ -1523,9 +1524,9 @@ class record_adapter implements RecordInterface, cache_cacheableInterface ':log_id' => $log_id , ':rec' => $this->getRecordId() , ':referrer' => $referrer - , ':site' => $gv_sit + , ':site' => $gv_sit, ]; - $stmt = $connbas->prepare($sql); + $stmt = $this->getDataboxConnection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -1533,7 +1534,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface } /** - * @var Array + * @var array */ protected $container_basket; @@ -1630,7 +1631,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface . " ORDER BY g.ord ASC, dateadd ASC, record_id ASC"; $params = [ - ':record_id' => $this->getRecordId() + ':record_id' => $this->getRecordId(), ]; } @@ -1702,13 +1703,13 @@ class record_adapter implements RecordInterface, cache_cacheableInterface throw new \Exception('Only stories can append children'); } - $connbas = $this->getDatabox()->get_connection(); - $ord = 0; $sql = "SELECT (max(ord)+1) as ord FROM regroup WHERE rid_parent = :parent_record_id"; - $stmt = $connbas->prepare($sql); + $connection = $this->getDataboxConnection(); + + $stmt = $connection->prepare($sql); $stmt->execute([':parent_record_id' => $this->getRecordId()]); @@ -1726,10 +1727,10 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $params = [ ':parent_record_id' => $this->getRecordId() , ':record_id' => $record->getRecordId() - , ':ord' => $ord + , ':ord' => $ord, ]; - $stmt = $connbas->prepare($sql); + $stmt = $connection->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -1745,16 +1746,14 @@ class record_adapter implements RecordInterface, cache_cacheableInterface throw new \Exception('Only stories can append children'); } - $connbas = $this->getDatabox()->get_connection(); - $sql = "DELETE FROM regroup WHERE rid_parent = :parent_record_id AND rid_child = :record_id"; $params = [ ':parent_record_id' => $this->getRecordId() - , ':record_id' => $record->getRecordId() + , ':record_id' => $record->getRecordId(), ]; - $stmt = $connbas->prepare($sql); + $stmt = $this->getDataboxConnection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -1766,7 +1765,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface /** {@inheritdoc} */ public function getDataboxId() { - return $this->getDatabox()->get_sbas_id(); + return $this->reference->getDataboxId(); } /** {@inheritdoc} */ @@ -1784,7 +1783,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface /** {@inheritdoc} */ public function getId() { - return $this->get_serialize_key(); + return $this->reference->getId(); } public function setStatus($status) @@ -1808,7 +1807,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function getStatusStructure() { - return $this->databox->getStatusStructure(); + return $this->getDatabox()->getStatusStructure(); } public function putInCache() @@ -1902,4 +1901,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface } } } + + /** + * @return Connection + */ + private function getDataboxConnection() + { + if (null === $this->connection) { + $this->connection = $this->getDatabox()->get_connection(); + } + + return $this->connection; + } } From 5ee7f3689a41536f578240edb90a368401fe76f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Fri, 4 Mar 2016 14:19:56 +0100 Subject: [PATCH 2/9] Use recently added getDataboxConnection method --- lib/classes/record/adapter.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 8318b48efb..d31673b057 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -249,7 +249,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function touch() { - $this->getDatabox()->get_connection()->executeUpdate( + $this->getDataboxConnection()->executeUpdate( 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id', ['record_id' => $this->getRecordId()] ); @@ -290,7 +290,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface throw new \Exception(sprintf('Unrecognized mime type %s', $mime)); } - if ($this->getDatabox()->get_connection()->executeUpdate( + if ($this->getDataboxConnection()->executeUpdate( 'UPDATE record SET moddate = NOW(), mime = :mime WHERE record_id = :record_id', array(':mime' => $mime, ':record_id' => $this->getRecordId()) )) { @@ -471,7 +471,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface ':record_id' => $this->getRecordId(), ]; - $stmt = $this->getDatabox()->get_connection()->prepare($sql); + $stmt = $this->getDataboxConnection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -546,7 +546,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return $data; } - $status = $this->getDatabox()->get_connection()->fetchColumn( + $status = $this->getDataboxConnection()->fetchColumn( 'SELECT BIN(status) as status FROM record WHERE record_id = :record_id', [':record_id' => $this->getRecordId()] ); @@ -813,7 +813,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface } } - $this->getDatabox()->get_connection()->executeUpdate( + $this->getDataboxConnection()->executeUpdate( 'UPDATE record SET moddate = NOW(), originalname = :originalname WHERE record_id = :record_id', ['originalname' => $original_name, 'record_id' => $this->getRecordId()] ); @@ -1088,7 +1088,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface public function write_metas() { $tokenMask = PhraseaTokens::WRITE_META_DOC | PhraseaTokens::WRITE_META_SUBDEF; - $this->getDatabox()->get_connection()->executeUpdate( + $this->getDataboxConnection()->executeUpdate( 'UPDATE record SET jeton = jeton | :tokenMask WHERE record_id= :record_id', ['tokenMask' => $tokenMask, 'record_id' => $this->getRecordId()] ); @@ -1102,7 +1102,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface */ public function set_binary_status($status) { - $connection = $this->getDatabox()->get_connection(); + $connection = $this->getDataboxConnection(); $connection->executeUpdate( 'UPDATE record SET moddate = NOW(), status = :status WHERE record_id= :record_id', @@ -1254,7 +1254,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return $this; } - $connection = $this->getDatabox()->get_connection(); + $connection = $this->getDataboxConnection(); $sql = 'DELETE FROM technical_datas WHERE record_id = :record_id'; $stmt = $connection->prepare($sql); $stmt->execute([':record_id' => $this->getRecordId()]); @@ -1635,7 +1635,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface ]; } - $stmt = $this->getDatabox()->get_connection()->prepare($sql); + $stmt = $this->getDataboxConnection()->prepare($sql); $stmt->execute($params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -1675,7 +1675,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface . " ON (g.rid_parent = r.record_id)\n" . " WHERE rid_child = :record_id"; - $stmt = $this->getDatabox()->get_connection()->prepare($sql); + $stmt = $this->getDataboxConnection()->prepare($sql); $stmt->execute([ ':site' => $this->app['conf']->get(['main', 'key']), ':usr_id' => $this->app->getAuthenticatedUser()->getId(), @@ -1877,7 +1877,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface { $sql = 'SELECT name, value FROM technical_datas WHERE record_id = :record_id'; - return $this->getDatabox()->get_connection() + return $this->getDataboxConnection() ->fetchAll($sql, ['record_id' => $this->getRecordId()]); } From b0330d8f56832bef572a24f10cf58762ee9bbd03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Fri, 4 Mar 2016 15:27:00 +0100 Subject: [PATCH 3/9] Added RecordReferenceCollection utility method --- .../Phrasea/Controller/Api/V1Controller.php | 8 +- lib/Alchemy/Phrasea/Model/RecordInterface.php | 17 +-- .../Model/RecordReferenceInterface.php | 29 +++++ .../Phrasea/Record/RecordReference.php | 3 +- .../Record/RecordReferenceCollection.php | 100 ++++++++++++++++++ .../SearchEngineResultToRecordsConverter.php | 74 ------------- 6 files changed, 136 insertions(+), 95 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Model/RecordReferenceInterface.php create mode 100644 lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php delete mode 100644 lib/Alchemy/Phrasea/SearchEngine/SearchEngineResultToRecordsConverter.php diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index 9cd1819e4f..f9a075111c 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -54,11 +54,11 @@ use Alchemy\Phrasea\Model\Repositories\FeedEntryRepository; use Alchemy\Phrasea\Model\Repositories\FeedRepository; use Alchemy\Phrasea\Model\Repositories\LazaretFileRepository; use Alchemy\Phrasea\Model\Repositories\TaskRepository; +use Alchemy\Phrasea\Record\RecordReferenceCollection; use Alchemy\Phrasea\SearchEngine\SearchEngineInterface; use Alchemy\Phrasea\SearchEngine\SearchEngineLogger; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineResult; -use Alchemy\Phrasea\SearchEngine\SearchEngineResultToRecordsConverter; use Alchemy\Phrasea\SearchEngine\SearchEngineSuggestion; use Alchemy\Phrasea\Status\StatusStructure; use Alchemy\Phrasea\TaskManager\LiveInformation; @@ -1067,10 +1067,10 @@ class V1Controller extends Controller $ret['results'] = ['records' => [], 'stories' => []]; - $converter = new SearchEngineResultToRecordsConverter($this->getApplicationBox()); - /** @var SearchEngineResult $search_result */ - foreach ($converter->convert($search_result->getResults()) as $record) { + $references = new RecordReferenceCollection($search_result->getResults()); + + foreach ($references->toRecords($this->getApplicationBox()) as $record) { if ($record->isStory()) { $ret['results']['stories'][] = $this->listStory($request, $record); } else { diff --git a/lib/Alchemy/Phrasea/Model/RecordInterface.php b/lib/Alchemy/Phrasea/Model/RecordInterface.php index e1ff83c847..fb2e47fe0b 100644 --- a/lib/Alchemy/Phrasea/Model/RecordInterface.php +++ b/lib/Alchemy/Phrasea/Model/RecordInterface.php @@ -2,13 +2,8 @@ namespace Alchemy\Phrasea\Model; -interface RecordInterface +interface RecordInterface extends RecordReferenceInterface { - /** - * @return string - */ - public function getId(); - /** * The unique id of the collection where belong the record. * @@ -26,13 +21,6 @@ interface RecordInterface /** @return \DateTime */ public function getCreated(); - /** - * The id of the databox where belong the record. - * - * @return integer - */ - public function getDataboxId(); - /** @return boolean */ public function isStory(); @@ -42,9 +30,6 @@ interface RecordInterface /** @return string */ public function getOriginalName(); - /** @return integer */ - public function getRecordId(); - /** @return string */ public function getSha256(); diff --git a/lib/Alchemy/Phrasea/Model/RecordReferenceInterface.php b/lib/Alchemy/Phrasea/Model/RecordReferenceInterface.php new file mode 100644 index 0000000000..6049921cfb --- /dev/null +++ b/lib/Alchemy/Phrasea/Model/RecordReferenceInterface.php @@ -0,0 +1,29 @@ + $records + * @return RecordReferenceCollection + */ + public static function fromArrayOfArray($records) + { + Assertion::allIsArrayAccessible($records); + + $references = []; + + foreach ($records as $index => $record) { + if (isset($record['id'])) { + $references[$index] = RecordReference::createFromRecordReference($record['id']); + } elseif (isset($record['databox_id']) && isset($record['record_id'])) { + $references[$index] = RecordReference::createFromDataboxIdAndRecordId($record['databox_id'], $record['record_id']); + } + } + + return new self($references); + } + + /** + * @var RecordReference[] + */ + private $references = []; + + /** + * @param RecordReference[] $references + */ + public function __construct($references) + { + Assertion::allIsInstanceOf($references, RecordReference::class); + + $this->references = $references; + } + + public function getIterator() + { + return new \ArrayIterator($this->references); + } + + /** + * @return array> + */ + public function groupPerDataboxId() + { + $groups = []; + + foreach ($this->references as $index => $reference) { + $databoxId = $reference->getDataboxId(); + + if (!isset($groups[$databoxId])) { + $groups[$databoxId] = []; + } + + $groups[$databoxId][$reference->getRecordId()] = $index; + } + + return $groups; + } + + /** + * @param \appbox $appbox + * @return \record_adapter[] + */ + public function toRecords(\appbox $appbox) + { + $groups = $this->groupPerDataboxId(); + + $records = []; + + foreach ($groups as $databoxId => $recordIds) { + $databox = $appbox->get_databox($databoxId); + + foreach ($databox->getRecordRepository()->findByRecordIds(array_keys($recordIds)) as $record) { + $records[$recordIds[$record->getRecordId()]] = $record; + } + } + + ksort($records); + + return array_values($records); + } +} diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineResultToRecordsConverter.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineResultToRecordsConverter.php deleted file mode 100644 index efdd81904c..0000000000 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineResultToRecordsConverter.php +++ /dev/null @@ -1,74 +0,0 @@ -appbox = $appbox; - } - - /** - * @param RecordInterface[] $records - * @return \record_adapter[] - */ - public function convert($records) - { - Assertion::allIsInstanceOf($records, RecordInterface::class); - - $perDataboxRecordIds = $this->groupRecordIdsPerDataboxId($records); - - $records = []; - - foreach ($perDataboxRecordIds as $databoxId => $recordIds) { - $databox = $this->appbox->get_databox($databoxId); - - foreach ($databox->getRecordRepository()->findByRecordIds(array_keys($recordIds)) as $record) { - $records[$recordIds[$record->getRecordId()]] = $record; - } - } - - ksort($records); - - return $records; - } - - /** - * @param RecordInterface[] $records - * @return array[] - */ - private function groupRecordIdsPerDataboxId($records) - { - $number = 0; - $perDataboxRecordIds = []; - - foreach ($records as $record) { - $databoxId = $record->getDataboxId(); - - if (!isset($perDataboxRecordIds[$databoxId])) { - $perDataboxRecordIds[$databoxId] = []; - } - - $perDataboxRecordIds[$databoxId][$record->getRecordId()] = $number++; - } - - return $perDataboxRecordIds; - } -} From 5da9c03d5b7d7869f34173b6d6c66ab61b6134db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Fri, 4 Mar 2016 15:40:23 +0100 Subject: [PATCH 4/9] Fix Typehinting against interface, not implementation --- lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php b/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php index e7b999e89d..18116625a6 100644 --- a/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php +++ b/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php @@ -10,6 +10,7 @@ namespace Alchemy\Phrasea\Record; +use Alchemy\Phrasea\Model\RecordReferenceInterface; use Assert\Assertion; class RecordReferenceCollection implements \IteratorAggregate @@ -36,16 +37,16 @@ class RecordReferenceCollection implements \IteratorAggregate } /** - * @var RecordReference[] + * @var RecordReferenceInterface[] */ private $references = []; /** - * @param RecordReference[] $references + * @param RecordReferenceInterface[] $references */ public function __construct($references) { - Assertion::allIsInstanceOf($references, RecordReference::class); + Assertion::allIsInstanceOf($references, RecordReferenceInterface::class); $this->references = $references; } From 63fd462abed5cc2f14370216afb107503fc300f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 7 Mar 2016 13:41:37 +0100 Subject: [PATCH 5/9] Change listRecordCaption argument to record_adapter --- .../Phrasea/Controller/Api/V1Controller.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index f9a075111c..becca55a73 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -1206,7 +1206,7 @@ class V1Controller extends Controller $extendedData = [ 'subdefs' => $subdefs, - 'metadata' => $this->listRecordCaption($record->get_caption()), + 'metadata' => $this->listRecordCaption($record), 'status' => $this->listRecordStatus($record), 'caption' => $caption ]; @@ -1316,22 +1316,22 @@ class V1Controller extends Controller public function getRecordMetadataAction(Request $request, $databox_id, $record_id) { $record = $this->findDataboxById($databox_id)->get_record($record_id); - $ret = ["record_metadatas" => $this->listRecordCaption($record->get_caption())]; + $ret = ["record_metadatas" => $this->listRecordCaption($record)]; return Result::create($request, $ret)->createResponse(); } /** - * List all fields about a specified caption - * - * @param \caption_record $caption + * List all fields of given record * + * @param \record_adapter $record * @return array */ - private function listRecordCaption(\caption_record $caption) + private function listRecordCaption(\record_adapter $record) { $ret = []; - foreach ($caption->get_fields() as $field) { + + foreach ($record->get_caption()->get_fields() as $field) { foreach ($field->get_values() as $value) { $ret[] = $this->listRecordCaptionField($value, $field); } @@ -1526,7 +1526,7 @@ class V1Controller extends Controller $record->set_metadatas($metadata); return Result::create($request, [ - "record_metadatas" => $this->listRecordCaption($record->get_caption()), + "record_metadatas" => $this->listRecordCaption($record), ])->createResponse(); } From 5b93fd92b8d04a369f55bb38635484c3e3ffe78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 7 Mar 2016 18:38:41 +0100 Subject: [PATCH 6/9] Add memory cache to RecordReferenceCollection --- .../Record/RecordReferenceCollection.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php b/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php index 18116625a6..8335c4db90 100644 --- a/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php +++ b/lib/Alchemy/Phrasea/Record/RecordReferenceCollection.php @@ -15,6 +15,8 @@ use Assert\Assertion; class RecordReferenceCollection implements \IteratorAggregate { + private $groups; + /** * @param array $records * @return RecordReferenceCollection @@ -48,7 +50,7 @@ class RecordReferenceCollection implements \IteratorAggregate { Assertion::allIsInstanceOf($references, RecordReferenceInterface::class); - $this->references = $references; + $this->references = $references instanceof \Traversable ? iterator_to_array($references) : $references; } public function getIterator() @@ -61,19 +63,29 @@ class RecordReferenceCollection implements \IteratorAggregate */ public function groupPerDataboxId() { - $groups = []; + if (null === $this->groups) { + $this->groups = []; - foreach ($this->references as $index => $reference) { - $databoxId = $reference->getDataboxId(); + foreach ($this->references as $index => $reference) { + $databoxId = $reference->getDataboxId(); - if (!isset($groups[$databoxId])) { - $groups[$databoxId] = []; + if (!isset($this->groups[$databoxId])) { + $this->groups[$databoxId] = []; + } + + $this->groups[$databoxId][$reference->getRecordId()] = $index; } - - $groups[$databoxId][$reference->getRecordId()] = $index; } - return $groups; + return $this->groups; + } + + /** + * @return array + */ + public function getDataboxIds() + { + return array_keys($this->groupPerDataboxId()); } /** From 8f6f475b7df175e8ab69ca3752949151c8e0cdd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Mon, 7 Mar 2016 18:39:29 +0100 Subject: [PATCH 7/9] Add private fields to caption when available to user --- .../Phrasea/Controller/Api/V1Controller.php | 132 +++++++++++------- lib/classes/caption/record.php | 5 +- 2 files changed, 81 insertions(+), 56 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index becca55a73..d36672fb15 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -49,6 +49,7 @@ use Alchemy\Phrasea\Model\Manipulator\TaskManipulator; use Alchemy\Phrasea\Model\Manipulator\UserManipulator; use Alchemy\Phrasea\Model\Provider\SecretProvider; use Alchemy\Phrasea\Model\RecordInterface; +use Alchemy\Phrasea\Model\RecordReferenceInterface; use Alchemy\Phrasea\Model\Repositories\BasketRepository; use Alchemy\Phrasea\Model\Repositories\FeedEntryRepository; use Alchemy\Phrasea\Model\Repositories\FeedRepository; @@ -1188,30 +1189,12 @@ class V1Controller extends Controller ]; if ($request->attributes->get('_extended', false)) { - $subdefs = $caption = []; - - foreach ($record->get_embedable_medias([], []) as $name => $media) { - if (null !== $subdef = $this->listEmbeddableMedia($request, $record, $media)) { - $subdefs[] = $subdef; - } - } - - foreach ($record->get_caption()->get_fields() as $field) { - $caption[] = [ - 'meta_structure_id' => $field->get_meta_struct_id(), - 'name' => $field->get_name(), - 'value' => $field->get_serialized_values(';'), - ]; - } - - $extendedData = [ - 'subdefs' => $subdefs, - 'metadata' => $this->listRecordCaption($record), - 'status' => $this->listRecordStatus($record), - 'caption' => $caption - ]; - - $data = array_merge($data, $extendedData); + $data = array_merge($data, [ + 'subdefs' => $this->listRecordEmbeddableMedias($request, $record), + 'metadata' => $this->listRecordMetadata($record), + 'status' => $this->listRecordStatus($record), + 'caption' => $this->listRecordCaption($record), + ]); } return $data; @@ -1316,7 +1299,7 @@ class V1Controller extends Controller public function getRecordMetadataAction(Request $request, $databox_id, $record_id) { $record = $this->findDataboxById($databox_id)->get_record($record_id); - $ret = ["record_metadatas" => $this->listRecordCaption($record)]; + $ret = ["record_metadatas" => $this->listRecordMetadata($record)]; return Result::create($request, $ret)->createResponse(); } @@ -1327,42 +1310,48 @@ class V1Controller extends Controller * @param \record_adapter $record * @return array */ - private function listRecordCaption(\record_adapter $record) + private function listRecordMetadata(\record_adapter $record) + { + $includeBusiness = $this->getAclForUser()->can_see_business_fields($record->getDatabox()); + + return $this->listRecordCaptionFields($record->get_caption()->get_fields(null, $includeBusiness)); + } + + /** + * @param \caption_field[] $fields + * @return array + */ + private function listRecordCaptionFields($fields) { $ret = []; - foreach ($record->get_caption()->get_fields() as $field) { + foreach ($fields as $field) { + $databox_field = $field->get_databox_field(); + + $fieldData = [ + 'meta_structure_id' => $field->get_meta_struct_id(), + 'name' => $field->get_name(), + 'labels' => [ + 'fr' => $databox_field->get_label('fr'), + 'en' => $databox_field->get_label('en'), + 'de' => $databox_field->get_label('de'), + 'nl' => $databox_field->get_label('nl'), + ], + ]; + foreach ($field->get_values() as $value) { - $ret[] = $this->listRecordCaptionField($value, $field); + $data = [ + 'meta_id' => $value->getId(), + 'value' => $value->getValue(), + ]; + + $ret[] = $fieldData + $data; } } return $ret; } - /** - * Retrieve information about a caption field - * - * @param \caption_Field_Value $value - * @param \caption_field $field - * @return array - */ - private function listRecordCaptionField(\caption_Field_Value $value, \caption_field $field) - { - return [ - 'meta_id' => $value->getId(), - 'meta_structure_id' => $field->get_meta_struct_id(), - 'name' => $field->get_name(), - 'labels' => [ - 'fr' => $field->get_databox_field()->get_label('fr'), - 'en' => $field->get_databox_field()->get_label('en'), - 'de' => $field->get_databox_field()->get_label('de'), - 'nl' => $field->get_databox_field()->get_label('nl'), - ], - 'value' => $value->getValue(), - ]; - } - /** * Get a Response containing the record status * @@ -1526,7 +1515,7 @@ class V1Controller extends Controller $record->set_metadatas($metadata); return Result::create($request, [ - "record_metadatas" => $this->listRecordCaption($record), + "record_metadatas" => $this->listRecordMetadata($record), ])->createResponse(); } @@ -2574,4 +2563,43 @@ class V1Controller extends Controller { return $this->app['subdef.substituer']; } + + /** + * @param Request $request + * @param \record_adapter $record + * @return array + */ + private function listRecordEmbeddableMedias(Request $request, \record_adapter $record) + { + $subdefs = []; + + foreach ($record->get_embedable_medias([], []) as $name => $media) { + if (null !== $subdef = $this->listEmbeddableMedia($request, $record, $media)) { + $subdefs[] = $subdef; + } + } + + return $subdefs; + } + + /** + * @param \record_adapter $record + * @return array + */ + private function listRecordCaption(\record_adapter $record) + { + $includeBusiness = $this->getAclForUser()->can_see_business_fields($record->getDatabox()); + + $caption = []; + + foreach ($record->get_caption()->get_fields(null, $includeBusiness) as $field) { + $caption[] = [ + 'meta_structure_id' => $field->get_meta_struct_id(), + 'name' => $field->get_name(), + 'value' => $field->get_serialized_values(';'), + ]; + } + + return $caption; + } } diff --git a/lib/classes/caption/record.php b/lib/classes/caption/record.php index 740e21ee2b..3dacaa7f8e 100644 --- a/lib/classes/caption/record.php +++ b/lib/classes/caption/record.php @@ -17,20 +17,17 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; class caption_record implements caption_interface, cache_cacheableInterface { /** - * * @var array */ protected $fields; /** - * * @var int */ protected $sbas_id; /** - * - * @var record + * @var record_adapter */ protected $record; protected $databox; From b6cc58a68ed645fa23ed24a4497e6e66149a808c Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Wed, 17 Feb 2016 16:55:47 +0100 Subject: [PATCH 8/9] PHRAS-987 1h PNG-Subdefs (port from 3.8) --- composer.json | 2 +- .../Phrasea/Filesystem/FilesystemService.php | 23 ++++++++++++++++++- lib/Alchemy/Phrasea/Media/Subdef/Image.php | 5 +++- lib/classes/databox/subdef.php | 21 +++++++++-------- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 94f86c76f0..9ece8abf32 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ "justinrainbow/json-schema": "~1.3", "league/flysystem": "^1.0", "league/flysystem-aws-s3-v2": "^1.0", - "media-alchemyst/media-alchemyst": "~0.4", + "media-alchemyst/media-alchemyst": "^0.5", "monolog/monolog": "~1.3", "mrclay/minify": "~2.1.6", "neutron/process-manager": "2.0.x-dev@dev", diff --git a/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php b/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php index 1ec7c39880..bbe1c32ab9 100644 --- a/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php +++ b/lib/Alchemy/Phrasea/Filesystem/FilesystemService.php @@ -151,7 +151,7 @@ class FilesystemService { switch ($spec->getType()) { case SpecificationInterface::TYPE_IMAGE: - return 'jpg'; + return $this->getExtensionFromImageCodec($spec->getImageCodec()); case SpecificationInterface::TYPE_ANIMATION: return 'gif'; case SpecificationInterface::TYPE_AUDIO: @@ -186,6 +186,27 @@ class FilesystemService return null; } + /** + * Get the extension from imageCodec + * + * @param string $imageCodec + * + * @return string + */ + protected function getExtensionFromImageCodec($imageCodec) + { + switch ($imageCodec) { + case 'tiff': + return 'tif'; + case 'jpeg': + return 'jpg'; + case 'png': + return 'png'; + } + + return null; + } + /** * Get the extension from videocodec * diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Image.php b/lib/Alchemy/Phrasea/Media/Subdef/Image.php index 30f76f8437..441f156b21 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Image.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Image.php @@ -21,6 +21,7 @@ class Image extends Provider const OPTION_STRIP = 'strip'; const OPTION_QUALITY = 'quality'; const OPTION_FLATTEN = 'flatten'; + const OPTION_ICODEC = 'icodec'; protected $options = []; @@ -33,6 +34,7 @@ class Image extends Provider $this->registerOption(new OptionType\Boolean($this->translator->trans('Remove ICC Profile'), self::OPTION_STRIP, false)); $this->registerOption(new OptionType\Boolean($this->translator->trans('Flatten layers'), self::OPTION_FLATTEN, false)); $this->registerOption(new OptionType\Range($this->translator->trans('Quality'), self::OPTION_QUALITY, 0, 100, 75)); + $this->registerOption(new OptionType\Enum('Image Codec', self::OPTION_ICODEC, array('jpeg', 'png', 'tiff'), 'jpeg')); } public function getType() @@ -42,7 +44,7 @@ class Image extends Provider public function getDescription() { - return $this->translator->trans('Generates a Jpeg image'); + return $this->translator->trans('Generates an image'); } public function getMediaAlchemystSpec() @@ -54,6 +56,7 @@ class Image extends Provider $size = $this->getOption(self::OPTION_SIZE)->getValue(); $resolution = $this->getOption(self::OPTION_RESOLUTION)->getValue(); + $this->spec->setImageCodec($this->getOption(self::OPTION_ICODEC)->getValue()); $this->spec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO); $this->spec->setDimensions($size, $size); $this->spec->setQuality($this->getOption(self::OPTION_QUALITY)->getValue()); diff --git a/lib/classes/databox/subdef.php b/lib/classes/databox/subdef.php index 653ac83a1e..e64ca7fb08 100644 --- a/lib/classes/databox/subdef.php +++ b/lib/classes/databox/subdef.php @@ -107,8 +107,6 @@ class databox_subdef $this->subdef_type = $this->buildFlexPaperSubdef($sd); break; } - - return $this; } /** @@ -289,13 +287,16 @@ class databox_subdef /** * Build Image Subdef object depending the SimpleXMLElement * - * @param SimpleXMLElement $sd - * @return \Alchemy\Phrasea\Media\Subdef\Video + * @param SimpleXMLElement $sd + * @return Image */ protected function buildImageSubdef(SimpleXMLElement $sd) { $image = new Image($this->translator); + if ($sd->icodec) { + $image->setOptionValue(Image::OPTION_ICODEC, (string) $sd->icodec); + } if ($sd->size) { $image->setOptionValue(Image::OPTION_SIZE, (int) $sd->size); } @@ -318,8 +319,8 @@ class databox_subdef /** * Build Audio Subdef object depending the SimpleXMLElement * - * @param SimpleXMLElement $sd - * @return \Alchemy\Phrasea\Media\Subdef\Video + * @param SimpleXMLElement $sd + * @return Audio */ protected function buildAudioSubdef(SimpleXMLElement $sd) { @@ -352,8 +353,8 @@ class databox_subdef /** * Build GIF Subdef object depending the SimpleXMLElement * - * @param SimpleXMLElement $sd - * @return \Alchemy\Phrasea\Media\Subdef\Video + * @param SimpleXMLElement $sd + * @return Gif */ protected function buildGifSubdef(SimpleXMLElement $sd) { @@ -372,8 +373,8 @@ class databox_subdef /** * Build Video Subdef object depending the SimpleXMLElement * - * @param SimpleXMLElement $sd - * @return \Alchemy\Phrasea\Media\Subdef\Video + * @param SimpleXMLElement $sd + * @return Video */ protected function buildVideoSubdef(SimpleXMLElement $sd) { From 197071f060f607fd42543b62ecdf93c2373d0de7 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Wed, 17 Feb 2016 17:29:47 +0100 Subject: [PATCH 9/9] PHRAS-987 30m bump media-alchemyst to ^0.5 --- composer.lock | 144 ++++++++++++++++++-------------------------------- 1 file changed, 51 insertions(+), 93 deletions(-) diff --git a/composer.lock b/composer.lock index 42d9128160..e70c4036a5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "02cbfee2e7384dfed43ce4c8e8a64c5d", - "content-hash": "db0a3515fad6442e50e3a64478365383", + "hash": "455f2f5469072352ed9a240d8c170956", + "content-hash": "bb783826a1ca0339baf5bff696d69a73", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -15,6 +15,12 @@ "url": "https://github.com/alchemy-fr/tcpdf-clone.git", "reference": "2ba0248a7187f1626df6c128750650416267f0e7" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alchemy-fr/tcpdf-clone/zipball/2ba0248a7187f1626df6c128750650416267f0e7", + "reference": "2ba0248a7187f1626df6c128750650416267f0e7", + "shasum": "" + }, "require": { "php": ">=5.3.0" }, @@ -61,6 +67,10 @@ "qrcode", "tcpdf" ], + "support": { + "source": "https://github.com/alchemy-fr/tcpdf-clone/tree/6.0.039", + "issues": "https://github.com/alchemy-fr/tcpdf-clone/issues" + }, "time": "2013-10-13 16:11:17" }, { @@ -103,14 +113,14 @@ "email": "imprec@gmail.com", "homepage": "http://www.lickmychip.com/" }, - { - "name": "Nicolas Le Goff", - "email": "legoff.n@gmail.com" - }, { "name": "Phraseanet Team", "email": "info@alchemy.fr", "homepage": "http://www.phraseanet.com/" + }, + { + "name": "Nicolas Le Goff", + "email": "legoff.n@gmail.com" } ], "description": "A set of tools to build binary drivers", @@ -483,12 +493,12 @@ "source": { "type": "git", "url": "https://github.com/alchemy-fr/rest-bundle.git", - "reference": "7b1c88c02ab8c0d4e997fd61c13c8fd4c3ce5216" + "reference": "9048a99dd328cd2d01efaad16e6af648d11ad2b4" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/alchemy-fr/rest-bundle/zipball/9048a99dd328cd2d01efaad16e6af648d11ad2b4", - "reference": "7b1c88c02ab8c0d4e997fd61c13c8fd4c3ce5216", + "reference": "9048a99dd328cd2d01efaad16e6af648d11ad2b4", "shasum": "" }, "require": { @@ -526,7 +536,7 @@ } ], "description": "Simple REST utility bundle", - "time": "2015-09-22 06:58:52" + "time": "2016-02-20 22:35:16" }, { "name": "alchemy/symfony-cors", @@ -536,6 +546,12 @@ "url": "https://github.com/alchemy-fr/symfony-cors.git", "reference": "dbf7fcff1ce9fc1265db12955476ff169eab7375" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alchemy-fr/symfony-cors/zipball/dbf7fcff1ce9fc1265db12955476ff169eab7375", + "reference": "dbf7fcff1ce9fc1265db12955476ff169eab7375", + "shasum": "" + }, "require": { "symfony/http-kernel": "^2.3.0|^3.0.0" }, @@ -556,11 +572,7 @@ "Alchemy\\CorsBundle\\": "src/Bundle/" } }, - "autoload-dev": { - "psr-4": { - "Alchemy\\Cors\\Tests\\": "tests/unit/Component/" - } - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1723,12 +1735,12 @@ "source": { "type": "git", "url": "https://github.com/igorw/evenement.git", - "reference": "v1.0.0" + "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/igorw/evenement/zipball/fa966683e7df3e5dd5929d984a44abfbd6bafe8d", - "reference": "v1.0.0", + "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d", "shasum": "" }, "require": { @@ -1755,7 +1767,7 @@ "keywords": [ "event-dispatcher" ], - "time": "2012-05-30 08:01:08" + "time": "2012-05-30 15:01:08" }, { "name": "facebook/php-sdk", @@ -1801,6 +1813,7 @@ "facebook", "sdk" ], + "abandoned": "facebook/php-sdk-v4", "time": "2013-11-19 23:11:14" }, { @@ -2642,12 +2655,12 @@ "source": { "type": "git", "url": "https://github.com/hoaproject/Stream.git", - "reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3" + "reference": "3bc446bc00849bf51166adc415d77aa375d48d8c" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/hoaproject/Stream/zipball/3bc446bc00849bf51166adc415d77aa375d48d8c", - "reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3", + "reference": "3bc446bc00849bf51166adc415d77aa375d48d8c", "shasum": "" }, "require": { @@ -2692,7 +2705,7 @@ "stream", "wrapper" ], - "time": "2015-10-22 06:30:43" + "time": "2015-10-26 12:21:43" }, { "name": "hoa/ustring", @@ -3544,37 +3557,38 @@ }, { "name": "media-alchemyst/media-alchemyst", - "version": "0.4.8", + "version": "0.5.0", "source": { "type": "git", "url": "https://github.com/alchemy-fr/Media-Alchemyst.git", - "reference": "cf1fdacbaf0d54440fa7b61c750234d0befde0c8" + "reference": "cc279e0dcf22e47322028084dd1145a44a219c1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/alchemy-fr/Media-Alchemyst/zipball/cf1fdacbaf0d54440fa7b61c750234d0befde0c8", - "reference": "cf1fdacbaf0d54440fa7b61c750234d0befde0c8", + "url": "https://api.github.com/repos/alchemy-fr/Media-Alchemyst/zipball/cc279e0dcf22e47322028084dd1145a44a219c1a", + "reference": "cc279e0dcf22e47322028084dd1145a44a219c1a", "shasum": "" }, "require": { "alchemy/ghostscript": "~0.4.0", + "alchemy/mediavorus": "^0.4.4", "imagine/imagine": "0.6.x@dev", - "mediavorus/mediavorus": ">=0.4.2,<0.5", "monolog/monolog": "~1.0", - "neutron/temporary-filesystem": "~2.1", + "neutron/temporary-filesystem": "^2.1.1", "php": ">=5.3.3", "php-ffmpeg/php-ffmpeg": ">=0.4.2,<0.6", "php-mp4box/php-mp4box": "~0.3.0", "php-unoconv/php-unoconv": "~0.3.0", "pimple/pimple": "~1.0", "swftools/swftools": "~0.3.0", - "symfony/console": "~2.0", - "symfony/filesystem": "~2.0" + "symfony/console": "^2.1|^3.0", + "symfony/filesystem": "^2.1|^3.0", + "symfony/process": "^2.1.1|^3.0" }, "require-dev": { + "alchemy/phpexiftool": "^0.4.0|^0.5.0", "neutron/silex-imagine-provider": "~0.1", - "phpexiftool/phpexiftool": "~0.1", - "phpunit/phpunit": "~3.7", + "phpunit/phpunit": "^4.1|^5.0", "silex/silex": "~1.0" }, "type": "library", @@ -3613,63 +3627,7 @@ "video", "video processing" ], - "time": "2015-02-03 16:25:38" - }, - { - "name": "mediavorus/mediavorus", - "version": "0.4.4", - "source": { - "type": "git", - "url": "https://github.com/romainneutron/MediaVorus.git", - "reference": "2df98b5b180c50b1bc7be838e36bc6ecc573e646" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/romainneutron/MediaVorus/zipball/2df98b5b180c50b1bc7be838e36bc6ecc573e646", - "reference": "2df98b5b180c50b1bc7be838e36bc6ecc573e646", - "shasum": "" - }, - "require": { - "doctrine/collections": "~1.0", - "monolog/monolog": "~1.0", - "php": ">=5.3.0", - "php-ffmpeg/php-ffmpeg": "~0.3", - "phpexiftool/phpexiftool": "~0.1", - "symfony/console": "~2.0", - "symfony/http-foundation": "~2.0" - }, - "require-dev": { - "jms/serializer": "~0.12.0", - "phpunit/phpunit": "~3.7", - "silex/silex": "~1.0", - "symfony/yaml": "~2.0" - }, - "suggest": { - "jms/serializer": "To serialize Medias", - "symfony/yaml": "To serialize Medias in Yaml format" - }, - "type": "library", - "autoload": { - "psr-0": { - "MediaVorus": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Romain Neutron", - "email": "imprec@gmail.com", - "homepage": "http://www.lickmychip.com/" - } - ], - "description": "MediaVorus", - "keywords": [ - "metadata" - ], - "time": "2014-08-26 12:32:10" + "time": "2016-02-17 14:25:54" }, { "name": "monolog/monolog", @@ -3778,7 +3736,7 @@ ], "authors": [ { - "name": "Stephen Clay", + "name": "Steve Clay", "email": "steve@mrclay.org", "homepage": "http://www.mrclay.org/", "role": "Developer" @@ -3964,21 +3922,21 @@ "source": { "type": "git", "url": "https://github.com/romainneutron/Imagine-Silex-Service-Provider.git", - "reference": "0.1.2" + "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/romainneutron/Imagine-Silex-Service-Provider/zipball/a8a7862ae90419f2b23746cd8436c2310e4eb084", - "reference": "0.1.2", + "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084", "shasum": "" }, "require": { "imagine/imagine": "*", "php": ">=5.3.3", - "silex/silex": ">=1.0,<2.0" + "silex/silex": "~1.0" }, "require-dev": { - "symfony/browser-kit": ">=2.0,<3.0" + "symfony/browser-kit": "~2.0" }, "type": "library", "autoload": { @@ -5325,7 +5283,7 @@ }, { "name": "Phraseanet Team", - "email": "support@alchemy.fr", + "email": "info@alchemy.fr", "homepage": "http://www.phraseanet.com/" } ],