public function createAction()
    {
        if (null !== $response = $this->checkAuth(AdminResources::COUPON, [], AccessManager::CREATE)) {
            return $response;
        }

        // Parameters given to the template
        $args = [];

        $eventToDispatch = TheliaEvents::COUPON_CREATE;

        if ($this->getRequest()->isMethod('POST')) {
            if (null !== $response = $this->validateCreateOrUpdateForm(
                $eventToDispatch,
                'created',
                'creation'
            )) {
                return $response;
            }
        } else {
            // If no input for expirationDate, now + 2 months
            $defaultDate = new \DateTime();
            $args['nowDate'] = $defaultDate->format($this->getDefaultDateFormat());
            $args['defaultDate'] = $defaultDate->modify('+2 month')->format($this->getDefaultDateFormat());
        }

        $args['dateFormat'] = $this->getDefaultDateFormat();
        $args['availableCoupons'] = $this->getAvailableCoupons();
        $args['urlAjaxAdminCouponDrawInputs'] = $this->getRoute(
            'admin.coupon.draw.inputs.ajax',
            ['couponServiceId' => 'couponServiceId'],
            Router::ABSOLUTE_URL
        );
        $args['formAction'] = 'admin/coupon/create';

        // Setup empty data if form is already in parser context
        $this->getParserContext()->addForm($this->createForm(AdminForm::COUPON_CREATION));

        return $this->render(
            'coupon-create',
            $args
        );
    }
public function createAction()
    {
        if (null !== $response = $this->checkAuth(AdminResources::COUPON, [], AccessManager::CREATE)) {
            return $response;
        }

        // Parameters given to the template
        $args = [];

        $eventToDispatch = TheliaEvents::COUPON_CREATE;

        if ($this->getRequest()->isMethod('POST')) {
            if (null !== $response = $this->validateCreateOrUpdateForm(
                $eventToDispatch,
                'created',
                'creation'
            )) {
                return $response;
            }
        } else {
            // If no input for expirationDate, now + 2 months
            $defaultDate = new \DateTime();
            $args['nowDate'] = $defaultDate->format($this->getDefaultDateFormat());
            $args['defaultDate'] = $defaultDate->modify('+2 month')->format($this->getDefaultDateFormat());
        }

        $args['dateFormat'] = $this->getDefaultDateFormat();
        $args['availableCoupons'] = $this->getAvailableCoupons();
        $args['urlAjaxAdminCouponDrawInputs'] = $this->getRoute(
            'admin.coupon.draw.inputs.ajax',
            ['couponServiceId' => 'couponServiceId'],
            Router::ABSOLUTE_URL
        );
        $args['formAction'] = 'admin/coupon/create';

        // Setup empty data if form is already in parser context
        $this->getParserContext()->addForm($this->createForm(AdminForm::COUPON_CREATION));

        return $this->render(
            'coupon-create',
            $args
        );
    }
public function createAction ( ) { if ( null !== $ response = $ this -> checkAuth ( AdminResources :: COUPON , [ ] , AccessManager :: CREATE ) ) { return $ response ; } // Parameters given to the template $ args = [ ] ; $ eventToDispatch = TheliaEvents :: COUPON_CREATE ; if ( $ this -> getRequest ( ) -> isMethod ( 'POST' ) ) { if ( null !== $ response = $ this -> validateCreateOrUpdateForm ( $ eventToDispatch , 'created' , 'creation' ) ) { return $ response ; } } else { // If no input for expirationDate, now + 2 months $ defaultDate = new \ DateTime ( ) ; $ args [ 'nowDate' ] = $ defaultDate -> format ( $ this -> getDefaultDateFormat ( ) ) ; $ args [ 'defaultDate' ] = $ defaultDate -> modify ( '+2 month' ) -> format ( $ this -> getDefaultDateFormat ( ) ) ; } $ args [ 'dateFormat' ] = $ this -> getDefaultDateFormat ( ) ; $ args [ 'availableCoupons' ] = $ this -> getAvailableCoupons ( ) ; $ args [ 'urlAjaxAdminCouponDrawInputs' ] = $ this -> getRoute ( 'admin.coupon.draw.inputs.ajax' , [ 'couponServiceId' => 'couponServiceId' ] , Router :: ABSOLUTE_URL ) ; $ args [ 'formAction' ] = 'admin/coupon/create' ; // Setup empty data if form is already in parser context $ this -> getParserContext ( ) -> addForm ( $ this -> createForm ( AdminForm :: COUPON_CREATION ) ) ; return $ this -> render ( 'coupon-create' , $ args ) ; }
Manage Coupons creation display

@return \Thelia\Core\HttpFoundation\Response
Manage Coupons creation display