Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/150'
Browse files Browse the repository at this point in the history
Close #150
  • Loading branch information
weierophinney committed Oct 11, 2016
2 parents 2fde180 + 16c73d0 commit 7c164ef
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace ZF\Hal;

use Traversable;
use Zend\Paginator\Paginator;
use Zend\Stdlib\ArrayUtils;

/**
Expand All @@ -24,7 +25,7 @@ class Collection implements Link\LinkCollectionAwareInterface
protected $attributes = [];

/**
* @var array|Traversable|\Zend\Paginator\Paginator
* @var array|Traversable|Paginator
*/
protected $collection;

Expand Down Expand Up @@ -99,7 +100,7 @@ class Collection implements Link\LinkCollectionAwareInterface
protected $entityRouteParams = [];

/**
* @param array|Traversable|\Zend\Paginator\Paginator $collection
* @param array|Traversable|Paginator $collection
* @param string $entityRoute
* @param array|Traversable $entityRouteParams
* @param array|Traversable $entityRouteOptions
Expand Down Expand Up @@ -491,7 +492,7 @@ public function getAttributes()
/**
* Collection
*
* @return array|Traversable|\Zend\Paginator\Paginator
* @return array|Traversable|Paginator
*/
public function getCollection()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Factory/HalViewHelperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
namespace ZF\Hal\Factory;

use Interop\Container\ContainerInterface;
use Zend\Hydrator\HydratorInterface;
use Zend\Hydrator\HydratorPluginManager;
use Zend\ServiceManager\AbstractPluginManager;
use ZF\Hal\Exception;
use ZF\Hal\Extractor\LinkCollectionExtractor;
Expand All @@ -28,6 +30,8 @@ public function __invoke(ContainerInterface $container)
/* @var $rendererOptions \ZF\Hal\RendererOptions */
$rendererOptions = $container->get('ZF\Hal\RendererOptions');
$metadataMap = $container->get('ZF\Hal\MetadataMap');

/** @var HydratorPluginManager $hydrators */
$hydrators = $metadataMap->getHydratorManager();

$helper = new Plugin\Hal($hydrators);
Expand All @@ -48,6 +52,7 @@ public function __invoke(ContainerInterface $container)
));
}

/** @var HydratorInterface $hydrator */
$hydrator = $hydrators->get($defaultHydrator);
$helper->setDefaultHydrator($hydrator);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Factory/LinkUrlBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace ZF\Hal\Factory;

use Zend\View\Helper\ServerUrl;
use ZF\Hal\Link\LinkUrlBuilder;

class LinkUrlBuilderFactory
Expand All @@ -20,6 +21,7 @@ public function __invoke($container)

$viewHelperManager = $container->get('ViewHelperManager');

/** @var ServerUrl $serverUrlHelper */
$serverUrlHelper = $viewHelperManager->get('ServerUrl');
if (isset($halConfig['options']['use_proxy'])) {
$serverUrlHelper->setUseProxy($halConfig['options']['use_proxy']);
Expand Down
1 change: 1 addition & 0 deletions src/Link/PaginationInjectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace ZF\Hal\Link;

use ZF\ApiProblem\ApiProblem;
use ZF\Hal\Collection;

interface PaginationInjectorInterface
Expand Down
1 change: 0 additions & 1 deletion src/Link/SelfLinkInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace ZF\Hal\Link;

use ZF\Hal\Link\LinkCollectionAwareInterface;
use ZF\Hal\Collection;
use ZF\Hal\Entity;

Expand Down
2 changes: 0 additions & 2 deletions src/Link/SelfLinkInjectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

namespace ZF\Hal\Link;

use ZF\Hal\Link\LinkCollectionAwareInterface;

interface SelfLinkInjectorInterface
{
/**
Expand Down
10 changes: 8 additions & 2 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace ZF\Hal;

use Zend\Mvc\ApplicationInterface;
use Zend\Mvc\MvcEvent;
use ZF\Hal\View\HalJsonStrategy;

Expand All @@ -30,7 +31,9 @@ public function getConfig()
*/
public function onBootstrap(MvcEvent $e)
{
$events = $e->getTarget()->getEventManager();
/** @var ApplicationInterface $application */
$application = $e->getTarget();
$events = $application->getEventManager();
$events->attach(MvcEvent::EVENT_RENDER, [$this, 'onRender'], 100);
}

Expand All @@ -48,11 +51,14 @@ public function onRender(MvcEvent $e)
return;
}

$services = $e->getTarget()->getServiceManager();
/** @var Application $application */
$application = $e->getTarget();
$services = $application->getServiceManager();
$events = $services->get('View')->getEventManager();

// register at high priority, to "beat" normal json strategy registered
// via view manager
/** @var HalJsonStrategy $halStrategy */
$halStrategy = $services->get('ZF\Hal\JsonStrategy');
$halStrategy->attach($events, 200);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Plugin/Hal.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use ArrayObject;
use Countable;
use Traversable;
use Zend\EventManager\Event;
use Zend\EventManager\EventInterface;
use Zend\EventManager\EventManagerAwareInterface;
Expand Down Expand Up @@ -941,7 +942,7 @@ public function createCollection($collection, $route = null)
}

/**
* @param object $object
* @param array|Traversable|Paginator $object
* @param Metadata $metadata
* @return Collection
*/
Expand Down
2 changes: 1 addition & 1 deletion src/RendererOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function setHydrators(array $hydrators)
}

/**
* @return string
* @return array
*/
public function getHydrators()
{
Expand Down
8 changes: 4 additions & 4 deletions src/ResourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace ZF\Hal;

use Closure;
use ZF\Hal\Collection;
use ZF\Hal\Entity;
use Traversable;
use Zend\Paginator\Paginator;
use ZF\Hal\Extractor\EntityExtractor;
use ZF\Hal\Exception;
use ZF\Hal\Link\Link;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function __construct(EntityHydratorManager $entityHydratorManager, Entity
/**
* Create a entity and/or collection based on a metadata map
*
* @param object $object
* @param object|array|Traversable|Paginator $object
* @param Metadata $metadata
* @param bool $renderEmbeddedEntities
* @return Entity|Collection
Expand Down Expand Up @@ -89,7 +89,7 @@ public function createEntityFromMetadata($object, Metadata $metadata, $renderEmb
}

/**
* @param object $object
* @param array|Traversable|Paginator $object
* @param Metadata $metadata
* @return Collection
*/
Expand Down

0 comments on commit 7c164ef

Please sign in to comment.