Zend Framework

Implementing IteratorAggregate in custum Arraycollection results in empty result on the Flex side

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.7.6, 1.7.7
  • Fix Version/s: None
  • Component/s: Zend_Amf
  • Labels:
    None

Description

I' writing an ArrayCollection Object in php. Which looks like this:
class RemoteObject extends Object {
function getASClassName() { return get_class($this); }
}

/**

  • PHP ArrayCollection Class. implementing the IteratorAggregate interface
  • breaks the automatic mapping to AS
    *
    */
    class ArrayCollection extends RemoteObject implements IteratorAggregate, ArrayAccess, Countable {

public $source = array();

function __construct($source = array()){
if(!is_array($source)) { $source = array(); }
$this->source = $source;
}
/**

  • add an item to the ArrayCollection
    *
  • @param mixed $item
  • @param mixed $num
    */
    function addItem($item,$num = null)
    Unknown macro: { if(is_null($num)) { $this->source[]=$item; } else { $this->source[$num]=$item; } }

    /**
  • emulate AS3 properties
    *
  • @param string $member
  • @return mixed

function __get($member) {
switch ($member) { case 'length': //print debug("acessing length"); return count($this->source); break; default: break; }
}
*/
/**

  • The following cuntions allow treatment of the Arraycollection class
  • as if it was an array. They implement the ArrayAccess interface
    */
    function offsetExists($offset) { return isset($this->source[$offset]); }
    function offsetGet($offset) { return $this->source[$offset]; }
    function offsetSet($offset,$value) { //print debug_obj($value,sprintf('setting new value at %s',$offset)); $this->source[$offset] = $value; }
    function offsetUnset($offset) { unset($this->source[$offset]); }

/**

  • Impelent countable
    */
    function count() { return count($this->source); }

/**

  • Create a new iterator from an ArrayCollection instance
    *
  • @return ArrayIterator
    */
    function getIterator() { return new ArrayIterator($this->source); }
    }

however, if the "IteratorAggregate" interface is implemented the result on the Flex side is always empty.

e.g.: returning new ArrayCollection(array('a'=>'A','b'=>'B'));

produces the following erros in the Flex debugger.

Error: Unknown Property: 'a'.
Error: Unknown Property: 'b'.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: