-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 'TicketsAcceptedPrefixId` option callback
- Loading branch information
Tom Coward
committed
Jun 14, 2020
1 parent
b40139c
commit 8d5a9da
Showing
3 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace VersoBit\ResourceTickets\Option; | ||
|
||
use XF\Option\AbstractOption; | ||
|
||
class TicketsAcceptedPrefixId extends AbstractOption | ||
{ | ||
public static function renderOption(\XF\Entity\Option $option, array $htmlParams) | ||
{ | ||
// TODO: only fetch prefixes available in selected ticket category (would require options save if category is changed at same time) | ||
/** @var \NF\Tickets\Repository\TicketPrefix $prefixRepo */ | ||
$prefixRepo = \XF::repository('NF\Tickets:TicketPrefix'); | ||
$prefixes = $prefixRepo->findPrefixesForList()->fetch(); | ||
$prefixes = $prefixes->pluckNamed('title', 'prefix_id'); | ||
|
||
return self::getSelectRow($option, $htmlParams, $prefixes); | ||
} | ||
|
||
public static function verifyOption(&$value, \XF\Entity\Option $option) | ||
{ | ||
if (!$value) | ||
{ | ||
$value = null; | ||
|
||
return true; | ||
} | ||
|
||
/** @var \NF\Tickets\Entity\TicketPrefix $category */ | ||
$prefix = \XF::finder('NF\Tickets:TicketPrefix')->whereId($value)->fetchOne(); | ||
|
||
if (!$prefix) | ||
{ | ||
$option->error(\XF::phrase('vb_resourcetickets_ticket_prefix_not_found'), $option->option_id); | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters