added initial support for service definition

This commit is contained in:
Christian Kerl
2010-10-07 15:16:56 +02:00
parent 783ced3b7b
commit 31d40380a6
18 changed files with 677 additions and 34 deletions

52
Util/Collection.php Normal file
View File

@ -0,0 +1,52 @@
<?php
namespace Bundle\WebServiceBundle\Util;
class Collection implements \IteratorAggregate, \Countable
{
private $elements = array();
private $keyPropertyGetter;
public function __construct($keyPropertyGetter)
{
$this->keyPropertyGetter = $keyPropertyGetter;
}
public function add($element)
{
$this->elements[call_user_func(array($element, $this->keyPropertyGetter))] = $element;
}
public function addAll($elements)
{
foreach ($elements as $element)
{
$this->add($element);
}
}
public function has($key)
{
return isset($this->elements[$key]);
}
public function get($key)
{
return $this->has($key) ? $this->elements[$key] : null;
}
public function clear()
{
$this->elements = array();
}
public function count()
{
return count($this->elements);
}
public function getIterator ()
{
return new \ArrayIterator($this->elements);
}
}