public function delete(SaleDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
            $con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);

            $con->beginTransaction();

            try {
                // Update related products sale status, if required
                if ($sale->getActive()) {
                    $sale->setActive(false);

                    // Update related products sale status
                    $dispatcher->dispatch(
                        TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
                        new ProductSaleStatusUpdateEvent($sale)
                    );
                }

                $sale->setDispatcher($dispatcher)->delete($con);

                $event->setSale($sale);

                $con->commit();
            } catch (PropelException $e) {
                $con->rollback();
                throw $e;
            }
        }
    }
public function delete(SaleDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $sale = SaleQuery::create()->findPk($event->getSaleId())) {
            $con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);

            $con->beginTransaction();

            try {
                // Update related products sale status, if required
                if ($sale->getActive()) {
                    $sale->setActive(false);

                    // Update related products sale status
                    $dispatcher->dispatch(
                        TheliaEvents::UPDATE_PRODUCT_SALE_STATUS,
                        new ProductSaleStatusUpdateEvent($sale)
                    );
                }

                $sale->setDispatcher($dispatcher)->delete($con);

                $event->setSale($sale);

                $con->commit();
            } catch (PropelException $e) {
                $con->rollback();
                throw $e;
            }
        }
    }
public function delete ( SaleDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ sale = SaleQuery :: create ( ) -> findPk ( $ event -> getSaleId ( ) ) ) { $ con = Propel :: getWriteConnection ( SaleTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { // Update related products sale status, if required if ( $ sale -> getActive ( ) ) { $ sale -> setActive ( false ) ; // Update related products sale status $ dispatcher -> dispatch ( TheliaEvents :: UPDATE_PRODUCT_SALE_STATUS , new ProductSaleStatusUpdateEvent ( $ sale ) ) ; } $ sale -> setDispatcher ( $ dispatcher ) -> delete ( $ con ) ; $ event -> setSale ( $ sale ) ; $ con -> commit ( ) ; } catch ( PropelException $ e ) { $ con -> rollback ( ) ; throw $ e ; } } }
Delete a sale

@param  SaleDeleteEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws \Propel\Runtime\Exception\PropelException
Delete a sale