當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。