public function toggleActivity(SaleToggleActivityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $sale = $event->getSale();

        $con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);

        $con->beginTransaction();

        try {
            $sale
            ->setDispatcher($dispatcher)
            ->setActive(!$sale->getActive())
            ->save($con);

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

            $event->setSale($sale);

            $con->commit();
        } catch (PropelException $e) {
            $con->rollback();
            throw $e;
        }
    }
public function toggleActivity(SaleToggleActivityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        $sale = $event->getSale();

        $con = Propel::getWriteConnection(SaleTableMap::DATABASE_NAME);

        $con->beginTransaction();

        try {
            $sale
            ->setDispatcher($dispatcher)
            ->setActive(!$sale->getActive())
            ->save($con);

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

            $event->setSale($sale);

            $con->commit();
        } catch (PropelException $e) {
            $con->rollback();
            throw $e;
        }
    }
public function toggleActivity ( SaleToggleActivityEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ sale = $ event -> getSale ( ) ; $ con = Propel :: getWriteConnection ( SaleTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ sale -> setDispatcher ( $ dispatcher ) -> setActive ( ! $ sale -> getActive ( ) ) -> save ( $ con ) ; // Update related products sale status $ dispatcher -> dispatch ( TheliaEvents :: UPDATE_PRODUCT_SALE_STATUS , new ProductSaleStatusUpdateEvent ( $ sale ) ) ; $ event -> setSale ( $ sale ) ; $ con -> commit ( ) ; } catch ( PropelException $ e ) { $ con -> rollback ( ) ; throw $ e ; } }
Toggle Sale activity

@param SaleToggleActivityEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
@throws \Propel\Runtime\Exception\PropelException
Toggle Sale activity