本文整理匯總了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();
}
}