FOSElasticaBundle/Type/LookupManager.php

36 lines
738 B
PHP
Raw Normal View History

2014-04-25 13:31:04 +02:00
<?php
namespace FOS\ElasticaBundle\Type;
class LookupManager
{
/**
* @var LookupInterface[]
*/
private $lookups = array();
/**
* @param LookupInterface[] $lookups
*/
public function __construct($lookups)
{
foreach ($lookups as $lookup) {
$this->lookups[$lookup->getKey()] = $lookup;
}
}
/**
* @param string $type
* @return LookupInterface
* @throws \InvalidArgumentException
*/
public function getLookup($type)
{
if (!array_key_exists($type, $this->lookups)) {
throw new \InvalidArgumentException(sprintf('Lookup with key "%s" does not exist', $type));
}
return $this->lookups[$type];
}
}