本文整理汇总了PHP中Channel::getSupplier方法的典型用法代码示例。如果您正苦于以下问题:PHP Channel::getSupplier方法的具体用法?PHP Channel::getSupplier怎么用?PHP Channel::getSupplier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::getSupplier方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadSupplier
/**
* Return the appropriate supplier (or create it if it doesn't already exist)
*
* @param Channel $chan
* @param array $updateData
* @return Supplier
* @throws CouldNotUpdate
*/
protected function loadSupplier(Channel $chan, array $updateData) : Supplier
{
// No invalid names:
$this->supplierName = \preg_replace('#[^A-Za-z0-9\\-_]#', '', $updateData['supplier']);
try {
if (!\file_exists(ROOT . '/config/supplier_keys/' . $this->supplierName . '.json')) {
throw new NoSupplier($this->supplierName);
}
return $chan->getSupplier($this->supplierName);
} catch (NoSupplier $ex) {
if ($updateData['action'] !== self::ACTION_INSERT_KEY) {
throw new CouldNotUpdate(\__('For new suppliers, we can only insert their first master key.'), 0, $ex);
}
if ($updateData['type'] !== self::KEY_TYPE_MASTER) {
throw new CouldNotUpdate(\__('Non-master key provided. It is possible that the channel is borked.'), 0, $ex);
}
// If we reach here, it's a new supplier.
$this->isNewSupplier = true;
return $chan->createSupplier($updateData);
}
}
示例2: revokeKey
/**
* We're storing a new public key for this supplier.
*
* @param Channel $chan
* @param TreeUpdate $update
* @return void
*/
protected function revokeKey(Channel $chan, TreeUpdate $update)
{
$supplier = $update->getSupplier();
$name = $supplier->getName();
$file = ROOT . '/config/supplier_keys/' . $name . '.json';
$supplierData = \Airship\loadJSON($file);
foreach ($supplierData['signing_keys'] as $id => $skey) {
if (\hash_equals($skey['public_key'], $update->getPublicKeyString())) {
// Remove this key
unset($supplierData['signing_keys'][$id]);
break;
}
}
\Airship\saveJSON($file, $supplierData);
\clearstatcache();
// Flush the channel's supplier cache
$chan->getSupplier($name, true);
}