Exemplo n.º 1
0
/**
 *	Returns first element of Iterator or default value if Iterator is empty.
 *	Parameter $factory allows to apply factory to returned element.
 *
 *	@param		iterator	Traversable			Iterator
 *	@param		factory		RM_Store_iFactory	Optional factory (performance hack)
 *	@param		default		mixed				Value to return if iterator is empty (default is RM_Base_NullObject)
 *	@return		mixed
 */
function iterFirst($iterator, RM_Store_iFactory $factory = NULL, $default = NULL)
{
    foreach ($iterator as $data) {
        return $factory ? $factory->create($data) : $data;
    }
    return $default === NULL ? M('Base')->null() : $default;
}
Exemplo n.º 2
0
 public function createByProps($data = NULL)
 {
     $object = $this->_factory->createByProps($data);
     if (!$object->{$this->_guidProp}) {
         $object->{$this->_guidProp} = M('Guid')->get($this->_guidType);
     }
     return $object;
 }
Exemplo n.º 3
0
 public function createByProps($data = NULL)
 {
     return new RM_TextFilter_ObjectDecorator($this->_factory->createByProps($data), $this->_config, $this->_default);
 }
Exemplo n.º 4
0
 public function current()
 {
     return $this->_factory->create($this->_iter->current());
 }