本文整理汇总了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();
}
示例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.');
}
示例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));
}
示例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());
}
示例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);
}
示例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);
}
}
}
示例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);
}