/** * Hydrate the update form for this object, before passing it to the update template * * @param Sale $sale * @return SaleModificationForm */ protected function hydrateObjectForm($sale) { // Find all categories of the selected products $saleProducts = $sale->getSaleProductList(); $categories = $products = []; /** @var SaleProduct $saleProduct */ foreach ($saleProducts as $saleProduct) { $categories[] = $saleProduct->getProduct()->getDefaultCategoryId(); $products[] = $saleProduct->getProduct()->getId(); } $dateFormat = SaleModificationForm::PHP_DATE_FORMAT; // Transform the selected attributes list (product_id => array of attributes av id) into // product_id => comma separated list of attributes av id, to math the collection type (text) $saleProductsAttributesAvs = $sale->getSaleProductsAttributeList(); $product_attributes = []; foreach ($saleProductsAttributesAvs as $productId => $saleProductsAttributesAv) { $product_attributes[$productId] = implode(',', $saleProductsAttributesAv); } // Prepare the data that will hydrate the form $data = ['id' => $sale->getId(), 'locale' => $sale->getLocale(), 'title' => $sale->getTitle(), 'label' => $sale->getSaleLabel(), 'chapo' => $sale->getChapo(), 'description' => $sale->getDescription(), 'postscriptum' => $sale->getPostscriptum(), 'active' => $sale->getActive(), 'display_initial_price' => $sale->getDisplayInitialPrice(), 'start_date' => $sale->getStartDate($dateFormat), 'end_date' => $sale->getEndDate($dateFormat), 'price_offset_type' => $sale->getPriceOffsetType(), 'price_offset' => $sale->getPriceOffsets(), 'categories' => $categories, 'products' => $products, 'product_attributes' => $product_attributes]; // Setup the object form return new SaleModificationForm($this->getRequest(), "form", $data); }
/** * Filter the query by a related \Thelia\Model\Sale object * * @param \Thelia\Model\Sale|ObjectCollection $sale The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildSaleProductQuery The current query, for fluid interface */ public function filterBySale($sale, $comparison = null) { if ($sale instanceof \Thelia\Model\Sale) { return $this->addUsingAlias(SaleProductTableMap::SALE_ID, $sale->getId(), $comparison); } elseif ($sale instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(SaleProductTableMap::SALE_ID, $sale->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterBySale() only accepts arguments of type \\Thelia\\Model\\Sale or Collection'); } }
/** * Returns the object ID from the object * * @param Sale $object * * @return int sale id */ protected function getObjectId($object) { return $object->getId(); }
/** * Declares an association between this object and a ChildSale object. * * @param ChildSale $v * @return \Thelia\Model\SaleI18n The current object (for fluent API support) * @throws PropelException */ public function setSale(ChildSale $v = null) { if ($v === null) { $this->setId(NULL); } else { $this->setId($v->getId()); } $this->aSale = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildSale object, it will not be re-added. if ($v !== null) { $v->addSaleI18n($this); } return $this; }
/** * Exclude object from result * * @param ChildSale $sale Object to remove from the list of results * * @return ChildSaleQuery The current query, for fluid interface */ public function prune($sale = null) { if ($sale) { $this->addUsingAlias(SaleTableMap::ID, $sale->getId(), Criteria::NOT_EQUAL); } return $this; }