Completed
Branch FET-8385-datetime-ticket-selec... (cac7e5)
by
unknown
67:23 queued 43:13
created

TicketSelectorStandard::addTemplateArgs()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 39
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 32
nc 4
nop 0
dl 0
loc 39
rs 8.5806
c 0
b 0
f 0
1
<?php
2
namespace EventEspresso\modules\ticket_selector;
3
4
defined('ABSPATH') || exit;
5
6
7
8
/**
9
 * Class TicketSelectorStandard
10
 * regular ticket selector that displays one row for each ticket
11
 * with a dropdown for selecting the desired ticket quantity
12
 *
13
 * @package       Event Espresso
14
 * @author        Brent Christensen
15
 * @since         4.9.18
16
 */
17
class TicketSelectorStandard extends TicketSelector
18
{
19
20
    /**
21
     * @var string $date_format
22
     */
23
    protected $date_format;
24
25
    /**
26
     * @var \EE_Ticket_Selector_Config $ticket_selector_config
27
     */
28
    protected $ticket_selector_config;
29
30
    /**
31
     * @var \EE_Tax_Config $tax_config
32
     */
33
    protected $tax_config;
34
35
36
37
    /**
38
     * TicketSelectorSimple constructor.
39
     *
40
     * @param \EE_Event                  $event
41
     * @param \EE_Ticket[]               $tickets
42
     * @param int                        $max_attendees
43
     * @param array                      $template_args
44
     * @param string                     $date_format
45
     * @param \EE_Ticket_Selector_Config $ticket_selector_config
46
     * @param \EE_Tax_Config             $tax_config
47
     */
48
    public function __construct(
49
        \EE_Event $event,
50
        array $tickets,
51
        $max_attendees,
52
        array $template_args,
53
        $date_format = 'Y-m-d',
0 ignored issues
show
Unused Code introduced by
The parameter $date_format is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
54
        \EE_Ticket_Selector_Config $ticket_selector_config = null,
0 ignored issues
show
Unused Code introduced by
The parameter $ticket_selector_config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
        \EE_Tax_Config $tax_config = null
0 ignored issues
show
Unused Code introduced by
The parameter $tax_config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
    ) {
57
        // get EE_Ticket_Selector_Config and TicketDetails
58
        $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
59
            ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
60
            : new \EE_Ticket_Selector_Config();
61
        // $template_settings->setDatetimeSelectorThreshold(2);
62
        // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__);
63
        // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__);
64
        $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings)
65
            ? \EE_Registry::instance()->CFG->tax_settings
66
            : new \EE_Tax_Config();
67
        parent::__construct($event, $tickets, $max_attendees, $template_args);
68
    }
69
70
71
72
    /**
73
     * sets any and all template args that are required for this Ticket Selector
74
     *
75
     * @return void
76
     * @throws \EE_Error
77
     */
78
    protected function addTemplateArgs()
79
    {
80
        $row = 1;
81
        $ticket_row_html = '';
82
        $required_ticket_sold_out = false;
83
        // flag to indicate that at least one taxable ticket has been encountered
84
        $taxable_tickets = false;
85
        $datetime_selector = new DatetimeSelector($this->event, $this->tickets, $this->ticket_selector_config);
86
        // loop through tickets
87
        foreach ($this->tickets as $TKT_ID => $ticket) {
88
            if ($ticket instanceof \EE_Ticket) {
89
                $cols = 2;
90
                $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
91
                $ticket_selector_row = new TicketSelectorRowStandard(
92
                    $ticket,
93
                    new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),
94
                    $this->ticket_selector_config,
95
                    $this->tax_config,
96
                    $this->max_attendees,
97
                    $row,
98
                    $cols,
99
                    $required_ticket_sold_out,
100
                    $this->template_args['event_status'],
101
                    $this->template_args['date_format'],
102
                    $datetime_selector->getTicketDatetimeClasses($ticket)
103
                );
104
                $ticket_row_html .= $ticket_selector_row->getHtml();
105
                $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();
106
                $row++;
107
            }
108
        }
109
        $this->template_args['row'] = $row;
110
        $this->template_args['ticket_row_html'] = $ticket_row_html;
111
        $this->template_args['taxable_tickets'] = $taxable_tickets;
112
        $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector($this->date_format);
113
        $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
114
        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
115
        remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
116
    }
117
118
119
120
}
121
// End of file TicketSelectorStandard.php
122
// Location: EventEspresso\modules\ticket_selector/TicketSelectorStandard.php