本文整理汇总了PHP中yii\base\Component::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::add方法的具体用法?PHP Component::add怎么用?PHP Component::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Component
的用法示例。
在下文中一共展示了Component::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Updates the position in the shopping cart
* If the position was previously added, then it will be updated in shopping cart,
* if the position was not previously in the cart, it will be added there.
* If the count of less than 1, the position will be deleted.
*
* @param IECartPosition $position
* @param int $quantity
*/
public function update(CartPosition $position, $quantity)
{
if (!$position instanceof Component) {
throw new InvalidArgumentException('invalid argument 1, product must implement CComponent interface');
}
$key = $position->getId();
$position->attachBehavior("CartPosition", new CartPositionBehaviour());
$position->setRefresh($this->refresh);
$position->setQuantity($quantity);
if ($position->getQuantity() < 1) {
$this->remove($key);
} else {
parent::add($key, $position);
}
$this->applyDiscounts();
$this->onUpdatePoistion(new Event($this));
$this->saveState();
}