diff --git a/composer.json b/composer.json index 9aee8b75f4..d225ce42fd 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,10 @@ { "type": "vcs", "url": "https://github.com/alchemy-fr/embed-bundle.git" + }, + { + "type": "git", + "url": "https://github.com/bburnichon/fractal.git" } ], "require": { @@ -38,7 +42,7 @@ "alchemy/oauth2php": "1.0.0", "alchemy/phlickr": "0.2.9", "alchemy/phpexiftool": "^0.5.0", - "alchemy/rest-bundle": "^0.0.4", + "alchemy/rest-bundle": "^0.0.5", "alchemy/symfony-cors": "^0.1.0", "alchemy/task-manager": "2.0.x-dev@dev", "alchemy/zippy": "^0.3.0", @@ -69,6 +73,7 @@ "justinrainbow/json-schema": "~1.3", "league/flysystem": "^1.0", "league/flysystem-aws-s3-v2": "^1.0", + "league/fractal": "dev-bug/null-resource-serialization#d84aa1e as 0.13.0", "media-alchemyst/media-alchemyst": "^0.5", "monolog/monolog": "~1.3", "mrclay/minify": "~2.1.6", diff --git a/composer.lock b/composer.lock index e52e7ca25b..586c07aff9 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": "2f0d3c97831221555b3c1d1a725f897e", - "content-hash": "898155bdbf7333a2634c4b04053469ea", + "hash": "364406a454e9033151c8a2075ecb240f", + "content-hash": "e2785509e5ac412cd184fcb0c3f1bd5f", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -15,12 +15,6 @@ "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" }, @@ -67,10 +61,6 @@ "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" }, { @@ -489,20 +479,21 @@ }, { "name": "alchemy/rest-bundle", - "version": "0.0.4", + "version": "0.0.5", "source": { "type": "git", "url": "https://github.com/alchemy-fr/rest-bundle.git", - "reference": "9048a99dd328cd2d01efaad16e6af648d11ad2b4" + "reference": "e795b3cd565086d575ee919d1b23279656c982ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/alchemy-fr/rest-bundle/zipball/9048a99dd328cd2d01efaad16e6af648d11ad2b4", - "reference": "9048a99dd328cd2d01efaad16e6af648d11ad2b4", + "url": "https://api.github.com/repos/alchemy-fr/rest-bundle/zipball/e795b3cd565086d575ee919d1b23279656c982ad", + "reference": "e795b3cd565086d575ee919d1b23279656c982ad", "shasum": "" }, "require": { - "league/fractal": "^0.12.0", + "league/fractal": "^0.12.0|^0.13.0", + "php": ">=5.4", "willdurand/negotiation": "~2.0@dev" }, "require-dev": { @@ -536,7 +527,7 @@ } ], "description": "Simple REST utility bundle", - "time": "2016-02-20 22:35:16" + "time": "2016-05-16 09:37:34" }, { "name": "alchemy/symfony-cors", @@ -546,12 +537,6 @@ "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" }, @@ -572,7 +557,11 @@ "Alchemy\\CorsBundle\\": "src/Bundle/" } }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "psr-4": { + "Alchemy\\Cors\\Tests\\": "tests/unit/Component/" + } + }, "license": [ "MIT" ], @@ -1801,12 +1790,12 @@ "source": { "type": "git", "url": "https://github.com/igorw/evenement.git", - "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d" + "reference": "v1.0.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/fa966683e7df3e5dd5929d984a44abfbd6bafe8d", - "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d", + "url": "https://api.github.com/repos/igorw/evenement/zipball/v1.0.0", + "reference": "v1.0.0", "shasum": "" }, "require": { @@ -1833,7 +1822,7 @@ "keywords": [ "event-dispatcher" ], - "time": "2012-05-30 15:01:08" + "time": "2012-05-30 08:01:08" }, { "name": "facebook/php-sdk", @@ -2822,12 +2811,12 @@ "source": { "type": "git", "url": "https://github.com/hoaproject/Stream.git", - "reference": "3bc446bc00849bf51166adc415d77aa375d48d8c" + "reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/hoaproject/Stream/zipball/3bc446bc00849bf51166adc415d77aa375d48d8c", - "reference": "3bc446bc00849bf51166adc415d77aa375d48d8c", + "url": "https://api.github.com/repos/hoaproject/Stream/zipball/011ab91d942f1d7096deade4c8a10fe57d51c5b3", + "reference": "011ab91d942f1d7096deade4c8a10fe57d51c5b3", "shasum": "" }, "require": { @@ -2872,7 +2861,7 @@ "stream", "wrapper" ], - "time": "2015-10-26 12:21:43" + "time": "2015-10-22 06:30:43" }, { "name": "hoa/ustring", @@ -3660,17 +3649,11 @@ }, { "name": "league/fractal", - "version": "0.12.0", + "version": "dev-bug/null-resource-serialization", "source": { "type": "git", - "url": "https://github.com/thephpleague/fractal.git", - "reference": "0a51dcb6398dc2377d086210d0624996a1df8322" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/fractal/zipball/0a51dcb6398dc2377d086210d0624996a1df8322", - "reference": "0a51dcb6398dc2377d086210d0624996a1df8322", - "shasum": "" + "url": "https://github.com/bburnichon/fractal.git", + "reference": "d84aa1e" }, "require": { "php": ">=5.4" @@ -3699,7 +3682,11 @@ "League\\Fractal\\": "src" } }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "psr-4": { + "League\\Fractal\\Test\\": "test" + } + }, "license": [ "MIT" ], @@ -3719,7 +3706,7 @@ "league", "rest" ], - "time": "2015-03-19 15:16:43" + "time": "2016-05-16 14:18:29" }, { "name": "media-alchemyst/media-alchemyst", @@ -3903,7 +3890,7 @@ ], "authors": [ { - "name": "Steve Clay", + "name": "Stephen Clay", "email": "steve@mrclay.org", "homepage": "http://www.mrclay.org/", "role": "Developer" @@ -4089,21 +4076,21 @@ "source": { "type": "git", "url": "https://github.com/romainneutron/Imagine-Silex-Service-Provider.git", - "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084" + "reference": "0.1.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/romainneutron/Imagine-Silex-Service-Provider/zipball/a8a7862ae90419f2b23746cd8436c2310e4eb084", - "reference": "a8a7862ae90419f2b23746cd8436c2310e4eb084", + "url": "https://api.github.com/repos/romainneutron/Imagine-Silex-Service-Provider/zipball/0.1.2", + "reference": "0.1.2", "shasum": "" }, "require": { "imagine/imagine": "*", "php": ">=5.3.3", - "silex/silex": "~1.0" + "silex/silex": ">=1.0,<2.0" }, "require-dev": { - "symfony/browser-kit": "~2.0" + "symfony/browser-kit": ">=2.0,<3.0" }, "type": "library", "autoload": { @@ -5576,7 +5563,7 @@ }, { "name": "Phraseanet Team", - "email": "info@alchemy.fr", + "email": "support@alchemy.fr", "homepage": "http://www.phraseanet.com/" } ], @@ -7728,12 +7715,20 @@ "time": "2015-06-21 13:59:46" } ], - "aliases": [], + "aliases": [ + { + "alias": "0.13.0", + "alias_normalized": "0.13.0.0", + "version": "dev-bug/null-resource-serialization", + "package": "league/fractal" + } + ], "minimum-stability": "stable", "stability-flags": { "alchemy/task-manager": 20, "imagine/imagine": 20, "jms/translation-bundle": 20, + "league/fractal": 20, "neutron/process-manager": 20, "roave/security-advisories": 20, "willdurand/negotiation": 15 diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index b9855c56db..83740c3e56 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -1212,9 +1212,7 @@ class V1Controller extends Controller $subdefViews = $this->buildSubdefsViews($allChildren, $names, $urlTTL); $technicalDatasets = $this->app['service.technical_data']->fetchRecordsTechnicalData($allChildren); - $newHashes = []; foreach ($childrenViews as $index => $recordView) { - $newHashes[spl_object_hash($recordView)] = $recordView; $recordView->setSubdefs($subdefViews[$index]); $recordView->setTechnicalDataView(new TechnicalDataView($technicalDatasets[$index])); } diff --git a/lib/Alchemy/Phrasea/Databox/Subdef/MediaSubdefService.php b/lib/Alchemy/Phrasea/Databox/Subdef/MediaSubdefService.php index 23802b9424..ae7c75d80b 100644 --- a/lib/Alchemy/Phrasea/Databox/Subdef/MediaSubdefService.php +++ b/lib/Alchemy/Phrasea/Databox/Subdef/MediaSubdefService.php @@ -53,7 +53,9 @@ class MediaSubdefService /** @var RecordReferenceInterface $reference */ foreach ($references as $index => $reference) { - $carry[$index] = $subdefsByRecordId[$reference->getRecordId()]; + if (isset($subdefsByRecordId[$reference->getRecordId()])) { + $carry[$index] = $subdefsByRecordId[$reference->getRecordId()]; + }; } return $carry; diff --git a/lib/Alchemy/Phrasea/Fractal/ArraySerializer.php b/lib/Alchemy/Phrasea/Fractal/ArraySerializer.php index a1ca0df69c..264b42803b 100644 --- a/lib/Alchemy/Phrasea/Fractal/ArraySerializer.php +++ b/lib/Alchemy/Phrasea/Fractal/ArraySerializer.php @@ -24,7 +24,12 @@ class ArraySerializer extends SerializerAbstract public function item($resourceKey, array $data) { - return $data ?: null; + return $data; + } + + public function null($resourceKey) + { + return null; } public function includedData(ResourceInterface $resource, array $data) diff --git a/lib/Alchemy/Phrasea/Search/SubdefTransformer.php b/lib/Alchemy/Phrasea/Search/SubdefTransformer.php index c8c63f0bc9..ecd43ff032 100644 --- a/lib/Alchemy/Phrasea/Search/SubdefTransformer.php +++ b/lib/Alchemy/Phrasea/Search/SubdefTransformer.php @@ -43,20 +43,20 @@ class SubdefTransformer extends TransformerAbstract $media = $subdefView->getSubdef(); if (!$media->is_physically_present()) { - return []; + return null; } $acl = $this->aclProvider->get($this->user); $record = $media->get_record(); if ($media->get_name() !== 'document' && false === $acl->has_access_to_subdef($record, $media->get_name())) { - return []; + return null; } if ($media->get_name() === 'document' && !$acl->has_right_on_base($record->getBaseId(), 'candwnldhd') && !$acl->has_hd_grant($record) ) { - return []; + return null; } $permalink = $subdefView->getPermalinkView() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiJsonTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiJsonTest.php index 6945e4c151..eed46a878d 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiJsonTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Api/ApiJsonTest.php @@ -800,25 +800,29 @@ class ApiJsonTest extends ApiTestCase public function testSearchRoute() { - self::$DI['app']['manipulator.user'] = $this->getMockBuilder('Alchemy\Phrasea\Model\Manipulator\UserManipulator') + $app = $this->getApplication(); + + $app['manipulator.user'] = $this->getMockBuilder('Alchemy\Phrasea\Model\Manipulator\UserManipulator') ->setConstructorArgs([ - self::$DI['app']['model.user-manager'], - self::$DI['app']['auth.password-encoder'], - self::$DI['app']['geonames.connector'], - self::$DI['app']['repo.users'], - self::$DI['app']['random.low'], - self::$DI['app']['dispatcher'], + $app['model.user-manager'], + $app['auth.password-encoder'], + $app['geonames.connector'], + $app['repo.users'], + $app['random.low'], + $app['dispatcher'], ]) ->setMethods(['logQuery']) ->getMock(); - self::$DI['app']['manipulator.user']->expects($this->once())->method('logQuery'); + $app['manipulator.user']->expects($this->once())->method('logQuery'); $this->setToken($this->userAccessToken); - self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); - $content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); + $response = $this->request('POST', '/api/v1/search/', $this->getParameters(), [ + 'HTTP_Accept' => $this->getAcceptMimeType(), + ]); + $content = $this->unserialize($response->getContent()); - $this->evaluateResponse200(self::$DI['client']->getResponse()); + $this->evaluateResponse200($response); $this->evaluateMeta200($content); $response = $content['response'];