Esempio n. 1
0
 public function testContains()
 {
     $col = new Collection();
     $this->assertFalse($col->contains('foo_1'), 'contains() returns false on an empty collection');
     $data = array('bar1', 'bar2', 'bar3');
     $col = new Collection($data);
     $this->assertTrue($col->contains('bar1'), 'contains() returns true when the key exists');
     $this->assertFalse($col->contains('bar4'), 'contains() returns false when the key does not exist');
 }
 /**
  * Returns an array of objects present in the collection that
  * are not presents in the given collection.
  *
  * @param  Collection $collection A Propel collection.
  * @return Collection An array of Propel objects from the collection that are not presents in the given collection.
  */
 public function diff(Collection $collection)
 {
     $diff = clone $this;
     $diff->clear();
     foreach ($this as $object) {
         if (!$collection->contains($object)) {
             $diff[] = $object;
         }
     }
     return $diff;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function contains($element)
 {
     if (!is_object($element)) {
         return parent::contains($element);
     }
     return isset($this->indexSplHash[spl_object_hash($element)]) || isset($this->index[$element->hashCode()]);
 }
 /**
  * {@inheritdoc}
  */
 public function contains($element)
 {
     if ($element instanceof ActiveRecordInterface) {
         if (null !== ($elt = $this->getIdenticalObject($element))) {
             $element = $elt;
         }
     }
     return parent::contains($element);
 }