當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayCollection::indexOf方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Collections\ArrayCollection::indexOf方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayCollection::indexOf方法的具體用法?PHP ArrayCollection::indexOf怎麽用?PHP ArrayCollection::indexOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Collections\ArrayCollection的用法示例。


在下文中一共展示了ArrayCollection::indexOf方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexOf

 public function indexOf($element)
 {
     if (null === $this->entries) {
         $this->__load___();
     }
     return $this->entries->indexOf($element);
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:7,代碼來源:AggregateEntryCollection.php

示例2: getIdentifier

 /**
  * @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());
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:12,代碼來源:OrderAddressManager.php

示例3: removeReport

 public function removeReport(ReportModule $reportModule)
 {
     $index = $this->modules->indexOf($reportModule);
     if ($index !== null) {
         $this->modules->remove($index);
     }
     return $this;
 }
開發者ID:Quiss,項目名稱:RNMoT,代碼行數:8,代碼來源:Report.php

示例4: indexOf

 public function indexOf($element)
 {
     $index = parent::indexOf($element);
     if (is_numeric($index)) {
         $index += 1;
     }
     return $index;
 }
開發者ID:junjinZ,項目名稱:wealthbot,代碼行數:8,代碼來源:ConsolidatedAccountsCollection.php

示例5: removeCourse

 public function removeCourse(CourseModule $courseModule)
 {
     $index = $this->modules->indexOf($courseModule);
     if ($index !== null) {
         $this->modules->remove($index);
     }
     return $this;
 }
開發者ID:Quiss,項目名稱:Learning,代碼行數:8,代碼來源:Course.php

示例6: testIndexOf

 /**
  * 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'));
 }
開發者ID:cross-solution,項目名稱:yawik,代碼行數:11,代碼來源:IdentityWrapperTest.php

示例7: filterCollection

 /**
  * 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;
 }
開發者ID:RuslanZavacky,項目名稱:EcentriaRestBundle,代碼行數:32,代碼來源:CrudManager.php

示例8: testIndexOf

 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');
 }
開發者ID:tccLaravel,項目名稱:test4,代碼行數:8,代碼來源:ArrayCollectionTest.php

示例9: _addSubcontent

 /**
  * 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();
 }
開發者ID:ReissClothing,項目名稱:BackBee,代碼行數:15,代碼來源:AbstractClassContent.php

示例10: hasOxfordable

 /**
  * 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);
 }
開發者ID:epfremmer,項目名稱:PHP-Weekly-Issue28,代碼行數:12,代碼來源:Sentence.php

示例11: indexOf

 /** {@inheritDoc} */
 public function indexOf($element)
 {
     $this->initialize();
     return $this->collection->indexOf($element);
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:6,代碼來源:PersistentCollection.php

示例12: indexOf

 /**
  * 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);
 }
開發者ID:Rybbow,項目名稱:x-blog,代碼行數:13,代碼來源:ImmutableCollection.php

示例13: indexOf

 /**
  * @param Column $column
  *
  * @return bool|int|string
  */
 public function indexOf($column)
 {
     $this->columnTypeExpected($column);
     return parent::indexOf($column);
 }
開發者ID:ynloultratech,項目名稱:framework,代碼行數:10,代碼來源:ColumnCollection.php

示例14: indexOf

 function indexOf($element)
 {
     return $this->fields->indexOf($element);
 }
開發者ID:tomaszhanc,項目名稱:form-field-bundle,代碼行數:4,代碼來源:FieldCollection.php


注:本文中的Doctrine\Common\Collections\ArrayCollection::indexOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。