public function indexOf($element) { if (null === $this->entries) { $this->__load___(); } return $this->entries->indexOf($element); }
/** * @param AbstractAddress $address * @return string */ public function getIdentifier(AbstractAddress $address) { $className = ClassUtils::getClass($address); if (!$this->map->contains($className)) { throw new \InvalidArgumentException(sprintf('Entity with "%s" not registered', $className)); } return sprintf('%s%s%s', $this->map->indexOf($className), self::DELIMITER, $address->getId()); }
public function removeReport(ReportModule $reportModule) { $index = $this->modules->indexOf($reportModule); if ($index !== null) { $this->modules->remove($index); } return $this; }
public function indexOf($element) { $index = parent::indexOf($element); if (is_numeric($index)) { $index += 1; } return $index; }
public function removeCourse(CourseModule $courseModule) { $index = $this->modules->indexOf($courseModule); if ($index !== null) { $this->modules->remove($index); } return $this; }
/** * Tests IdentityWrapper->indexOf() */ public function testIndexOf() { foreach ($this->entries as $key => $entry) { $this->assertSame($key, $this->identityWrapper->indexOf($entry)); $this->assertNotSame($key, $this->wrappedCollection->indexOf($entry)); } $this->assertFalse($this->identityWrapper->indexOf('non-existent')); }
/** * Filtering collection * * @param ArrayCollection|CrudEntityInterface[] $collection Collection * @param bool $replace replace * * @return CrudUnitOfWork */ public function filterCollection(ArrayCollection $collection, $replace = true) { $unitOfWork = new CrudUnitOfWork(); foreach ($collection as $entity) { if ($entity->getId()) { $crudEntity = $this->find(get_class($entity), $entity->getId()); } else { $this->crudTransformer->initializeClassMetadata(get_class($entity)); $conditions = $this->crudTransformer->getUniqueSearchConditions($entity); $crudEntity = $this->entityManager->getRepository(get_class($entity))->findOneBy($conditions); } if ($crudEntity instanceof CrudEntityInterface) { if ($replace) { $key = $collection->indexOf($entity); $collection->remove($key); $collection->set($key, $crudEntity); } $unitOfWork->update($crudEntity); } else { $unitOfWork->insert($entity); } } return $unitOfWork; }
public function testIndexOf() { $elements = array(1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0); $collection = new ArrayCollection($elements); $this->assertSame(array_search(2, $elements, true), $collection->indexOf(2), 'Index of 2'); $this->assertSame(array_search(null, $elements, true), $collection->indexOf(null), 'Index of null'); $this->assertSame(array_search('non-existent', $elements, true), $collection->indexOf('non-existent'), 'Index of non existent'); }
/** * Adds a subcontent to the collection. * * @param \BackBee\CoreDomain\ClassContent\AbstractClassContent $value * * @return string the unique identifier of the add subcontent */ protected function _addSubcontent(AbstractClassContent $value) { if (!$this->_subcontent->indexOf($value)) { $this->_subcontent->add($value); } $this->subcontentmap[$value->getUid()] = $this->_subcontent->indexOf($value); return $value->getUid(); }
/** * Test if there is a previous oxfordable word * available to the conjunction * * @param Conjunction $word * @return bool */ private function hasOxfordable(Conjunction $word) { $index = $this->words->indexOf($word); return $this->words->offsetExists($index - 1); }
/** {@inheritDoc} */ public function indexOf($element) { $this->initialize(); return $this->collection->indexOf($element); }
/** * Gets the index/key of a given element. The comparison of two elements is strict, * that means not only the value but also the type must match. * For objects this means reference equality. * * @param mixed $element The element to search for. * * @return int|string|bool The key/index of the element or FALSE if the element was not found. */ public function indexOf($element) { return $this->collection->indexOf($element); }
/** * @param Column $column * * @return bool|int|string */ public function indexOf($column) { $this->columnTypeExpected($column); return parent::indexOf($column); }
function indexOf($element) { return $this->fields->indexOf($element); }