本文整理汇总了PHP中DreamFactory\Library\Utility\ArrayUtils::has方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::has方法的具体用法?PHP ArrayUtils::has怎么用?PHP ArrayUtils::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DreamFactory\Library\Utility\ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils::has方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publish
/**
* @param string $request
* @param string|null $resource_type
* @param string|null $resource_id
*
* @return array
* @throws BadRequestException
* @throws InternalServerErrorException
* @throws NotFoundException
* @throws null
*/
public function publish($request, $resource_type = null, $resource_id = null)
{
/** http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Sns.SnsClient.html#_publish */
$data = [];
if (is_array($request)) {
if (null !== ($message = ArrayUtils::get($request, 'Message'))) {
$data = array_merge($data, $request);
if (is_array($message)) {
$data['Message'] = json_encode($message);
if (!ArrayUtils::has($request, 'MessageStructure')) {
$data['MessageStructure'] = 'json';
}
}
} else {
// This array is the message
$data['Message'] = json_encode($request);
$data['MessageStructure'] = 'json';
}
} else {
// This string is the message
$data['Message'] = $request;
}
switch ($resource_type) {
case SnsTopic::RESOURCE_NAME:
$data['TopicArn'] = $this->addArnPrefix($resource_id);
break;
case SnsEndpoint::RESOURCE_NAME:
$data['TargetArn'] = $this->addArnPrefix($resource_id);
break;
default:
// Must contain resource, either Topic or Endpoint ARN
$topic = ArrayUtils::get($data, 'Topic', ArrayUtils::get($data, 'TopicArn'));
$endpoint = ArrayUtils::get($data, 'Endpoint', ArrayUtils::get($data, 'EndpointArn', ArrayUtils::get($data, 'TargetArn')));
if (!empty($topic)) {
$data['TopicArn'] = $this->addArnPrefix($topic);
} elseif (!empty($endpoint)) {
$data['TargetArn'] = $this->addArnPrefix($endpoint);
} else {
throw new BadRequestException("Publish request does not contain resource, either 'Topic' or 'Endpoint'.");
}
break;
}
try {
if (null !== ($result = $this->conn->publish($data))) {
$id = ArrayUtils::get($result->toArray(), 'MessageId', '');
return ['MessageId' => $id];
}
} catch (\Exception $ex) {
if (null !== ($newEx = static::translateException($ex))) {
throw $newEx;
}
throw new InternalServerErrorException("Failed to push message.\n{$ex->getMessage()}", $ex->getCode());
}
return [];
}