private function createCategoryEntriesWithEntitlement(array $categoriesArr, $entryId, $userId) { $partnerInfo = KBatchBase::$kClient->partner->get(KBatchBase::$kClientConfig->partnerId); $clientConfig = new KalturaConfiguration($partnerInfo->id); $clientConfig->serviceUrl = KBatchBase::$kClient->getConfig()->serviceUrl; $clientConfig->setLogger($this); $client = new KalturaClient($clientConfig); foreach ($categoriesArr as $category) { /* @var $category KalturaCategory */ $ks = $client->generateSessionV2($partnerInfo->adminSecret, $userId, KalturaSessionType::ADMIN, $partnerInfo->id, 86400, 'enableentitlement,privacycontext:' . $category->privacyContexts); $client->setKs($ks); $categoryEntry = new KalturaCategoryEntry(); $categoryEntry->categoryId = $category->id; $categoryEntry->entryId = $entryId; try { $client->categoryEntry->add($categoryEntry); } catch (Exception $e) { KalturaLog::err("Could not add entry {$entryId} to category {$category->id}. Exception thrown."); } } }