当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection\ObjectCollection类代码示例

本文整理汇总了PHP中Propel\Runtime\Collection\ObjectCollection的典型用法代码示例。如果您正苦于以下问题:PHP ObjectCollection类的具体用法?PHP ObjectCollection怎么用?PHP ObjectCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLoad

 public function testLoad()
 {
     $collection = new ObjectCollection();
     $collection->setModel('\\Thelia\\Model\\RewritingArgument');
     for ($i = 0; $i < 3; $i++) {
         $ra = new RewritingArgument();
         $ra->setParameter('foo' . $i);
         $ra->setValue('bar' . $i);
         $ra->setVirtualColumn('ru_view', 'view');
         $ra->setVirtualColumn('ru_viewId', 'viewId');
         $ra->setVirtualColumn('ru_locale', 'locale');
         $ra->setVirtualColumn('ru_redirected_to_url', null);
         $collection->append($ra);
     }
     $resolverQuery = $this->getMock('\\Thelia\\Model\\RewritingUrlQuery', array('getResolverSearch'));
     $resolverQuery->expects($this->any())->method('getResolverSearch')->with('foo.html')->will($this->returnValue($collection));
     $resolver = new RewritingResolver();
     $rewritingUrlQuery = $this->getProperty('rewritingUrlQuery');
     $rewritingUrlQuery->setValue($resolver, $resolverQuery);
     $resolver->load('foo.html');
     $this->assertEquals('view', $resolver->view);
     $this->assertEquals('viewId', $resolver->viewId);
     $this->assertEquals('locale', $resolver->locale);
     $this->assertEquals(array('foo0' => 'bar0', 'foo1' => 'bar1', 'foo2' => 'bar2'), $resolver->otherParameters);
 }
开发者ID:margery,项目名称:thelia,代码行数:25,代码来源:RewritingResolverTest.php

示例2: testWithPaginate

 public function testWithPaginate()
 {
     QuerycacheTable1Query::create()->deleteAll();
     $coll = new ObjectCollection();
     $coll->setModel('\\Propel\\Tests\\Bookstore\\Behavior\\QuerycacheTable1');
     for ($i = 0; $i < 5; $i++) {
         $b = new QuerycacheTable1();
         $b->setTitle('Title' . $i);
         $coll[] = $b;
     }
     $coll->save();
     $pager = $this->getPager(2, 1);
     $this->assertEquals(5, $pager->getNbResults());
     $results = $pager->getResults();
     $this->assertEquals('query cache with paginate offset 0 limit 2', $pager->getQuery()->getQueryKey());
     $this->assertEquals(2, count($results));
     $this->assertEquals('Title1', $results[1]->getTitle());
     //jump to page 3
     $pager = $this->getPager(2, 3);
     $this->assertEquals(5, $pager->getNbResults());
     $results = $pager->getResults();
     $this->assertEquals('query cache with paginate offset 4 limit 2', $pager->getQuery()->getQueryKey());
     $this->assertEquals(1, count($results));
     $this->assertEquals('Title4', $results[0]->getTitle());
 }
