AddDiscountExtension::updateForm()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Broarm\EventTickets;
4
5
use Extension;
6
7
/**
8
 * Class AddDiscountExtension
9
 * @package Broarm\EventTickets
10
 * @property ReservationForm $owner
11
 */
12
class AddDiscountExtension extends Extension
13
{
14
    public function updateForm()
15
    {
16
        $fields = $this->owner->Fields();
17
        $reservation = $this->owner->getReservation();
18
        $event = $reservation->Event();
19
20
        if (!$event->DisableDiscountField) {
21
            $fields->add(
22
                $field = DiscountField::create('CouponCode', _t('DiscountForm.COUPON_CODE', 'Coupon code'))
23
            );
24
            $field->setForm($this->owner);
25
        }
26
    }
27
}
28