mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Add TraceableArraySerializer to be able to debug calls
This commit is contained in:
@@ -37,6 +37,7 @@ use Alchemy\Phrasea\Fractal\ArraySerializer;
|
|||||||
use Alchemy\Phrasea\Fractal\CallbackTransformer;
|
use Alchemy\Phrasea\Fractal\CallbackTransformer;
|
||||||
use Alchemy\Phrasea\Fractal\IncludeResolver;
|
use Alchemy\Phrasea\Fractal\IncludeResolver;
|
||||||
use Alchemy\Phrasea\Fractal\SearchResultTransformerResolver;
|
use Alchemy\Phrasea\Fractal\SearchResultTransformerResolver;
|
||||||
|
use Alchemy\Phrasea\Fractal\TraceableArraySerializer;
|
||||||
use Alchemy\Phrasea\Model\Entities\ApiOauthToken;
|
use Alchemy\Phrasea\Model\Entities\ApiOauthToken;
|
||||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||||
use Alchemy\Phrasea\Model\Entities\BasketElement;
|
use Alchemy\Phrasea\Model\Entities\BasketElement;
|
||||||
@@ -1087,11 +1088,12 @@ class V1Controller extends Controller
|
|||||||
$includeResolver = new IncludeResolver($transformerResolver);
|
$includeResolver = new IncludeResolver($transformerResolver);
|
||||||
|
|
||||||
$fractal = new \League\Fractal\Manager();
|
$fractal = new \League\Fractal\Manager();
|
||||||
$fractal->setSerializer(new ArraySerializer());
|
$fractal->setSerializer(new TraceableArraySerializer($this->app['dispatcher']));
|
||||||
$fractal->parseIncludes($this->resolveSearchIncludes($request));
|
$fractal->parseIncludes($this->resolveSearchIncludes($request));
|
||||||
|
|
||||||
|
$result = $this->doSearch($request);
|
||||||
$searchView = $this->buildSearchView(
|
$searchView = $this->buildSearchView(
|
||||||
$this->doSearch($request),
|
$result,
|
||||||
$includeResolver->resolve($fractal),
|
$includeResolver->resolve($fractal),
|
||||||
$this->resolveSubdefUrlTTL($request)
|
$this->resolveSubdefUrlTTL($request)
|
||||||
);
|
);
|
||||||
|
53
lib/Alchemy/Phrasea/Fractal/GetSerializationEvent.php
Normal file
53
lib/Alchemy/Phrasea/Fractal/GetSerializationEvent.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Fractal;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
|
class GetSerializationEvent extends Event
|
||||||
|
{
|
||||||
|
private $resourceKey;
|
||||||
|
private $data;
|
||||||
|
private $serialization;
|
||||||
|
|
||||||
|
public function __construct($resourceKey, $data)
|
||||||
|
{
|
||||||
|
$this->resourceKey = $resourceKey;
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getResourceKey()
|
||||||
|
{
|
||||||
|
return $this->resourceKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSerialization($serialization)
|
||||||
|
{
|
||||||
|
$this->serialization = $serialization;
|
||||||
|
$this->stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSerialization()
|
||||||
|
{
|
||||||
|
return $this->serialization;
|
||||||
|
}
|
||||||
|
}
|
63
lib/Alchemy/Phrasea/Fractal/TraceableArraySerializer.php
Normal file
63
lib/Alchemy/Phrasea/Fractal/TraceableArraySerializer.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Fractal;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
|
class TraceableArraySerializer extends ArraySerializer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var EventDispatcherInterface
|
||||||
|
*/
|
||||||
|
private $dispatcher;
|
||||||
|
|
||||||
|
public function __construct(EventDispatcherInterface $dispatcher)
|
||||||
|
{
|
||||||
|
$this->dispatcher = $dispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection($resourceKey, array $data)
|
||||||
|
{
|
||||||
|
/** @var GetSerializationEvent $event */
|
||||||
|
$event = $this->dispatcher->dispatch('fractal.serializer.collection', new GetSerializationEvent($resourceKey, $data));
|
||||||
|
|
||||||
|
$serialization = parent::collection($resourceKey, $data);
|
||||||
|
|
||||||
|
$event->setSerialization($serialization);
|
||||||
|
|
||||||
|
return $serialization;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function item($resourceKey, array $data)
|
||||||
|
{
|
||||||
|
/** @var GetSerializationEvent $event */
|
||||||
|
$event = $this->dispatcher->dispatch('fractal.serializer.item', new GetSerializationEvent($resourceKey, $data));
|
||||||
|
|
||||||
|
$serialization = parent::item($resourceKey, $data);
|
||||||
|
|
||||||
|
$event->setSerialization($serialization);
|
||||||
|
|
||||||
|
return $serialization;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function null($resourceKey)
|
||||||
|
{
|
||||||
|
/** @var GetSerializationEvent $event */
|
||||||
|
$event = $this->dispatcher->dispatch('fractal.serializer.null', new GetSerializationEvent($resourceKey, null));
|
||||||
|
|
||||||
|
$serialization = parent::null($resourceKey);
|
||||||
|
|
||||||
|
$event->setSerialization($serialization);
|
||||||
|
|
||||||
|
return $serialization;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user