public function __construct($attributes) { parent::__construct($attributes); if (!isset($this->attributes['base_price_field']) || !$this->attributes['base_price_field'] instanceof Field) { throw new Exception("Base price source field (attribute: base_price_field) not set for field '{$this->attributes['name']}'."); } $this->attributes['base_price_field_name'] = $this->attributes['base_price_field']->getName(); $this->attributes['suffixes'] = App::getModel('suffix/suffix')->getSuffixTypesForSelect(); }
/** * This is the constructor of the price with quantity object. * * @api * @author David Pauli <*****@*****.**> * @since 0.1.0 * @since 0.1.1 No locale parameter is needed * @param mixed[] $priceParameter The price parameter. * @param mixed[] $quantityParameter The quantity parameter. */ public function __construct($priceParameter, $quantityParameter) { parent::__construct($priceParameter); if (InputValidator::isArray($quantityParameter)) { if (!InputValidator::isEmptyArrayKey($quantityParameter, "amount")) { $this->quantityAmount = $quantityParameter['amount']; } if (!InputValidator::isEmptyArrayKey($quantityParameter, "unit")) { $this->quantityUnit = $quantityParameter['unit']; } } }