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


PHP ObjectCollection::append方法代码示例

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


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

示例1: 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

示例2: testIssue1133OffsetSet

 public function testIssue1133OffsetSet()
 {
     $testCollection = new ObjectCollection();
     $testCollection->setModel(DummyObject::class);
     for ($i = 0; $i < 3; $i++) {
         $testCollection->append(new DummyObject($i));
     }
     $firstToRemove = $testCollection[0];
     $objectThatShouldNotBeRemoved = $testCollection[2];
     // breaks index numbering
     $testCollection->removeObject($firstToRemove);
     $objectThatWillBeRemoved = new DummyObject(3);
     // calls offsetSet
     $testCollection[] = $objectThatWillBeRemoved;
     $testCollection->removeObject($objectThatWillBeRemoved);
     $this->assertContains($objectThatShouldNotBeRemoved, $testCollection, 'ObjectCollection does not contain item that should be in collection.');
     $this->assertNotContains($objectThatWillBeRemoved, $testCollection, 'ObjectCollection contains item that should be removed.');
 }
开发者ID:SwissalpS,项目名称:Propel2,代码行数:18,代码来源:Issue1133Test.php

示例3: testSerializeUnserialize

 public function testSerializeUnserialize()
 {
     $collection = new ObjectCollection();
     $collection->setModel('Propel\\Bundle\\PropelBundle\\Model\\Acl\\Entry');
     $entry = $this->createEntry();
     $entry->setSecurityIdentity(SecurityIdentity::fromAclIdentity($this->getRoleSecurityIdentity('ROLE_ADMIN')))->setAclClass($this->getAclClass());
     $collection->append($entry);
     $acl = new MutableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
     $serialized = serialize($acl);
     $unserialized = unserialize($serialized);
     $this->assertNotEmpty($serialized);
     $this->assertNotEmpty($unserialized);
     $this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Security\\Acl\\Domain\\MutableAcl', $unserialized);
     $this->assertEquals($serialized, serialize($unserialized));
 }
开发者ID:naldz,项目名称:cyberden,代码行数:15,代码来源:MutableAclTest.php

示例4: testUpdateClassFieldAuditing

 /**
  * @depends testUpdateObjectAuditing
  */
 public function testUpdateClassFieldAuditing()
 {
     $collection = new ObjectCollection();
     $collection->setModel('Propel\\Bundle\\PropelBundle\\Model\\Acl\\Entry');
     $entry = $this->createEntry();
     $entry->setFieldName('name')->setSecurityIdentity(SecurityIdentity::fromAclIdentity($this->getRoleSecurityIdentity()))->setAclClass($this->getAclClass());
     $collection->append($entry);
     $acl = new AuditableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
     $aces = $acl->getClassFieldAces('name');
     $this->assertCount(1, $aces);
     $acl->updateClassFieldAuditing(0, 'name', true, true);
     $aces = $acl->getClassFieldAces('name');
     $this->assertTrue($aces[0]->isAuditSuccess());
     $this->assertTrue($aces[0]->isAuditFailure());
     $acl->updateClassFieldAuditing(0, 'name', false, false);
     $aces = $acl->getClassFieldAces('name');
     $this->assertFalse($aces[0]->isAuditSuccess());
     $this->assertFalse($aces[0]->isAuditFailure());
 }
开发者ID:naldz,项目名称:cyberden,代码行数:22,代码来源:AuditableAclTest.php

示例5: testGetUntaxedPriceAndGetTaxAmountFromTaxedPrice

 public function testGetUntaxedPriceAndGetTaxAmountFromTaxedPrice()
 {
     $taxRulesCollection = new ObjectCollection();
     $taxRulesCollection->setModel('\\Thelia\\Model\\Tax');
     $tax = new Tax();
     $tax->setType('\\Thelia\\TaxEngine\\TaxType\\PricePercentTaxType')->setRequirements(array('percent' => 10))->setVirtualColumn('taxRuleCountryPosition', 1);
     $taxRulesCollection->append($tax);
     $tax = new Tax();
     $tax->setType('\\Thelia\\TaxEngine\\TaxType\\PricePercentTaxType')->setRequirements(array('percent' => 8))->setVirtualColumn('taxRuleCountryPosition', 1);
     $taxRulesCollection->append($tax);
     $tax = new Tax();
     $tax->setType('\\Thelia\\TaxEngine\\TaxType\\FixAmountTaxType')->setRequirements(array('amount' => 5))->setVirtualColumn('taxRuleCountryPosition', 2);
     $taxRulesCollection->append($tax);
     $tax = new Tax();
     $tax->setType('\\Thelia\\TaxEngine\\TaxType\\PricePercentTaxType')->setRequirements(array('percent' => 1))->setVirtualColumn('taxRuleCountryPosition', 3);
     $taxRulesCollection->append($tax);
     $aProduct = ProductQuery::create()->findOne();
     if (null === $aProduct) {
         return;
     }
     $calculator = new Calculator();
     $rewritingUrlQuery = $this->getProperty('taxRulesCollection');
     $rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
     $product = $this->getProperty('product');
     $product->setValue($calculator, $aProduct);
     $taxAmount = $calculator->getTaxAmountFromTaxedPrice(600.95);
     $untaxedPrice = $calculator->getUntaxedPrice(600.95);
     /*
      * expect :
      *  tax 3 = 600.95 - 600.95 / (1 + 0.01) = 5,95 // amount without tax 3 : 595
      *  tax 2 = 5 // amount without tax 2 : 590
      *  tax 1 = 590 - 590 / (1 + 0.08 + 0.10) = 90 // amount without tax 1 : 500
      * total tax amount = 100.95
      */
     $this->assertEquals(100.95, $taxAmount);
     $this->assertEquals(500, $untaxedPrice);
 }
开发者ID:shirone,项目名称:thelia,代码行数:37,代码来源:CalculatorTest.php

示例6: addProductWhenAjaxChangeActive

 public static function addProductWhenAjaxChangeActive($arg)
 {
     /* @var $model SProducts */
     $models = $arg['model'];
     /* @var $ci MY_Controller */
     $ci =& get_instance();
     if (!$models instanceof PropelObjectCollection) {
         $model = $models;
         $models = new PropelObjectCollection();
         $models->append($model);
     }
     foreach ($models as $model) {
         if ($model->getActive()) {
             $ci->db->where('trash_url', 'shop/product/' . $model->getUrl())->delete('trash');
         } else {
             $array = array('trash_id' => $model->getCategoryId(), 'trash_url' => 'shop/product/' . $model->getUrl(), 'trash_redirect_type' => 'category', 'trash_type' => '302', 'trash_redirect' => shop_url('category/' . $model->getMainCategory()->getFullPath()));
             $ci->db->insert('trash', $array);
         }
     }
 }
开发者ID:RandomUsernameHere,项目名称:megainfo-corporate-cms,代码行数:20,代码来源:trash.php

示例7: 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


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