本文整理汇总了PHP中Summit::seedSummitTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP Summit::seedSummitTypes方法的具体用法?PHP Summit::seedSummitTypes怎么用?PHP Summit::seedSummitTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Summit
的用法示例。
在下文中一共展示了Summit::seedSummitTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleAddDefaultSummitTypes
public function handleAddDefaultSummitTypes($grid, $request, $data = null)
{
$summit_id = intval($request->param('ID'));
if ($summit_id > 0 && ($summit = Summit::get()->byID($summit_id))) {
Summit::seedSummitTypes($summit_id);
}
}
示例2: run
/**
* Implement this method in the task subclass to
* execute via the TaskRunner
*/
public function run($request)
{
set_time_limit(0);
$summit_id = intval($request->getVar('summit_id'));
if (empty($summit_id)) {
throw new InvalidArgumentException('missing summit_id param!');
}
$summit_external_id = intval($request->getVar('summit_external_id'));
if (empty($summit_external_id)) {
throw new InvalidArgumentException('missing summit_external_id param!');
}
// get ticket types ...
$summit = Summit::get()->byID($summit_id);
if (is_null($summit)) {
throw new InvalidArgumentException("non existent summit!");
}
$summit->ExternalEventId = $summit_external_id;
$summit->write();
Summit::seedBasicEventTypes($summit_id);
Summit::seedSummitTypes($summit_id);
$client = new GuzzleHttp\Client();
$query = array('token' => EVENTBRITE_PERSONAL_OAUTH2_TOKEN);
$response = $client->get(sprintf("https://www.eventbriteapi.com/v3/events/%s/ticket_classes/", $summit_external_id), array('query' => $query));
if ($response->getStatusCode() !== 200) {
throw new Exception('invalid status code!');
}
$content_type = $response->getHeader('content-type');
if (empty($content_type)) {
throw new Exception('invalid content type!');
}
if ($content_type !== 'application/json') {
throw new Exception('invalid content type!');
}
$json = $response->getBody()->getContents();
$ticket_types = json_decode($json, true);
$ticket_types = $ticket_types['ticket_classes'];
foreach ($ticket_types as $t) {
$new_ticket = new SummitTicketType();
$new_ticket->ExternalId = $t["id"];
if (SummitTicketType::get()->filter(array('SummitID' => $summit_id, 'ExternalId' => $new_ticket->ExternalId))->count() > 0) {
continue;
}
$new_ticket->Name = $t["name"];
$new_ticket->Description = $t["description"];
$new_ticket->SummitID = $summit_id;
$new_ticket->write();
}
}