开发者ID:naldz,项目名称:cyberden,代码行数:25,代码来源:QueryCacheTest.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param ObjectCollection                                                          $entries
  * @param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface             $objectIdentity
  * @param \Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface $permissionGrantingStrategy
  * @param array                                                                     $loadedSecurityIdentities
  * @param \Symfony\Component\Security\Acl\Model\AclInterface                        $parentAcl
  * @param bool                                                                      $inherited
  */
 public function __construct(ObjectCollection $entries, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSecurityIdentities = array(), AclInterface $parentAcl = null, $inherited = true)
 {
     if ($entries->getFullyQualifiedModel() !== $this->model) {
         throw new AclException(sprintf('The given collection does not contain models of class "%s" but of class "%s".', $this->model, $entries->getFullyQualifiedModel()));
     }
     foreach ($entries as $eachEntry) {
         if (null === $eachEntry->getFieldName() and null === $eachEntry->getObjectIdentityId()) {
             $this->classAces[] = new Entry($eachEntry, $this);
         }
         if (null !== $eachEntry->getFieldName() and null === $eachEntry->getObjectIdentityId()) {
             if (empty($this->classFieldAces[$eachEntry->getFieldName()])) {
                 $this->classFieldAces[$eachEntry->getFieldName()] = array();
                 $this->updateFields($eachEntry->getFieldName());
             }
             $this->classFieldAces[$eachEntry->getFieldName()][] = new FieldEntry($eachEntry, $this);
         }
         if (null === $eachEntry->getFieldName() and null !== $eachEntry->getObjectIdentityId()) {
             $this->objectAces[] = new Entry($eachEntry, $this);
         }
         if (null !== $eachEntry->getFieldName() and null !== $eachEntry->getObjectIdentityId()) {
             if (empty($this->objectFieldAces[$eachEntry->getFieldName()])) {
                 $this->objectFieldAces[$eachEntry->getFieldName()] = array();
                 $this->updateFields($eachEntry->getFieldName());
             }
             $this->objectFieldAces[$eachEntry->getFieldName()][] = new FieldEntry($eachEntry, $this);
         }
     }
     $this->objectIdentity = $objectIdentity;
     $this->permissionGrantingStrategy = $permissionGrantingStrategy;
     $this->parentAcl = $parentAcl;
     $this->inherited = $inherited;
     $this->loadedSecurityIdentities = $loadedSecurityIdentities;
     $this->fields = array_unique($this->fields);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:44,代码来源:Acl.php

示例4: testTransformWithData

 public function testTransformWithData()
 {
     $coll = new ObjectCollection();
     $coll->setData(array($a = new \stdClass(), $b = new \stdClass()));
     $result = $this->transformer->transform($coll);
     $this->assertTrue(is_array($result));
     $this->assertEquals(2, count($result));
     $this->assertSame($a, $result[0]);
     $this->assertSame($b, $result[1]);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:10,代码来源:CollectionToArrayTransformerTest.php

示例5: testGetGetterRelatedBy

 public function testGetGetterRelatedBy()
 {
     $objectA = new \Issue656TestObject();
     $objectA->setName('A');
     $objectB = new \Issue656TestObject();
     $objectB->setName('B');
     $collection = new ObjectCollection();
     $collection->push($objectB);
     $objectA->setIssue656TestObjectsRelatedByTo($collection);
     $this->assertEquals($collection, $objectA->getIssue656TestObjectsRelatedByTo());
 }
开发者ID:disider,项目名称:Propel2,代码行数:11,代码来源:Issue656Test.php

示例6: createBooks

 protected function createBooks($nb = 15, $con = null)
 {
     BookQuery::create()->deleteAll($con);
     $books = new ObjectCollection();
     $books->setModel('\\Propel\\Tests\\Bookstore\\Book');
     for ($i = 0; $i < $nb; $i++) {
         $b = new Book();
         $b->setTitle('Book' . $i);
         $books[] = $b;
     }
     $books->save($con);
 }
开发者ID:norfil,项目名称:Propel2,代码行数:12,代码来源:PropelModelPagerTest.php

示例7: reverseTransform

 public function reverseTransform($array)
 {
     $collection = new ObjectCollection();
     if ('' === $array || null === $array) {
         return $collection;
     }
     if (!is_array($array)) {
         throw new TransformationFailedException('Expected an array.');
     }
     $collection->setData($array);
     return $collection;
 }
开发者ID:naldz,项目名称:cyberden,代码行数:12,代码来源:CollectionToArrayTransformer.php

示例8: insertChunk

 /**
  * @param string $itemType
  * @param string $itemEvent
  * @param array $itemIds
  *
  * @return int
  */
 protected function insertChunk($itemType, $itemEvent, array $itemIds)
 {
     $propelCollection = new ObjectCollection();
     $propelCollection->setModel(SpyTouch::class);
     foreach ($itemIds as $itemId) {
         $touchEntity = new SpyTouch();
         $touchEntity->setItemEvent($itemEvent)->setItemId($itemId)->setItemType($itemType)->setTouched(new \DateTime());
         $propelCollection->append($touchEntity);
     }
     $propelCollection->save();
     return $propelCollection->count();
 }
开发者ID:spryker,项目名称:Touch,代码行数:19,代码来源:BulkTouchHandlerInsert.php

示例9: filterByAuthor

 /**
  * Filter the query by a related \Author object.
  * 
  * @param \Author|ObjectCollection $author The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  * @return $this|BookQuery The current query, for fluid interface
  */
 public function filterByAuthor($author, $comparison = null)
 {
     if ($author instanceof \Author) {
         return $this->addUsingAlias(BookEntityMap::COL_AUTHORID, $author->getid(), $comparison);
     } elseif ($author instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(BookEntityMap::COL_AUTHORID, $author->toKeyValue('PrimaryKey', 'id'), $comparison);
     } else {
         throw new PropelException('filterByAuthor() only accepts arguments of type \\Author or Collection');
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:20,代码来源:BaseBookQuery.php

示例10: testFromArray

 public function testFromArray()
 {
     $author = new Author();
     $author->setFirstName('Jane');
     $author->setLastName('Austen');
     $author->save();
     $books = array(array('Title' => 'Mansfield Park', 'ISBN' => 'FA404', 'AuthorId' => $author->getId()), array('Title' => 'Pride And Prejudice', 'ISBN' => 'FA404', 'AuthorId' => $author->getId()));
     $col = new ObjectCollection();
     $col->setModel('Propel\\Tests\\Bookstore\\Book');
     $col->fromArray($books);
     $col->save();
     $nbBooks = PropelQuery::from('Propel\\Tests\\Bookstore\\Book')->count();
     $this->assertEquals(6, $nbBooks);
     $booksByJane = PropelQuery::from('Propel\\Tests\\Bookstore\\Book b')->join('b.Author a')->where('a.LastName = ?', 'Austen')->count();
     $this->assertEquals(2, $booksByJane);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:16,代码来源:ObjectCollectionWithFixturesTest.php

示例11: save

 public function save($key = null)
 {
     if ($key === null) {
         $data = [];
         foreach (array_keys($this->preferences) as $key) {
             $data[] = $this->getPreference($key);
         }
         $collection = new ObjectCollection($data);
         $collection->setModel(PreferenceTableMap::CLASS_NAME);
         $collection->save();
     } else {
         if ($this->has($key)) {
             $p = $this->getPreference($key);
             $p->save();
         }
     }
 }
开发者ID:keeko,项目名称:framework,代码行数:17,代码来源:Preferences.php

示例12: testConstruct

 public function testConstruct()
 {
     $collection = new ObjectCollection();
     $collection->setModel('Propel\\Bundle\\PropelBundle\\Model\\Acl\\Entry');
     $acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
     $model = $this->createEntry();
     $model->setAuditFailure(true);
     $model->setSecurityIdentity(SecurityIdentity::fromAclIdentity($this->getRoleSecurityIdentity()));
     $entry = new Entry($model, $acl);
     $this->assertEquals($model->getMask(), $entry->getMask());
     $this->assertEquals($model->getGranting(), $entry->isGranting());
     $this->assertEquals($model->getGrantingStrategy(), $entry->getStrategy());
     $this->assertEquals($model->getAuditFailure(), $entry->isAuditFailure());
     $this->assertEquals($model->getAuditSuccess(), $entry->isAuditSuccess());
     $this->assertEquals($this->getRoleSecurityIdentity(), $entry->getSecurityIdentity());
     return $entry;
 }
开发者ID:naldz,项目名称:cyberden,代码行数:17,代码来源:EntryTest.php

示例13: removeType

 /**
  * @param  ChildRegionType $type The ChildRegionType object to remove.
  * @return $this|ChildRegionArea The current object (for fluent API support)
  */
 public function removeType(ChildRegionType $type)
 {
     if ($this->getTypes()->contains($type)) {
         $pos = $this->collTypes->search($type);
         $this->collTypes->remove($pos);
         if (null === $this->typesScheduledForDeletion) {
             $this->typesScheduledForDeletion = clone $this->collTypes;
             $this->typesScheduledForDeletion->clear();
         }
         $this->typesScheduledForDeletion[] = clone $type;
         $type->setArea(null);
     }
     return $this;
 }
开发者ID:keeko,项目名称:core,代码行数:18,代码来源:RegionArea.php

示例14: removeTeams

 /**
  * @param  ChildTeams $teams The ChildTeams object to remove.
  * @return $this|ChildLeagueRef The current object (for fluent API support)
  */
 public function removeTeams(ChildTeams $teams)
 {
     if ($this->getTeamss()->contains($teams)) {
         $pos = $this->collTeamss->search($teams);
         $this->collTeamss->remove($pos);
         if (null === $this->teamssScheduledForDeletion) {
             $this->teamssScheduledForDeletion = clone $this->collTeamss;
             $this->teamssScheduledForDeletion->clear();
         }
         $this->teamssScheduledForDeletion[] = $teams;
         $teams->setLeagueRef(null);
     }
     return $this;
 }
开发者ID:scornfield,项目名称:StrayAdmin,代码行数:18,代码来源:LeagueRef.php

示例15: removeBook

 /**
  * @param  ChildBook $book The ChildBook object to remove.
  * @return $this|ChildPublisher The current object (for fluent API support)
  */
 public function removeBook(ChildBook $book)
 {
     if ($this->getBooks()->contains($book)) {
         $pos = $this->collBooks->search($book);
         $this->collBooks->remove($pos);
         if (null === $this->booksScheduledForDeletion) {
             $this->booksScheduledForDeletion = clone $this->collBooks;
             $this->booksScheduledForDeletion->clear();
         }
         $this->booksScheduledForDeletion[] = clone $book;
         $book->setPublisher(null);
     }
     return $this;
 }
开发者ID:jeffblack360,项目名称:testpropel,代码行数:18,代码来源:Publisher.php


注:本文中的Propel\Runtime\Collection\ObjectCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。