Completed
Branch FET/add-step-bubble-nav-compon... (18c94e)
by
unknown
09:13 queued 24s
created
core/services/commands/ticket/CancelTicketLineItemCommandHandler.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,36 +23,36 @@
 block discarded – undo
23 23
 {
24 24
 
25 25
 
26
-    /**
27
-     * @var CancelTicketLineItemService $cancel_ticket_line_item_service
28
-     */
29
-    private $cancel_ticket_line_item_service;
30
-
31
-
32
-    /**
33
-     * Command constructor
34
-     *
35
-     * @param CancelTicketLineItemService $cancel_ticket_line_item_service
36
-     */
37
-    public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
38
-    {
39
-        $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
40
-    }
41
-
42
-
43
-    /**
44
-     * @param CommandInterface|CancelTicketLineItemCommand $command
45
-     * @return mixed
46
-     * @throws InvalidEntityException
47
-     * @throws RuntimeException
48
-     */
49
-    public function handle(CommandInterface $command)
50
-    {
51
-        return $this->cancel_ticket_line_item_service->cancel(
52
-            $command->transaction(),
53
-            $command->ticket(),
54
-            $command->quantity(),
55
-            $command->ticketLineItem()
56
-        );
57
-    }
26
+	/**
27
+	 * @var CancelTicketLineItemService $cancel_ticket_line_item_service
28
+	 */
29
+	private $cancel_ticket_line_item_service;
30
+
31
+
32
+	/**
33
+	 * Command constructor
34
+	 *
35
+	 * @param CancelTicketLineItemService $cancel_ticket_line_item_service
36
+	 */
37
+	public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
38
+	{
39
+		$this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
40
+	}
41
+
42
+
43
+	/**
44
+	 * @param CommandInterface|CancelTicketLineItemCommand $command
45
+	 * @return mixed
46
+	 * @throws InvalidEntityException
47
+	 * @throws RuntimeException
48
+	 */
49
+	public function handle(CommandInterface $command)
50
+	{
51
+		return $this->cancel_ticket_line_item_service->cancel(
52
+			$command->transaction(),
53
+			$command->ticket(),
54
+			$command->quantity(),
55
+			$command->ticketLineItem()
56
+		);
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/services/commands/ticket/CreateTicketLineItemCommandHandler.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -22,37 +22,37 @@
 block discarded – undo
22 22
 {
23 23
 
24 24
 
25
-    /**
26
-     * @var CreateTicketLineItemService $factory
27
-     */
28
-    private $factory;
29
-
30
-
31
-    /**
32
-     * Command constructor
33
-     *
34
-     * @param CreateTicketLineItemService $factory
35
-     */
36
-    public function __construct(CreateTicketLineItemService $factory)
37
-    {
38
-        $this->factory = $factory;
39
-    }
40
-
41
-
42
-    /**
43
-     * @param CommandInterface|CreateTicketLineItemCommand $command
44
-     * @return EE_Line_Item
45
-     * @throws InvalidEntityException
46
-     * @throws UnexpectedEntityException
47
-     * @throws EE_Error
48
-     */
49
-    public function handle(CommandInterface $command)
50
-    {
51
-        // create new line item for ticket
52
-        return $this->factory->create(
53
-            $command->transaction(),
54
-            $command->ticket(),
55
-            $command->quantity()
56
-        );
57
-    }
25
+	/**
26
+	 * @var CreateTicketLineItemService $factory
27
+	 */
28
+	private $factory;
29
+
30
+
31
+	/**
32
+	 * Command constructor
33
+	 *
34
+	 * @param CreateTicketLineItemService $factory
35
+	 */
36
+	public function __construct(CreateTicketLineItemService $factory)
37
+	{
38
+		$this->factory = $factory;
39
+	}
40
+
41
+
42
+	/**
43
+	 * @param CommandInterface|CreateTicketLineItemCommand $command
44
+	 * @return EE_Line_Item
45
+	 * @throws InvalidEntityException
46
+	 * @throws UnexpectedEntityException
47
+	 * @throws EE_Error
48
+	 */
49
+	public function handle(CommandInterface $command)
50
+	{
51
+		// create new line item for ticket
52
+		return $this->factory->create(
53
+			$command->transaction(),
54
+			$command->ticket(),
55
+			$command->quantity()
56
+		);
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/services/commands/attendee/CreateAttendeeCommandHandler.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -21,134 +21,134 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * @var EEM_Attendee $attendee_model
26
-     */
27
-    protected $attendee_model;
24
+	/**
25
+	 * @var EEM_Attendee $attendee_model
26
+	 */
27
+	protected $attendee_model;
28 28
 
29 29
 
30
-    /**
31
-     * @param EEM_Attendee $attendee_model
32
-     */
33
-    public function __construct(EEM_Attendee $attendee_model)
34
-    {
35
-        $this->attendee_model = $attendee_model;
36
-    }
30
+	/**
31
+	 * @param EEM_Attendee $attendee_model
32
+	 */
33
+	public function __construct(EEM_Attendee $attendee_model)
34
+	{
35
+		$this->attendee_model = $attendee_model;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @param CommandInterface|CreateAttendeeCommand $command
41
-     * @return EE_Attendee
42
-     * @throws EE_Error
43
-     * @throws InvalidEntityException
44
-     */
45
-    public function handle(CommandInterface $command)
46
-    {
47
-        // have we met before?
48
-        $attendee = $this->findExistingAttendee(
49
-            $command->registration(),
50
-            $command->attendeeDetails()
51
-        );
52
-        // did we find an already existing record for this attendee ?
53
-        if ($attendee instanceof EE_Attendee) {
54
-            $attendee = $this->updateExistingAttendeeData(
55
-                $attendee,
56
-                $command->attendeeDetails()
57
-            );
58
-        } else {
59
-            $attendee = $this->createNewAttendee(
60
-                $command->registration(),
61
-                $command->attendeeDetails()
62
-            );
63
-        }
64
-        return $attendee;
65
-    }
39
+	/**
40
+	 * @param CommandInterface|CreateAttendeeCommand $command
41
+	 * @return EE_Attendee
42
+	 * @throws EE_Error
43
+	 * @throws InvalidEntityException
44
+	 */
45
+	public function handle(CommandInterface $command)
46
+	{
47
+		// have we met before?
48
+		$attendee = $this->findExistingAttendee(
49
+			$command->registration(),
50
+			$command->attendeeDetails()
51
+		);
52
+		// did we find an already existing record for this attendee ?
53
+		if ($attendee instanceof EE_Attendee) {
54
+			$attendee = $this->updateExistingAttendeeData(
55
+				$attendee,
56
+				$command->attendeeDetails()
57
+			);
58
+		} else {
59
+			$attendee = $this->createNewAttendee(
60
+				$command->registration(),
61
+				$command->attendeeDetails()
62
+			);
63
+		}
64
+		return $attendee;
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * find_existing_attendee
70
-     *
71
-     * @param EE_Registration $registration
72
-     * @param  array          $attendee_data
73
-     * @return EE_Attendee
74
-     */
75
-    private function findExistingAttendee(EE_Registration $registration, array $attendee_data)
76
-    {
77
-        $existing_attendee = null;
78
-        // does this attendee already exist in the db ?
79
-        // we're searching using a combination of first name, last name, AND email address
80
-        $ATT_fname = ! empty($attendee_data['ATT_fname'])
81
-            ? $attendee_data['ATT_fname']
82
-            : '';
83
-        $ATT_lname = ! empty($attendee_data['ATT_lname'])
84
-            ? $attendee_data['ATT_lname']
85
-            : '';
86
-        $ATT_email = ! empty($attendee_data['ATT_email'])
87
-            ? $attendee_data['ATT_email']
88
-            : '';
89
-        // but only if those have values
90
-        if ($ATT_fname && $ATT_lname && $ATT_email) {
91
-            $existing_attendee = $this->attendee_model->find_existing_attendee(
92
-                array(
93
-                    'ATT_fname' => $ATT_fname,
94
-                    'ATT_lname' => $ATT_lname,
95
-                    'ATT_email' => $ATT_email,
96
-                )
97
-            );
98
-        }
99
-        return apply_filters(
100
-            'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
101
-            $existing_attendee,
102
-            $registration,
103
-            $attendee_data
104
-        );
105
-    }
68
+	/**
69
+	 * find_existing_attendee
70
+	 *
71
+	 * @param EE_Registration $registration
72
+	 * @param  array          $attendee_data
73
+	 * @return EE_Attendee
74
+	 */
75
+	private function findExistingAttendee(EE_Registration $registration, array $attendee_data)
76
+	{
77
+		$existing_attendee = null;
78
+		// does this attendee already exist in the db ?
79
+		// we're searching using a combination of first name, last name, AND email address
80
+		$ATT_fname = ! empty($attendee_data['ATT_fname'])
81
+			? $attendee_data['ATT_fname']
82
+			: '';
83
+		$ATT_lname = ! empty($attendee_data['ATT_lname'])
84
+			? $attendee_data['ATT_lname']
85
+			: '';
86
+		$ATT_email = ! empty($attendee_data['ATT_email'])
87
+			? $attendee_data['ATT_email']
88
+			: '';
89
+		// but only if those have values
90
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
91
+			$existing_attendee = $this->attendee_model->find_existing_attendee(
92
+				array(
93
+					'ATT_fname' => $ATT_fname,
94
+					'ATT_lname' => $ATT_lname,
95
+					'ATT_email' => $ATT_email,
96
+				)
97
+			);
98
+		}
99
+		return apply_filters(
100
+			'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
101
+			$existing_attendee,
102
+			$registration,
103
+			$attendee_data
104
+		);
105
+	}
106 106
 
107 107
 
108
-    /**
109
-     * _update_existing_attendee_data
110
-     * in case it has changed since last time they registered for an event
111
-     *
112
-     * @param EE_Attendee $existing_attendee
113
-     * @param  array      $attendee_data
114
-     * @return EE_Attendee
115
-     * @throws EE_Error
116
-     */
117
-    private function updateExistingAttendeeData(EE_Attendee $existing_attendee, array $attendee_data)
118
-    {
119
-        // first remove fname, lname, and email from attendee data
120
-        // because these properties will be exactly the same as the returned attendee object,
121
-        // since they were used in the query to get the attendee object in the first place
122
-        $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
123
-        // now loop thru what's left and add to attendee CPT
124
-        foreach ($attendee_data as $property_name => $property_value) {
125
-            if (! in_array($property_name, $dont_set, true)
126
-                && $this->attendee_model->has_field($property_name)
127
-            ) {
128
-                $existing_attendee->set($property_name, $property_value);
129
-            }
130
-        }
131
-        // better save that now
132
-        $existing_attendee->save();
133
-        return $existing_attendee;
134
-    }
108
+	/**
109
+	 * _update_existing_attendee_data
110
+	 * in case it has changed since last time they registered for an event
111
+	 *
112
+	 * @param EE_Attendee $existing_attendee
113
+	 * @param  array      $attendee_data
114
+	 * @return EE_Attendee
115
+	 * @throws EE_Error
116
+	 */
117
+	private function updateExistingAttendeeData(EE_Attendee $existing_attendee, array $attendee_data)
118
+	{
119
+		// first remove fname, lname, and email from attendee data
120
+		// because these properties will be exactly the same as the returned attendee object,
121
+		// since they were used in the query to get the attendee object in the first place
122
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
123
+		// now loop thru what's left and add to attendee CPT
124
+		foreach ($attendee_data as $property_name => $property_value) {
125
+			if (! in_array($property_name, $dont_set, true)
126
+				&& $this->attendee_model->has_field($property_name)
127
+			) {
128
+				$existing_attendee->set($property_name, $property_value);
129
+			}
130
+		}
131
+		// better save that now
132
+		$existing_attendee->save();
133
+		return $existing_attendee;
134
+	}
135 135
 
136 136
 
137
-    /**
138
-     * create_new_attendee
139
-     *
140
-     * @param EE_Registration $registration
141
-     * @param  array          $attendee_data
142
-     * @return EE_Attendee
143
-     * @throws EE_Error
144
-     */
145
-    private function createNewAttendee(EE_Registration $registration, array $attendee_data)
146
-    {
147
-        // create new attendee object
148
-        $new_attendee = EE_Attendee::new_instance($attendee_data);
149
-        // set author to event creator
150
-        $new_attendee->set('ATT_author', $registration->event()->wp_user());
151
-        $new_attendee->save();
152
-        return $new_attendee;
153
-    }
137
+	/**
138
+	 * create_new_attendee
139
+	 *
140
+	 * @param EE_Registration $registration
141
+	 * @param  array          $attendee_data
142
+	 * @return EE_Attendee
143
+	 * @throws EE_Error
144
+	 */
145
+	private function createNewAttendee(EE_Registration $registration, array $attendee_data)
146
+	{
147
+		// create new attendee object
148
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
149
+		// set author to event creator
150
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
151
+		$new_attendee->save();
152
+		return $new_attendee;
153
+	}
154 154
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@
 block discarded – undo
122 122
         $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
123 123
         // now loop thru what's left and add to attendee CPT
124 124
         foreach ($attendee_data as $property_name => $property_value) {
125
-            if (! in_array($property_name, $dont_set, true)
125
+            if ( ! in_array($property_name, $dont_set, true)
126 126
                 && $this->attendee_model->has_field($property_name)
127 127
             ) {
128 128
                 $existing_attendee->set($property_name, $property_value);
Please login to merge, or discard this patch.
registration/UpdateRegistrationAndTransactionAfterChangeCommandHandler.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -19,31 +19,31 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * @var UpdateRegistrationService $update_registration_service
24
-     */
25
-    private $update_registration_service;
26
-
27
-
28
-    /**
29
-     * Command constructor
30
-     *
31
-     * @param UpdateRegistrationService $update_registration_service
32
-     */
33
-    public function __construct(
34
-        UpdateRegistrationService $update_registration_service
35
-    ) {
36
-        $this->update_registration_service = $update_registration_service;
37
-    }
38
-
39
-
40
-    /**
41
-     * @param CommandInterface|UpdateRegistrationAndTransactionAfterChangeCommand $command
42
-     * @return boolean
43
-     * @throws InvalidEntityException
44
-     */
45
-    public function handle(CommandInterface $command)
46
-    {
47
-        return $this->update_registration_service->updateRegistrationAndTransaction($command->registration());
48
-    }
22
+	/**
23
+	 * @var UpdateRegistrationService $update_registration_service
24
+	 */
25
+	private $update_registration_service;
26
+
27
+
28
+	/**
29
+	 * Command constructor
30
+	 *
31
+	 * @param UpdateRegistrationService $update_registration_service
32
+	 */
33
+	public function __construct(
34
+		UpdateRegistrationService $update_registration_service
35
+	) {
36
+		$this->update_registration_service = $update_registration_service;
37
+	}
38
+
39
+
40
+	/**
41
+	 * @param CommandInterface|UpdateRegistrationAndTransactionAfterChangeCommand $command
42
+	 * @return boolean
43
+	 * @throws InvalidEntityException
44
+	 */
45
+	public function handle(CommandInterface $command)
46
+	{
47
+		return $this->update_registration_service->updateRegistrationAndTransaction($command->registration());
48
+	}
49 49
 }
Please login to merge, or discard this patch.
services/commands/registration/CopyRegistrationPaymentsCommandHandler.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,35 +23,35 @@
 block discarded – undo
23 23
 {
24 24
 
25 25
 
26
-    /**
27
-     * @var CopyRegistrationService $copy_registration_service
28
-     */
29
-    private $copy_registration_service;
30
-
31
-
32
-    /**
33
-     * Command constructor
34
-     *
35
-     * @param CopyRegistrationService $copy_registration_service
36
-     */
37
-    public function __construct(CopyRegistrationService $copy_registration_service)
38
-    {
39
-        $this->copy_registration_service = $copy_registration_service;
40
-    }
41
-
42
-
43
-    /**
44
-     * @param CommandInterface|CopyRegistrationPaymentsCommand $command
45
-     * @return boolean
46
-     * @throws EE_Error
47
-     * @throws UnexpectedEntityException
48
-     * @throws RuntimeException
49
-     */
50
-    public function handle(CommandInterface $command)
51
-    {
52
-        return $this->copy_registration_service->copyPaymentDetails(
53
-            $command->targetRegistration(),
54
-            $command->registrationToCopy()
55
-        );
56
-    }
26
+	/**
27
+	 * @var CopyRegistrationService $copy_registration_service
28
+	 */
29
+	private $copy_registration_service;
30
+
31
+
32
+	/**
33
+	 * Command constructor
34
+	 *
35
+	 * @param CopyRegistrationService $copy_registration_service
36
+	 */
37
+	public function __construct(CopyRegistrationService $copy_registration_service)
38
+	{
39
+		$this->copy_registration_service = $copy_registration_service;
40
+	}
41
+
42
+
43
+	/**
44
+	 * @param CommandInterface|CopyRegistrationPaymentsCommand $command
45
+	 * @return boolean
46
+	 * @throws EE_Error
47
+	 * @throws UnexpectedEntityException
48
+	 * @throws RuntimeException
49
+	 */
50
+	public function handle(CommandInterface $command)
51
+	{
52
+		return $this->copy_registration_service->copyPaymentDetails(
53
+			$command->targetRegistration(),
54
+			$command->registrationToCopy()
55
+		);
56
+	}
57 57
 }
Please login to merge, or discard this patch.
commands/registration/CancelRegistrationAndTicketLineItemCommandHandler.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -28,43 +28,43 @@
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    /**
32
-     * @var CancelTicketLineItemService $cancel_ticket_line_item_service
33
-     */
34
-    private $cancel_ticket_line_item_service;
31
+	/**
32
+	 * @var CancelTicketLineItemService $cancel_ticket_line_item_service
33
+	 */
34
+	private $cancel_ticket_line_item_service;
35 35
 
36 36
 
37
-    /**
38
-     * Command constructor
39
-     *
40
-     * @param CancelTicketLineItemService $cancel_ticket_line_item_service
41
-     */
42
-    public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
43
-    {
44
-        $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
45
-    }
37
+	/**
38
+	 * Command constructor
39
+	 *
40
+	 * @param CancelTicketLineItemService $cancel_ticket_line_item_service
41
+	 */
42
+	public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
43
+	{
44
+		$this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * @param CommandInterface|CancelRegistrationAndTicketLineItemCommand $command
50
-     * @return boolean
51
-     * @throws DomainException
52
-     * @throws EE_Error
53
-     * @throws EntityNotFoundException
54
-     * @throws InvalidDataTypeException
55
-     * @throws InvalidInterfaceException
56
-     * @throws UnexpectedEntityException
57
-     * @throws InvalidArgumentException
58
-     * @throws ReflectionException
59
-     * @throws RuntimeException
60
-     */
61
-    public function handle(CommandInterface $command)
62
-    {
63
-        $registration = $command->registration();
64
-        $this->cancel_ticket_line_item_service->forRegistration($registration);
65
-        // cancel original registration
66
-        $registration->set_status(EEM_Registration::status_id_cancelled);
67
-        $registration->save();
68
-        return true;
69
-    }
48
+	/**
49
+	 * @param CommandInterface|CancelRegistrationAndTicketLineItemCommand $command
50
+	 * @return boolean
51
+	 * @throws DomainException
52
+	 * @throws EE_Error
53
+	 * @throws EntityNotFoundException
54
+	 * @throws InvalidDataTypeException
55
+	 * @throws InvalidInterfaceException
56
+	 * @throws UnexpectedEntityException
57
+	 * @throws InvalidArgumentException
58
+	 * @throws ReflectionException
59
+	 * @throws RuntimeException
60
+	 */
61
+	public function handle(CommandInterface $command)
62
+	{
63
+		$registration = $command->registration();
64
+		$this->cancel_ticket_line_item_service->forRegistration($registration);
65
+		// cancel original registration
66
+		$registration->set_status(EEM_Registration::status_id_cancelled);
67
+		$registration->save();
68
+		return true;
69
+	}
70 70
 }
Please login to merge, or discard this patch.
services/commands/registration/CopyRegistrationDetailsCommandHandler.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -24,37 +24,37 @@
 block discarded – undo
24 24
 {
25 25
 
26 26
 
27
-    /**
28
-     * @var CopyRegistrationService $copy_registration_service
29
-     */
30
-    private $copy_registration_service;
31
-
32
-
33
-    /**
34
-     * Command constructor
35
-     *
36
-     * @param CopyRegistrationService $copy_registration_service
37
-     */
38
-    public function __construct(CopyRegistrationService $copy_registration_service)
39
-    {
40
-        $this->copy_registration_service = $copy_registration_service;
41
-    }
42
-
43
-
44
-    /**
45
-     * @param CommandInterface|CopyRegistrationDetailsCommand $command
46
-     * @return boolean
47
-     * @throws InvalidEntityException
48
-     * @throws EE_Error
49
-     * @throws EntityNotFoundException
50
-     * @throws UnexpectedEntityException
51
-     * @throws RuntimeException
52
-     */
53
-    public function handle(CommandInterface $command)
54
-    {
55
-        return $this->copy_registration_service->copyRegistrationDetails(
56
-            $command->targetRegistration(),
57
-            $command->registrationToCopy()
58
-        );
59
-    }
27
+	/**
28
+	 * @var CopyRegistrationService $copy_registration_service
29
+	 */
30
+	private $copy_registration_service;
31
+
32
+
33
+	/**
34
+	 * Command constructor
35
+	 *
36
+	 * @param CopyRegistrationService $copy_registration_service
37
+	 */
38
+	public function __construct(CopyRegistrationService $copy_registration_service)
39
+	{
40
+		$this->copy_registration_service = $copy_registration_service;
41
+	}
42
+
43
+
44
+	/**
45
+	 * @param CommandInterface|CopyRegistrationDetailsCommand $command
46
+	 * @return boolean
47
+	 * @throws InvalidEntityException
48
+	 * @throws EE_Error
49
+	 * @throws EntityNotFoundException
50
+	 * @throws UnexpectedEntityException
51
+	 * @throws RuntimeException
52
+	 */
53
+	public function handle(CommandInterface $command)
54
+	{
55
+		return $this->copy_registration_service->copyRegistrationDetails(
56
+			$command->targetRegistration(),
57
+			$command->registrationToCopy()
58
+		);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_List_Table.class.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         $class = parent::_get_row_class($item);
113 113
         // add status class
114 114
         $class .= $item instanceof EE_Event
115
-            ? ' ee-status-strip event-status-' . $item->get_active_status()
115
+            ? ' ee-status-strip event-status-'.$item->get_active_status()
116 116
             : '';
117 117
         if ($this->_has_checkbox_column) {
118 118
             $class .= ' has-checkbox-column';
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function column_cb($item)
143 143
     {
144
-        if (! $item instanceof EE_Event) {
144
+        if ( ! $item instanceof EE_Event) {
145 145
             return '';
146 146
         }
147 147
         $this->_dtt = $item->primary_datetime(); // set this for use in other columns
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     public function column_id(EE_Event $item)
165 165
     {
166 166
         $content = $item->ID();
167
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
167
+        $content .= '  <span class="show-on-mobile-view-only">'.$item->name().'</span>';
168 168
         return $content;
169 169
     }
170 170
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         $actions = $this->_column_name_action_setup($item);
188 188
         $status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
189 189
         $content = '<strong><a class="row-title" href="'
190
-                   . $edit_link . '">'
190
+                   . $edit_link.'">'
191 191
                    . $item->name()
192 192
                    . '</a></strong>'
193 193
                    . $status;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     protected function _column_name_action_setup(EE_Event $item)
217 217
     {
218 218
         // todo: remove when attendees is active
219
-        if (! defined('REG_ADMIN_URL')) {
219
+        if ( ! defined('REG_ADMIN_URL')) {
220 220
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
221 221
         }
222 222
         $actions = array();
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
                 'post'   => $item->ID(),
234 234
             );
235 235
             $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
236
-            $actions['edit'] = '<a href="' . $edit_link . '"'
237
-                               . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">'
236
+            $actions['edit'] = '<a href="'.$edit_link.'"'
237
+                               . ' title="'.esc_attr__('Edit Event', 'event_espresso').'">'
238 238
                                . esc_html__('Edit', 'event_espresso')
239 239
                                . '</a>';
240 240
         }
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
                 'event_id' => $item->ID(),
254 254
             );
255 255
             $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
256
-            $actions['attendees'] = '<a href="' . $attendees_link . '"'
257
-                                    . ' title="' . esc_attr__('View Registrations', 'event_espresso') . '">'
256
+            $actions['attendees'] = '<a href="'.$attendees_link.'"'
257
+                                    . ' title="'.esc_attr__('View Registrations', 'event_espresso').'">'
258 258
                                     . esc_html__('Registrations', 'event_espresso')
259 259
                                     . '</a>';
260 260
         }
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
             );
302 302
         }
303 303
         $view_link = get_permalink($item->ID());
304
-        $actions['view'] = '<a href="' . $view_link . '"'
305
-                           . ' title="' . esc_attr__('View Event', 'event_espresso') . '">'
304
+        $actions['view'] = '<a href="'.$view_link.'"'
305
+                           . ' title="'.esc_attr__('View Event', 'event_espresso').'">'
306 306
                            . esc_html__('View', 'event_espresso')
307 307
                            . '</a>';
308 308
         if ($item->get('status') === 'trash') {
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
                 'espresso_events_restore_event',
312 312
                 $item->ID()
313 313
             )) {
314
-                $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"'
315
-                                                 . ' title="' . esc_attr__('Restore from Trash', 'event_espresso')
314
+                $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'"'
315
+                                                 . ' title="'.esc_attr__('Restore from Trash', 'event_espresso')
316 316
                                                  . '">'
317 317
                                                  . esc_html__('Restore from Trash', 'event_espresso')
318 318
                                                  . '</a>';
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
                     $item->ID()
325 325
                 )
326 326
             ) {
327
-                $actions['delete'] = '<a href="' . $delete_event_link . '"'
328
-                                     . ' title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">'
327
+                $actions['delete'] = '<a href="'.$delete_event_link.'"'
328
+                                     . ' title="'.esc_attr__('Delete Permanently', 'event_espresso').'">'
329 329
                                      . esc_html__('Delete Permanently', 'event_espresso')
330 330
                                      . '</a>';
331 331
             }
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
                 'espresso_events_trash_event',
336 336
                 $item->ID()
337 337
             )) {
338
-                $actions['move to trash'] = '<a href="' . $trash_event_link . '"'
339
-                                            . ' title="' . esc_attr__('Trash Event', 'event_espresso') . '">'
338
+                $actions['move to trash'] = '<a href="'.$trash_event_link.'"'
339
+                                            . ' title="'.esc_attr__('Trash Event', 'event_espresso').'">'
340 340
                                             . esc_html__('Trash', 'event_espresso')
341 341
                                             . '</a>';
342 342
             }
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
             'EVT_wp_user' => $item->wp_user(),
362 362
         );
363 363
         $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
364
-        return $gravatar . '  <a href="' . $filter_url . '"'
365
-               . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">'
364
+        return $gravatar.'  <a href="'.$filter_url.'"'
365
+               . ' title="'.esc_attr__('Click to filter events by this author.', 'event_espresso').'">'
366 366
                . $event_author->display_name
367 367
                . '</a>';
368 368
     }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
         return implode(
380 380
             ', ',
381 381
             array_map(
382
-                function (EE_Term $category) {
382
+                function(EE_Term $category) {
383 383
                     return $category->name();
384 384
                 },
385 385
                 $event_categories
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                    'ee_read_registrations',
455 455
                    'espresso_registrations_view_registration'
456 456
                )
457
-            ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>'
457
+            ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>'
458 458
             : $registered_attendees;
459 459
     }
460 460
 
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
     public function column_actions(EE_Event $item)
485 485
     {
486 486
         // todo: remove when attendees is active
487
-        if (! defined('REG_ADMIN_URL')) {
487
+        if ( ! defined('REG_ADMIN_URL')) {
488 488
             define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
489 489
         }
490 490
         $action_links = array();
491 491
         $view_link = get_permalink($item->ID());
492
-        $action_links[] = '<a href="' . $view_link . '"'
493
-                          . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">';
492
+        $action_links[] = '<a href="'.$view_link.'"'
493
+                          . ' title="'.esc_attr__('View Event', 'event_espresso').'" target="_blank">';
494 494
         $action_links[] = '<div class="dashicons dashicons-search"></div></a>';
495 495
         if (EE_Registry::instance()->CAP->current_user_can(
496 496
             'ee_edit_event',
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
                 'post'   => $item->ID(),
503 503
             );
504 504
             $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
505
-            $action_links[] = '<a href="' . $edit_link . '"'
506
-                              . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">'
505
+            $action_links[] = '<a href="'.$edit_link.'"'
506
+                              . ' title="'.esc_attr__('Edit Event', 'event_espresso').'">'
507 507
                               . '<div class="ee-icon ee-icon-calendar-edit"></div>'
508 508
                               . '</a>';
509 509
         }
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
                 'event_id' => $item->ID(),
522 522
             );
523 523
             $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
524
-            $action_links[] = '<a href="' . $attendees_link . '"'
525
-                              . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">'
524
+            $action_links[] = '<a href="'.$attendees_link.'"'
525
+                              . ' title="'.esc_attr__('View Registrants', 'event_espresso').'">'
526 526
                               . '<div class="dashicons dashicons-groups"></div>'
527 527
                               . '</a>';
528 528
         }
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
         }
558 558
         $column_array = [];
559 559
         foreach ($this->_columns as $column => $column_label) {
560
-            $column_array[ $column ] = $column_label;
560
+            $column_array[$column] = $column_label;
561 561
             if ($column === 'venue') {
562 562
                 $column_array['event_category'] = esc_html__('Event Category', 'event_espresso');
563 563
             }
Please login to merge, or discard this patch.
Indentation   +549 added lines, -549 removed lines patch added patch discarded remove patch
@@ -15,553 +15,553 @@
 block discarded – undo
15 15
 class Events_Admin_List_Table extends EE_Admin_List_Table
16 16
 {
17 17
 
18
-    /**
19
-     * @var EE_Datetime
20
-     */
21
-    private $_dtt;
22
-
23
-
24
-    /**
25
-     * Initial setup of data properties for the list table.
26
-     */
27
-    protected function _setup_data()
28
-    {
29
-        $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page);
30
-        $this->_all_data_count = $this->_admin_page->get_events(0, 0, true);
31
-    }
32
-
33
-
34
-    /**
35
-     * Set up of additional properties for the list table.
36
-     */
37
-    protected function _set_properties()
38
-    {
39
-        $this->_wp_list_args = array(
40
-            'singular' => esc_html__('event', 'event_espresso'),
41
-            'plural'   => esc_html__('events', 'event_espresso'),
42
-            'ajax'     => true, // for now
43
-            'screen'   => $this->_admin_page->get_current_screen()->id,
44
-        );
45
-        $this->_columns = array(
46
-            'cb'              => '<input type="checkbox" />',
47
-            'id'              => esc_html__('ID', 'event_espresso'),
48
-            'name'            => esc_html__('Name', 'event_espresso'),
49
-            'author'          => esc_html__('Author', 'event_espresso'),
50
-            'venue'           => esc_html__('Venue', 'event_espresso'),
51
-            'start_date_time' => esc_html__('Event Start', 'event_espresso'),
52
-            'reg_begins'      => esc_html__('On Sale', 'event_espresso'),
53
-            'attendees'       => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">'
54
-                                 . '<span class="screen-reader-text">'
55
-                                 . esc_html__('Approved Registrations', 'event_espresso')
56
-                                 . '</span>'
57
-                                 . '</span>',
58
-            // 'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'),
59
-            'actions'         => esc_html__('Actions', 'event_espresso'),
60
-        );
61
-        $this->addConditionalColumns();
62
-        $this->_sortable_columns = array(
63
-            'id'              => array('EVT_ID' => true),
64
-            'name'            => array('EVT_name' => false),
65
-            'author'          => array('EVT_wp_user' => false),
66
-            'venue'           => array('Venue.VNU_name' => false),
67
-            'start_date_time' => array('Datetime.DTT_EVT_start' => false),
68
-            'reg_begins'      => array('Datetime.Ticket.TKT_start_date' => false),
69
-        );
70
-
71
-        $this->_primary_column = 'id';
72
-        $this->_hidden_columns = array('author', 'event_category');
73
-    }
74
-
75
-
76
-    /**
77
-     * @return array
78
-     */
79
-    protected function _get_table_filters()
80
-    {
81
-        return array(); // no filters with decaf
82
-    }
83
-
84
-
85
-    /**
86
-     * Setup of views properties.
87
-     *
88
-     * @throws InvalidDataTypeException
89
-     * @throws InvalidInterfaceException
90
-     * @throws InvalidArgumentException
91
-     */
92
-    protected function _add_view_counts()
93
-    {
94
-        $this->_views['all']['count'] = $this->_admin_page->total_events();
95
-        $this->_views['draft']['count'] = $this->_admin_page->total_events_draft();
96
-        if (EE_Registry::instance()->CAP->current_user_can(
97
-            'ee_delete_events',
98
-            'espresso_events_trash_events'
99
-        )) {
100
-            $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events();
101
-        }
102
-    }
103
-
104
-
105
-    /**
106
-     * @param EE_Event $item
107
-     * @return string
108
-     * @throws EE_Error
109
-     */
110
-    protected function _get_row_class($item)
111
-    {
112
-        $class = parent::_get_row_class($item);
113
-        // add status class
114
-        $class .= $item instanceof EE_Event
115
-            ? ' ee-status-strip event-status-' . $item->get_active_status()
116
-            : '';
117
-        if ($this->_has_checkbox_column) {
118
-            $class .= ' has-checkbox-column';
119
-        }
120
-        return $class;
121
-    }
122
-
123
-
124
-    /**
125
-     * @param EE_Event $item
126
-     * @return string
127
-     * @throws EE_Error
128
-     */
129
-    public function column_status(EE_Event $item)
130
-    {
131
-        return '<span class="ee-status-strip ee-status-strip-td event-status-'
132
-               . $item->get_active_status()
133
-               . '"></span>';
134
-    }
135
-
136
-
137
-    /**
138
-     * @param  EE_Event $item
139
-     * @return string
140
-     * @throws EE_Error
141
-     */
142
-    public function column_cb($item)
143
-    {
144
-        if (! $item instanceof EE_Event) {
145
-            return '';
146
-        }
147
-        $this->_dtt = $item->primary_datetime(); // set this for use in other columns
148
-        // does event have any attached registrations?
149
-        $regs = $item->count_related('Registration');
150
-        return $regs > 0 && $this->_view === 'trash'
151
-            ? '<span class="ee-lock-icon"></span>'
152
-            : sprintf(
153
-                '<input type="checkbox" name="EVT_IDs[]" value="%s" />',
154
-                $item->ID()
155
-            );
156
-    }
157
-
158
-
159
-    /**
160
-     * @param EE_Event $item
161
-     * @return mixed|string
162
-     * @throws EE_Error
163
-     */
164
-    public function column_id(EE_Event $item)
165
-    {
166
-        $content = $item->ID();
167
-        $content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
168
-        return $content;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param EE_Event $item
174
-     * @return string
175
-     * @throws EE_Error
176
-     * @throws InvalidArgumentException
177
-     * @throws InvalidDataTypeException
178
-     * @throws InvalidInterfaceException
179
-     */
180
-    public function column_name(EE_Event $item)
181
-    {
182
-        $edit_query_args = array(
183
-            'action' => 'edit',
184
-            'post'   => $item->ID(),
185
-        );
186
-        $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
187
-        $actions = $this->_column_name_action_setup($item);
188
-        $status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
189
-        $content = '<strong><a class="row-title" href="'
190
-                   . $edit_link . '">'
191
-                   . $item->name()
192
-                   . '</a></strong>'
193
-                   . $status;
194
-        $content .= '<br><span class="ee-status-text-small">'
195
-                    . EEH_Template::pretty_status(
196
-                        $item->get_active_status(),
197
-                        false,
198
-                        'sentence'
199
-                    )
200
-                    . '</span>';
201
-        $content .= $this->row_actions($actions);
202
-        return $content;
203
-    }
204
-
205
-
206
-    /**
207
-     * Just a method for setting up the actions for the name column
208
-     *
209
-     * @param EE_Event $item
210
-     * @return array array of actions
211
-     * @throws EE_Error
212
-     * @throws InvalidArgumentException
213
-     * @throws InvalidDataTypeException
214
-     * @throws InvalidInterfaceException
215
-     */
216
-    protected function _column_name_action_setup(EE_Event $item)
217
-    {
218
-        // todo: remove when attendees is active
219
-        if (! defined('REG_ADMIN_URL')) {
220
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
221
-        }
222
-        $actions = array();
223
-        $restore_event_link = '';
224
-        $delete_event_link = '';
225
-        $trash_event_link = '';
226
-        if (EE_Registry::instance()->CAP->current_user_can(
227
-            'ee_edit_event',
228
-            'espresso_events_edit',
229
-            $item->ID()
230
-        )) {
231
-            $edit_query_args = array(
232
-                'action' => 'edit',
233
-                'post'   => $item->ID(),
234
-            );
235
-            $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
236
-            $actions['edit'] = '<a href="' . $edit_link . '"'
237
-                               . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">'
238
-                               . esc_html__('Edit', 'event_espresso')
239
-                               . '</a>';
240
-        }
241
-        if (EE_Registry::instance()->CAP->current_user_can(
242
-            'ee_read_registrations',
243
-            'espresso_registrations_view_registration'
244
-        )
245
-            && EE_Registry::instance()->CAP->current_user_can(
246
-                'ee_read_event',
247
-                'espresso_registrations_view_registration',
248
-                $item->ID()
249
-            )
250
-        ) {
251
-            $attendees_query_args = array(
252
-                'action'   => 'default',
253
-                'event_id' => $item->ID(),
254
-            );
255
-            $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
256
-            $actions['attendees'] = '<a href="' . $attendees_link . '"'
257
-                                    . ' title="' . esc_attr__('View Registrations', 'event_espresso') . '">'
258
-                                    . esc_html__('Registrations', 'event_espresso')
259
-                                    . '</a>';
260
-        }
261
-        if (EE_Registry::instance()->CAP->current_user_can(
262
-            'ee_delete_event',
263
-            'espresso_events_trash_event',
264
-            $item->ID()
265
-        )) {
266
-            $trash_event_query_args = array(
267
-                'action' => 'trash_event',
268
-                'EVT_ID' => $item->ID(),
269
-            );
270
-            $trash_event_link = EE_Admin_Page::add_query_args_and_nonce(
271
-                $trash_event_query_args,
272
-                EVENTS_ADMIN_URL
273
-            );
274
-        }
275
-        if (EE_Registry::instance()->CAP->current_user_can(
276
-            'ee_delete_event',
277
-            'espresso_events_restore_event',
278
-            $item->ID()
279
-        )) {
280
-            $restore_event_query_args = array(
281
-                'action' => 'restore_event',
282
-                'EVT_ID' => $item->ID(),
283
-            );
284
-            $restore_event_link = EE_Admin_Page::add_query_args_and_nonce(
285
-                $restore_event_query_args,
286
-                EVENTS_ADMIN_URL
287
-            );
288
-        }
289
-        if (EE_Registry::instance()->CAP->current_user_can(
290
-            'ee_delete_event',
291
-            'espresso_events_delete_event',
292
-            $item->ID()
293
-        )) {
294
-            $delete_event_query_args = array(
295
-                'action' => 'delete_event',
296
-                'EVT_ID' => $item->ID(),
297
-            );
298
-            $delete_event_link = EE_Admin_Page::add_query_args_and_nonce(
299
-                $delete_event_query_args,
300
-                EVENTS_ADMIN_URL
301
-            );
302
-        }
303
-        $view_link = get_permalink($item->ID());
304
-        $actions['view'] = '<a href="' . $view_link . '"'
305
-                           . ' title="' . esc_attr__('View Event', 'event_espresso') . '">'
306
-                           . esc_html__('View', 'event_espresso')
307
-                           . '</a>';
308
-        if ($item->get('status') === 'trash') {
309
-            if (EE_Registry::instance()->CAP->current_user_can(
310
-                'ee_delete_event',
311
-                'espresso_events_restore_event',
312
-                $item->ID()
313
-            )) {
314
-                $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"'
315
-                                                 . ' title="' . esc_attr__('Restore from Trash', 'event_espresso')
316
-                                                 . '">'
317
-                                                 . esc_html__('Restore from Trash', 'event_espresso')
318
-                                                 . '</a>';
319
-            }
320
-            if ($item->count_related('Registration') === 0
321
-                && EE_Registry::instance()->CAP->current_user_can(
322
-                    'ee_delete_event',
323
-                    'espresso_events_delete_event',
324
-                    $item->ID()
325
-                )
326
-            ) {
327
-                $actions['delete'] = '<a href="' . $delete_event_link . '"'
328
-                                     . ' title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">'
329
-                                     . esc_html__('Delete Permanently', 'event_espresso')
330
-                                     . '</a>';
331
-            }
332
-        } else {
333
-            if (EE_Registry::instance()->CAP->current_user_can(
334
-                'ee_delete_event',
335
-                'espresso_events_trash_event',
336
-                $item->ID()
337
-            )) {
338
-                $actions['move to trash'] = '<a href="' . $trash_event_link . '"'
339
-                                            . ' title="' . esc_attr__('Trash Event', 'event_espresso') . '">'
340
-                                            . esc_html__('Trash', 'event_espresso')
341
-                                            . '</a>';
342
-            }
343
-        }
344
-        return $actions;
345
-    }
346
-
347
-
348
-    /**
349
-     * @param EE_Event $item
350
-     * @return string
351
-     * @throws EE_Error
352
-     */
353
-    public function column_author(EE_Event $item)
354
-    {
355
-        // user author info
356
-        $event_author = get_userdata($item->wp_user());
357
-        $gravatar = get_avatar($item->wp_user(), '15');
358
-        // filter link
359
-        $query_args = array(
360
-            'action'      => 'default',
361
-            'EVT_wp_user' => $item->wp_user(),
362
-        );
363
-        $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
364
-        return $gravatar . '  <a href="' . $filter_url . '"'
365
-               . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">'
366
-               . $event_author->display_name
367
-               . '</a>';
368
-    }
369
-
370
-
371
-    /**
372
-     * @param EE_Event $event
373
-     * @return string
374
-     * @throws EE_Error
375
-     */
376
-    public function column_event_category(EE_Event $event)
377
-    {
378
-        $event_categories = $event->get_all_event_categories();
379
-        return implode(
380
-            ', ',
381
-            array_map(
382
-                function (EE_Term $category) {
383
-                    return $category->name();
384
-                },
385
-                $event_categories
386
-            )
387
-        );
388
-    }
389
-
390
-
391
-    /**
392
-     * @param EE_Event $item
393
-     * @return string
394
-     * @throws EE_Error
395
-     */
396
-    public function column_venue(EE_Event $item)
397
-    {
398
-        $venue = $item->get_first_related('Venue');
399
-        return ! empty($venue)
400
-            ? $venue->name()
401
-            : '';
402
-    }
403
-
404
-
405
-    /**
406
-     * @param EE_Event $item
407
-     * @return string
408
-     * @throws EE_Error
409
-     */
410
-    public function column_start_date_time(EE_Event $item)
411
-    {
412
-        return $this->_dtt instanceof EE_Datetime
413
-            ? $this->_dtt->get_i18n_datetime('DTT_EVT_start')
414
-            : esc_html__('No Date was saved for this Event', 'event_espresso');
415
-    }
416
-
417
-
418
-    /**
419
-     * @param EE_Event $item
420
-     * @return string
421
-     * @throws EE_Error
422
-     */
423
-    public function column_reg_begins(EE_Event $item)
424
-    {
425
-        $reg_start = $item->get_ticket_with_earliest_start_time();
426
-        return $reg_start instanceof EE_Ticket
427
-            ? $reg_start->get_i18n_datetime('TKT_start_date')
428
-            : esc_html__('No Tickets have been setup for this Event', 'event_espresso');
429
-    }
430
-
431
-
432
-    /**
433
-     * @param EE_Event $item
434
-     * @return int|string
435
-     * @throws EE_Error
436
-     * @throws InvalidArgumentException
437
-     * @throws InvalidDataTypeException
438
-     * @throws InvalidInterfaceException
439
-     */
440
-    public function column_attendees(EE_Event $item)
441
-    {
442
-        $attendees_query_args = array(
443
-            'action'   => 'default',
444
-            'event_id' => $item->ID(),
445
-        );
446
-        $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
447
-        $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
448
-        return EE_Registry::instance()->CAP->current_user_can(
449
-            'ee_read_event',
450
-            'espresso_registrations_view_registration',
451
-            $item->ID()
452
-        )
453
-               && EE_Registry::instance()->CAP->current_user_can(
454
-                   'ee_read_registrations',
455
-                   'espresso_registrations_view_registration'
456
-               )
457
-            ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>'
458
-            : $registered_attendees;
459
-    }
460
-
461
-
462
-    /**
463
-     * @param EE_Event $item
464
-     * @return float
465
-     * @throws EE_Error
466
-     * @throws InvalidArgumentException
467
-     * @throws InvalidDataTypeException
468
-     * @throws InvalidInterfaceException
469
-     */
470
-    public function column_tkts_sold(EE_Event $item)
471
-    {
472
-        return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold');
473
-    }
474
-
475
-
476
-    /**
477
-     * @param EE_Event $item
478
-     * @return string
479
-     * @throws EE_Error
480
-     * @throws InvalidArgumentException
481
-     * @throws InvalidDataTypeException
482
-     * @throws InvalidInterfaceException
483
-     */
484
-    public function column_actions(EE_Event $item)
485
-    {
486
-        // todo: remove when attendees is active
487
-        if (! defined('REG_ADMIN_URL')) {
488
-            define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
489
-        }
490
-        $action_links = array();
491
-        $view_link = get_permalink($item->ID());
492
-        $action_links[] = '<a href="' . $view_link . '"'
493
-                          . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">';
494
-        $action_links[] = '<div class="dashicons dashicons-search"></div></a>';
495
-        if (EE_Registry::instance()->CAP->current_user_can(
496
-            'ee_edit_event',
497
-            'espresso_events_edit',
498
-            $item->ID()
499
-        )) {
500
-            $edit_query_args = array(
501
-                'action' => 'edit',
502
-                'post'   => $item->ID(),
503
-            );
504
-            $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
505
-            $action_links[] = '<a href="' . $edit_link . '"'
506
-                              . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">'
507
-                              . '<div class="ee-icon ee-icon-calendar-edit"></div>'
508
-                              . '</a>';
509
-        }
510
-        if (EE_Registry::instance()->CAP->current_user_can(
511
-            'ee_read_registrations',
512
-            'espresso_registrations_view_registration'
513
-        ) && EE_Registry::instance()->CAP->current_user_can(
514
-            'ee_read_event',
515
-            'espresso_registrations_view_registration',
516
-            $item->ID()
517
-        )
518
-        ) {
519
-            $attendees_query_args = array(
520
-                'action'   => 'default',
521
-                'event_id' => $item->ID(),
522
-            );
523
-            $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
524
-            $action_links[] = '<a href="' . $attendees_link . '"'
525
-                              . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">'
526
-                              . '<div class="dashicons dashicons-groups"></div>'
527
-                              . '</a>';
528
-        }
529
-        $action_links = apply_filters(
530
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
531
-            $action_links,
532
-            $item
533
-        );
534
-        return $this->_action_string(
535
-            implode("\n\t", $action_links),
536
-            $item,
537
-            'div'
538
-        );
539
-    }
540
-
541
-
542
-    /**
543
-     * Helper for adding columns conditionally
544
-     *
545
-     * @throws EE_Error
546
-     * @throws InvalidArgumentException
547
-     * @throws InvalidDataTypeException
548
-     * @throws InvalidInterfaceException
549
-     */
550
-    private function addConditionalColumns()
551
-    {
552
-        $event_category_count = EEM_Term::instance()->count(
553
-            [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]]
554
-        );
555
-        if ($event_category_count === 0) {
556
-            return;
557
-        }
558
-        $column_array = [];
559
-        foreach ($this->_columns as $column => $column_label) {
560
-            $column_array[ $column ] = $column_label;
561
-            if ($column === 'venue') {
562
-                $column_array['event_category'] = esc_html__('Event Category', 'event_espresso');
563
-            }
564
-        }
565
-        $this->_columns = $column_array;
566
-    }
18
+	/**
19
+	 * @var EE_Datetime
20
+	 */
21
+	private $_dtt;
22
+
23
+
24
+	/**
25
+	 * Initial setup of data properties for the list table.
26
+	 */
27
+	protected function _setup_data()
28
+	{
29
+		$this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page);
30
+		$this->_all_data_count = $this->_admin_page->get_events(0, 0, true);
31
+	}
32
+
33
+
34
+	/**
35
+	 * Set up of additional properties for the list table.
36
+	 */
37
+	protected function _set_properties()
38
+	{
39
+		$this->_wp_list_args = array(
40
+			'singular' => esc_html__('event', 'event_espresso'),
41
+			'plural'   => esc_html__('events', 'event_espresso'),
42
+			'ajax'     => true, // for now
43
+			'screen'   => $this->_admin_page->get_current_screen()->id,
44
+		);
45
+		$this->_columns = array(
46
+			'cb'              => '<input type="checkbox" />',
47
+			'id'              => esc_html__('ID', 'event_espresso'),
48
+			'name'            => esc_html__('Name', 'event_espresso'),
49
+			'author'          => esc_html__('Author', 'event_espresso'),
50
+			'venue'           => esc_html__('Venue', 'event_espresso'),
51
+			'start_date_time' => esc_html__('Event Start', 'event_espresso'),
52
+			'reg_begins'      => esc_html__('On Sale', 'event_espresso'),
53
+			'attendees'       => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">'
54
+								 . '<span class="screen-reader-text">'
55
+								 . esc_html__('Approved Registrations', 'event_espresso')
56
+								 . '</span>'
57
+								 . '</span>',
58
+			// 'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'),
59
+			'actions'         => esc_html__('Actions', 'event_espresso'),
60
+		);
61
+		$this->addConditionalColumns();
62
+		$this->_sortable_columns = array(
63
+			'id'              => array('EVT_ID' => true),
64
+			'name'            => array('EVT_name' => false),
65
+			'author'          => array('EVT_wp_user' => false),
66
+			'venue'           => array('Venue.VNU_name' => false),
67
+			'start_date_time' => array('Datetime.DTT_EVT_start' => false),
68
+			'reg_begins'      => array('Datetime.Ticket.TKT_start_date' => false),
69
+		);
70
+
71
+		$this->_primary_column = 'id';
72
+		$this->_hidden_columns = array('author', 'event_category');
73
+	}
74
+
75
+
76
+	/**
77
+	 * @return array
78
+	 */
79
+	protected function _get_table_filters()
80
+	{
81
+		return array(); // no filters with decaf
82
+	}
83
+
84
+
85
+	/**
86
+	 * Setup of views properties.
87
+	 *
88
+	 * @throws InvalidDataTypeException
89
+	 * @throws InvalidInterfaceException
90
+	 * @throws InvalidArgumentException
91
+	 */
92
+	protected function _add_view_counts()
93
+	{
94
+		$this->_views['all']['count'] = $this->_admin_page->total_events();
95
+		$this->_views['draft']['count'] = $this->_admin_page->total_events_draft();
96
+		if (EE_Registry::instance()->CAP->current_user_can(
97
+			'ee_delete_events',
98
+			'espresso_events_trash_events'
99
+		)) {
100
+			$this->_views['trash']['count'] = $this->_admin_page->total_trashed_events();
101
+		}
102
+	}
103
+
104
+
105
+	/**
106
+	 * @param EE_Event $item
107
+	 * @return string
108
+	 * @throws EE_Error
109
+	 */
110
+	protected function _get_row_class($item)
111
+	{
112
+		$class = parent::_get_row_class($item);
113
+		// add status class
114
+		$class .= $item instanceof EE_Event
115
+			? ' ee-status-strip event-status-' . $item->get_active_status()
116
+			: '';
117
+		if ($this->_has_checkbox_column) {
118
+			$class .= ' has-checkbox-column';
119
+		}
120
+		return $class;
121
+	}
122
+
123
+
124
+	/**
125
+	 * @param EE_Event $item
126
+	 * @return string
127
+	 * @throws EE_Error
128
+	 */
129
+	public function column_status(EE_Event $item)
130
+	{
131
+		return '<span class="ee-status-strip ee-status-strip-td event-status-'
132
+			   . $item->get_active_status()
133
+			   . '"></span>';
134
+	}
135
+
136
+
137
+	/**
138
+	 * @param  EE_Event $item
139
+	 * @return string
140
+	 * @throws EE_Error
141
+	 */
142
+	public function column_cb($item)
143
+	{
144
+		if (! $item instanceof EE_Event) {
145
+			return '';
146
+		}
147
+		$this->_dtt = $item->primary_datetime(); // set this for use in other columns
148
+		// does event have any attached registrations?
149
+		$regs = $item->count_related('Registration');
150
+		return $regs > 0 && $this->_view === 'trash'
151
+			? '<span class="ee-lock-icon"></span>'
152
+			: sprintf(
153
+				'<input type="checkbox" name="EVT_IDs[]" value="%s" />',
154
+				$item->ID()
155
+			);
156
+	}
157
+
158
+
159
+	/**
160
+	 * @param EE_Event $item
161
+	 * @return mixed|string
162
+	 * @throws EE_Error
163
+	 */
164
+	public function column_id(EE_Event $item)
165
+	{
166
+		$content = $item->ID();
167
+		$content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
168
+		return $content;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param EE_Event $item
174
+	 * @return string
175
+	 * @throws EE_Error
176
+	 * @throws InvalidArgumentException
177
+	 * @throws InvalidDataTypeException
178
+	 * @throws InvalidInterfaceException
179
+	 */
180
+	public function column_name(EE_Event $item)
181
+	{
182
+		$edit_query_args = array(
183
+			'action' => 'edit',
184
+			'post'   => $item->ID(),
185
+		);
186
+		$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
187
+		$actions = $this->_column_name_action_setup($item);
188
+		$status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
189
+		$content = '<strong><a class="row-title" href="'
190
+				   . $edit_link . '">'
191
+				   . $item->name()
192
+				   . '</a></strong>'
193
+				   . $status;
194
+		$content .= '<br><span class="ee-status-text-small">'
195
+					. EEH_Template::pretty_status(
196
+						$item->get_active_status(),
197
+						false,
198
+						'sentence'
199
+					)
200
+					. '</span>';
201
+		$content .= $this->row_actions($actions);
202
+		return $content;
203
+	}
204
+
205
+
206
+	/**
207
+	 * Just a method for setting up the actions for the name column
208
+	 *
209
+	 * @param EE_Event $item
210
+	 * @return array array of actions
211
+	 * @throws EE_Error
212
+	 * @throws InvalidArgumentException
213
+	 * @throws InvalidDataTypeException
214
+	 * @throws InvalidInterfaceException
215
+	 */
216
+	protected function _column_name_action_setup(EE_Event $item)
217
+	{
218
+		// todo: remove when attendees is active
219
+		if (! defined('REG_ADMIN_URL')) {
220
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
221
+		}
222
+		$actions = array();
223
+		$restore_event_link = '';
224
+		$delete_event_link = '';
225
+		$trash_event_link = '';
226
+		if (EE_Registry::instance()->CAP->current_user_can(
227
+			'ee_edit_event',
228
+			'espresso_events_edit',
229
+			$item->ID()
230
+		)) {
231
+			$edit_query_args = array(
232
+				'action' => 'edit',
233
+				'post'   => $item->ID(),
234
+			);
235
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
236
+			$actions['edit'] = '<a href="' . $edit_link . '"'
237
+							   . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">'
238
+							   . esc_html__('Edit', 'event_espresso')
239
+							   . '</a>';
240
+		}
241
+		if (EE_Registry::instance()->CAP->current_user_can(
242
+			'ee_read_registrations',
243
+			'espresso_registrations_view_registration'
244
+		)
245
+			&& EE_Registry::instance()->CAP->current_user_can(
246
+				'ee_read_event',
247
+				'espresso_registrations_view_registration',
248
+				$item->ID()
249
+			)
250
+		) {
251
+			$attendees_query_args = array(
252
+				'action'   => 'default',
253
+				'event_id' => $item->ID(),
254
+			);
255
+			$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
256
+			$actions['attendees'] = '<a href="' . $attendees_link . '"'
257
+									. ' title="' . esc_attr__('View Registrations', 'event_espresso') . '">'
258
+									. esc_html__('Registrations', 'event_espresso')
259
+									. '</a>';
260
+		}
261
+		if (EE_Registry::instance()->CAP->current_user_can(
262
+			'ee_delete_event',
263
+			'espresso_events_trash_event',
264
+			$item->ID()
265
+		)) {
266
+			$trash_event_query_args = array(
267
+				'action' => 'trash_event',
268
+				'EVT_ID' => $item->ID(),
269
+			);
270
+			$trash_event_link = EE_Admin_Page::add_query_args_and_nonce(
271
+				$trash_event_query_args,
272
+				EVENTS_ADMIN_URL
273
+			);
274
+		}
275
+		if (EE_Registry::instance()->CAP->current_user_can(
276
+			'ee_delete_event',
277
+			'espresso_events_restore_event',
278
+			$item->ID()
279
+		)) {
280
+			$restore_event_query_args = array(
281
+				'action' => 'restore_event',
282
+				'EVT_ID' => $item->ID(),
283
+			);
284
+			$restore_event_link = EE_Admin_Page::add_query_args_and_nonce(
285
+				$restore_event_query_args,
286
+				EVENTS_ADMIN_URL
287
+			);
288
+		}
289
+		if (EE_Registry::instance()->CAP->current_user_can(
290
+			'ee_delete_event',
291
+			'espresso_events_delete_event',
292
+			$item->ID()
293
+		)) {
294
+			$delete_event_query_args = array(
295
+				'action' => 'delete_event',
296
+				'EVT_ID' => $item->ID(),
297
+			);
298
+			$delete_event_link = EE_Admin_Page::add_query_args_and_nonce(
299
+				$delete_event_query_args,
300
+				EVENTS_ADMIN_URL
301
+			);
302
+		}
303
+		$view_link = get_permalink($item->ID());
304
+		$actions['view'] = '<a href="' . $view_link . '"'
305
+						   . ' title="' . esc_attr__('View Event', 'event_espresso') . '">'
306
+						   . esc_html__('View', 'event_espresso')
307
+						   . '</a>';
308
+		if ($item->get('status') === 'trash') {
309
+			if (EE_Registry::instance()->CAP->current_user_can(
310
+				'ee_delete_event',
311
+				'espresso_events_restore_event',
312
+				$item->ID()
313
+			)) {
314
+				$actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"'
315
+												 . ' title="' . esc_attr__('Restore from Trash', 'event_espresso')
316
+												 . '">'
317
+												 . esc_html__('Restore from Trash', 'event_espresso')
318
+												 . '</a>';
319
+			}
320
+			if ($item->count_related('Registration') === 0
321
+				&& EE_Registry::instance()->CAP->current_user_can(
322
+					'ee_delete_event',
323
+					'espresso_events_delete_event',
324
+					$item->ID()
325
+				)
326
+			) {
327
+				$actions['delete'] = '<a href="' . $delete_event_link . '"'
328
+									 . ' title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">'
329
+									 . esc_html__('Delete Permanently', 'event_espresso')
330
+									 . '</a>';
331
+			}
332
+		} else {
333
+			if (EE_Registry::instance()->CAP->current_user_can(
334
+				'ee_delete_event',
335
+				'espresso_events_trash_event',
336
+				$item->ID()
337
+			)) {
338
+				$actions['move to trash'] = '<a href="' . $trash_event_link . '"'
339
+											. ' title="' . esc_attr__('Trash Event', 'event_espresso') . '">'
340
+											. esc_html__('Trash', 'event_espresso')
341
+											. '</a>';
342
+			}
343
+		}
344
+		return $actions;
345
+	}
346
+
347
+
348
+	/**
349
+	 * @param EE_Event $item
350
+	 * @return string
351
+	 * @throws EE_Error
352
+	 */
353
+	public function column_author(EE_Event $item)
354
+	{
355
+		// user author info
356
+		$event_author = get_userdata($item->wp_user());
357
+		$gravatar = get_avatar($item->wp_user(), '15');
358
+		// filter link
359
+		$query_args = array(
360
+			'action'      => 'default',
361
+			'EVT_wp_user' => $item->wp_user(),
362
+		);
363
+		$filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
364
+		return $gravatar . '  <a href="' . $filter_url . '"'
365
+			   . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">'
366
+			   . $event_author->display_name
367
+			   . '</a>';
368
+	}
369
+
370
+
371
+	/**
372
+	 * @param EE_Event $event
373
+	 * @return string
374
+	 * @throws EE_Error
375
+	 */
376
+	public function column_event_category(EE_Event $event)
377
+	{
378
+		$event_categories = $event->get_all_event_categories();
379
+		return implode(
380
+			', ',
381
+			array_map(
382
+				function (EE_Term $category) {
383
+					return $category->name();
384
+				},
385
+				$event_categories
386
+			)
387
+		);
388
+	}
389
+
390
+
391
+	/**
392
+	 * @param EE_Event $item
393
+	 * @return string
394
+	 * @throws EE_Error
395
+	 */
396
+	public function column_venue(EE_Event $item)
397
+	{
398
+		$venue = $item->get_first_related('Venue');
399
+		return ! empty($venue)
400
+			? $venue->name()
401
+			: '';
402
+	}
403
+
404
+
405
+	/**
406
+	 * @param EE_Event $item
407
+	 * @return string
408
+	 * @throws EE_Error
409
+	 */
410
+	public function column_start_date_time(EE_Event $item)
411
+	{
412
+		return $this->_dtt instanceof EE_Datetime
413
+			? $this->_dtt->get_i18n_datetime('DTT_EVT_start')
414
+			: esc_html__('No Date was saved for this Event', 'event_espresso');
415
+	}
416
+
417
+
418
+	/**
419
+	 * @param EE_Event $item
420
+	 * @return string
421
+	 * @throws EE_Error
422
+	 */
423
+	public function column_reg_begins(EE_Event $item)
424
+	{
425
+		$reg_start = $item->get_ticket_with_earliest_start_time();
426
+		return $reg_start instanceof EE_Ticket
427
+			? $reg_start->get_i18n_datetime('TKT_start_date')
428
+			: esc_html__('No Tickets have been setup for this Event', 'event_espresso');
429
+	}
430
+
431
+
432
+	/**
433
+	 * @param EE_Event $item
434
+	 * @return int|string
435
+	 * @throws EE_Error
436
+	 * @throws InvalidArgumentException
437
+	 * @throws InvalidDataTypeException
438
+	 * @throws InvalidInterfaceException
439
+	 */
440
+	public function column_attendees(EE_Event $item)
441
+	{
442
+		$attendees_query_args = array(
443
+			'action'   => 'default',
444
+			'event_id' => $item->ID(),
445
+		);
446
+		$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
447
+		$registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
448
+		return EE_Registry::instance()->CAP->current_user_can(
449
+			'ee_read_event',
450
+			'espresso_registrations_view_registration',
451
+			$item->ID()
452
+		)
453
+			   && EE_Registry::instance()->CAP->current_user_can(
454
+				   'ee_read_registrations',
455
+				   'espresso_registrations_view_registration'
456
+			   )
457
+			? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>'
458
+			: $registered_attendees;
459
+	}
460
+
461
+
462
+	/**
463
+	 * @param EE_Event $item
464
+	 * @return float
465
+	 * @throws EE_Error
466
+	 * @throws InvalidArgumentException
467
+	 * @throws InvalidDataTypeException
468
+	 * @throws InvalidInterfaceException
469
+	 */
470
+	public function column_tkts_sold(EE_Event $item)
471
+	{
472
+		return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold');
473
+	}
474
+
475
+
476
+	/**
477
+	 * @param EE_Event $item
478
+	 * @return string
479
+	 * @throws EE_Error
480
+	 * @throws InvalidArgumentException
481
+	 * @throws InvalidDataTypeException
482
+	 * @throws InvalidInterfaceException
483
+	 */
484
+	public function column_actions(EE_Event $item)
485
+	{
486
+		// todo: remove when attendees is active
487
+		if (! defined('REG_ADMIN_URL')) {
488
+			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
489
+		}
490
+		$action_links = array();
491
+		$view_link = get_permalink($item->ID());
492
+		$action_links[] = '<a href="' . $view_link . '"'
493
+						  . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">';
494
+		$action_links[] = '<div class="dashicons dashicons-search"></div></a>';
495
+		if (EE_Registry::instance()->CAP->current_user_can(
496
+			'ee_edit_event',
497
+			'espresso_events_edit',
498
+			$item->ID()
499
+		)) {
500
+			$edit_query_args = array(
501
+				'action' => 'edit',
502
+				'post'   => $item->ID(),
503
+			);
504
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
505
+			$action_links[] = '<a href="' . $edit_link . '"'
506
+							  . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">'
507
+							  . '<div class="ee-icon ee-icon-calendar-edit"></div>'
508
+							  . '</a>';
509
+		}
510
+		if (EE_Registry::instance()->CAP->current_user_can(
511
+			'ee_read_registrations',
512
+			'espresso_registrations_view_registration'
513
+		) && EE_Registry::instance()->CAP->current_user_can(
514
+			'ee_read_event',
515
+			'espresso_registrations_view_registration',
516
+			$item->ID()
517
+		)
518
+		) {
519
+			$attendees_query_args = array(
520
+				'action'   => 'default',
521
+				'event_id' => $item->ID(),
522
+			);
523
+			$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
524
+			$action_links[] = '<a href="' . $attendees_link . '"'
525
+							  . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">'
526
+							  . '<div class="dashicons dashicons-groups"></div>'
527
+							  . '</a>';
528
+		}
529
+		$action_links = apply_filters(
530
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
531
+			$action_links,
532
+			$item
533
+		);
534
+		return $this->_action_string(
535
+			implode("\n\t", $action_links),
536
+			$item,
537
+			'div'
538
+		);
539
+	}
540
+
541
+
542
+	/**
543
+	 * Helper for adding columns conditionally
544
+	 *
545
+	 * @throws EE_Error
546
+	 * @throws InvalidArgumentException
547
+	 * @throws InvalidDataTypeException
548
+	 * @throws InvalidInterfaceException
549
+	 */
550
+	private function addConditionalColumns()
551
+	{
552
+		$event_category_count = EEM_Term::instance()->count(
553
+			[['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]]
554
+		);
555
+		if ($event_category_count === 0) {
556
+			return;
557
+		}
558
+		$column_array = [];
559
+		foreach ($this->_columns as $column => $column_label) {
560
+			$column_array[ $column ] = $column_label;
561
+			if ($column === 'venue') {
562
+				$column_array['event_category'] = esc_html__('Event Category', 'event_espresso');
563
+			}
564
+		}
565
+		$this->_columns = $column_array;
566
+	}
567 567
 }
Please login to merge, or discard this patch.
core/services/commands/CommandHandlerManager.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -18,83 +18,83 @@  discard block
 block discarded – undo
18 18
 class CommandHandlerManager implements CommandHandlerManagerInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var CommandHandlerInterface[] $command_handlers
23
-     */
24
-    protected $command_handlers;
21
+	/**
22
+	 * @var CommandHandlerInterface[] $command_handlers
23
+	 */
24
+	protected $command_handlers;
25 25
 
26
-    /**
27
-     * @type LoaderInterface $loader
28
-     */
29
-    private $loader;
26
+	/**
27
+	 * @type LoaderInterface $loader
28
+	 */
29
+	private $loader;
30 30
 
31 31
 
32
-    /**
33
-     * CommandHandlerManager constructor
34
-     *
35
-     * @param LoaderInterface $loader
36
-     */
37
-    public function __construct(LoaderInterface $loader)
38
-    {
39
-        $this->loader = $loader;
40
-    }
32
+	/**
33
+	 * CommandHandlerManager constructor
34
+	 *
35
+	 * @param LoaderInterface $loader
36
+	 */
37
+	public function __construct(LoaderInterface $loader)
38
+	{
39
+		$this->loader = $loader;
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * By default, Commands and CommandHandlers would normally
45
-     * reside in the same folder under the same namespace,
46
-     * and the names of the two classes would only differ in that
47
-     * one ends in "Command" and the other ends in "CommandHandler".
48
-     * However, if you wanted to utilize a CommandHandler from somewhere else,
49
-     * then this method allows you to add that CommandHandler and specify the FQCN
50
-     * (Fully Qualified ClassName) for the Command class that it should be used for.
51
-     * For example:
52
-     *      by default the "Vendor\some\namespace\DoSomethingCommand"
53
-     *      would resolve to using "Vendor\some\namespace\DoSomethingCommandHandler"
54
-     *      but if you wanted to instead process that commend using:
55
-     *      "Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler"
56
-     *      then the following code:
57
-     *      $CommandHandlerManager = $this->loader->getShared( 'CommandHandlerManagerInterface' );
58
-     *      $CommandHandlerManager->addCommandHandler(
59
-     *          new Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler(),
60
-     *          'Vendor\some\namespace\DoSomethingCommand'
61
-     *      );
62
-     *      would result in the alternate CommandHandler being used to process that Command
63
-     *
64
-     * !!! IMPORTANT !!!
65
-     * If overriding the default CommandHandler for a Command,
66
-     * be sure to also override CommandHandler::verify(),
67
-     * or else an Exception will be thrown when the CommandBus
68
-     * attempts to verify that the incoming Command matches the Handler
69
-     *
70
-     * @param CommandHandlerInterface $command_handler
71
-     * @param string                  $fqcn_for_command Fully Qualified ClassName for Command
72
-     * @return void
73
-     * @throws InvalidCommandHandlerException
74
-     */
75
-    public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = '')
76
-    {
77
-        $command = ! empty($fqcn_for_command)
78
-            ? $fqcn_for_command
79
-            : str_replace('CommandHandler', 'Command', get_class($command_handler));
80
-        if (empty($command)) {
81
-            throw new InvalidCommandHandlerException($command);
82
-        }
83
-        $this->command_handlers[ $command ] = $command_handler;
84
-    }
43
+	/**
44
+	 * By default, Commands and CommandHandlers would normally
45
+	 * reside in the same folder under the same namespace,
46
+	 * and the names of the two classes would only differ in that
47
+	 * one ends in "Command" and the other ends in "CommandHandler".
48
+	 * However, if you wanted to utilize a CommandHandler from somewhere else,
49
+	 * then this method allows you to add that CommandHandler and specify the FQCN
50
+	 * (Fully Qualified ClassName) for the Command class that it should be used for.
51
+	 * For example:
52
+	 *      by default the "Vendor\some\namespace\DoSomethingCommand"
53
+	 *      would resolve to using "Vendor\some\namespace\DoSomethingCommandHandler"
54
+	 *      but if you wanted to instead process that commend using:
55
+	 *      "Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler"
56
+	 *      then the following code:
57
+	 *      $CommandHandlerManager = $this->loader->getShared( 'CommandHandlerManagerInterface' );
58
+	 *      $CommandHandlerManager->addCommandHandler(
59
+	 *          new Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler(),
60
+	 *          'Vendor\some\namespace\DoSomethingCommand'
61
+	 *      );
62
+	 *      would result in the alternate CommandHandler being used to process that Command
63
+	 *
64
+	 * !!! IMPORTANT !!!
65
+	 * If overriding the default CommandHandler for a Command,
66
+	 * be sure to also override CommandHandler::verify(),
67
+	 * or else an Exception will be thrown when the CommandBus
68
+	 * attempts to verify that the incoming Command matches the Handler
69
+	 *
70
+	 * @param CommandHandlerInterface $command_handler
71
+	 * @param string                  $fqcn_for_command Fully Qualified ClassName for Command
72
+	 * @return void
73
+	 * @throws InvalidCommandHandlerException
74
+	 */
75
+	public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = '')
76
+	{
77
+		$command = ! empty($fqcn_for_command)
78
+			? $fqcn_for_command
79
+			: str_replace('CommandHandler', 'Command', get_class($command_handler));
80
+		if (empty($command)) {
81
+			throw new InvalidCommandHandlerException($command);
82
+		}
83
+		$this->command_handlers[ $command ] = $command_handler;
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * @param CommandInterface    $command
89
-     * @param CommandBusInterface $command_bus
90
-     * @return mixed
91
-     * @throws DomainException
92
-     * @throws CommandHandlerNotFoundException
93
-     */
94
-    public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null)
95
-    {
96
-        $command_name = get_class($command);
97
-        /*
87
+	/**
88
+	 * @param CommandInterface    $command
89
+	 * @param CommandBusInterface $command_bus
90
+	 * @return mixed
91
+	 * @throws DomainException
92
+	 * @throws CommandHandlerNotFoundException
93
+	 */
94
+	public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null)
95
+	{
96
+		$command_name = get_class($command);
97
+		/*
98 98
          * Filters the Fully Qualified Class Name for the Command Handler
99 99
          * that will be used to handle the incoming Command
100 100
          *
@@ -107,34 +107,34 @@  discard block
 block discarded – undo
107 107
          * @param string "CommandHandler::class" Fully Qualified Class Name for the Command Handler
108 108
          * @param CommandInterface $command the actual Command instance
109 109
          */
110
-        $command_handler = apply_filters(
111
-            'FHEE__EventEspresso_core_services_commands_CommandHandlerManager__getCommandHandler__command_handler',
112
-            str_replace('Command', 'CommandHandler', $command_name),
113
-            $command
114
-        );
115
-        $handler = null;
116
-        // has a command handler already been set for this class ?
117
-        // if not, can we find one via the FQCN ?
118
-        if (isset($this->command_handlers[ $command_name ])) {
119
-            $handler = $this->command_handlers[ $command_name ];
120
-        } elseif (class_exists($command_handler)) {
121
-            $handler = $this->loader->getShared($command_handler);
122
-        }
123
-        // if Handler requires an instance of the CommandBus, but that has not yet been set
124
-        if ($handler instanceof CompositeCommandHandler && ! $handler->commandBus() instanceof CommandBusInterface) {
125
-            if (! $command_bus instanceof CommandBusInterface) {
126
-                throw new DomainException(
127
-                    esc_html__(
128
-                        'CompositeCommandHandler classes require an instance of the CommandBus.',
129
-                        'event_espresso'
130
-                    )
131
-                );
132
-            }
133
-            $handler->setCommandBus($command_bus);
134
-        }
135
-        if ($handler instanceof CommandHandlerInterface) {
136
-            return $handler;
137
-        }
138
-        throw new CommandHandlerNotFoundException($command_handler);
139
-    }
110
+		$command_handler = apply_filters(
111
+			'FHEE__EventEspresso_core_services_commands_CommandHandlerManager__getCommandHandler__command_handler',
112
+			str_replace('Command', 'CommandHandler', $command_name),
113
+			$command
114
+		);
115
+		$handler = null;
116
+		// has a command handler already been set for this class ?
117
+		// if not, can we find one via the FQCN ?
118
+		if (isset($this->command_handlers[ $command_name ])) {
119
+			$handler = $this->command_handlers[ $command_name ];
120
+		} elseif (class_exists($command_handler)) {
121
+			$handler = $this->loader->getShared($command_handler);
122
+		}
123
+		// if Handler requires an instance of the CommandBus, but that has not yet been set
124
+		if ($handler instanceof CompositeCommandHandler && ! $handler->commandBus() instanceof CommandBusInterface) {
125
+			if (! $command_bus instanceof CommandBusInterface) {
126
+				throw new DomainException(
127
+					esc_html__(
128
+						'CompositeCommandHandler classes require an instance of the CommandBus.',
129
+						'event_espresso'
130
+					)
131
+				);
132
+			}
133
+			$handler->setCommandBus($command_bus);
134
+		}
135
+		if ($handler instanceof CommandHandlerInterface) {
136
+			return $handler;
137
+		}
138
+		throw new CommandHandlerNotFoundException($command_handler);
139
+	}
140 140
 }
Please login to merge, or discard this patch.