/** * Berechnet die Updates / Inserts / Deletes zwischen den beiden Collections * * wird keine $compareFunction angegeben, werden die Elemente der Collection als Objekte behandelt * wird keine $uniqueHashFunction angegeben werden diese mit spl_object_hash() gehashed * @return list($inserts, $updates, $deletes) */ public function computeCUDSets(ArrayCollection $fromCollection, ArrayCollection $toCollection, $compareFunction = NULL, $uniqueHashFunction = NULL) { if (!isset($compareFunction)) { $compareFunction = ArrayCollection::COMPARE_OBJECTS; } return $fromCollection->computeCUDSets($toCollection, $compareFunction, $uniqueHashFunction); }
/** * * Wird EmptyDataException bei validate() geworfen und ist der Validator mit optional aufgerufen worden, wird keine ValidatorException geworfen * @return $data */ public function validate($data = NULL) { if ($data === NULL || $data === array()) { throw EmptyDataException::factory(new \Psc\Data\ArrayCollection()); } if (!is_array($data)) { throw new \InvalidArgumentException('Parameter ist als Array erwartet. ' . Code::varInfo($data) . ' wurde übergeben'); } $identifierCaster = $this->getIdentifierCaster($this->entityMeta->getIdentifier()); $repository = $this->dc->getRepository($this->entityMeta->getClass()); $entities = new ArrayCollection(); foreach ($data as $key => $identifierString) { $identifier = $identifierCaster($identifierString, $key); $entities->add($repository->hydrate($identifier)); } return $entities; }
/** * @return Iterator */ public function getIterator() { return $this->parameters->getIterator(); }
public function testIndexofFromDoctrine() { $o1 = new CollectionObject(1); $o2 = new CollectionObject(2); $o3 = new CollectionObject(3); $collection = new ArrayCollection(array($o1, $o2, $o3)); $collection->removeElement($o1); $this->assertEquals(1, $collection->indexOf($o2)); // this is not 0 }