|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright 2014 Underground Elephant |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + * |
| 18 | + * @package qpush-bundle |
| 19 | + * @copyright Underground Elephant 2014 |
| 20 | + * @license Apache License, Version 2.0 |
| 21 | + */ |
| 22 | + |
| 23 | +namespace Uecode\Bundle\QPushBundle\Provider; |
| 24 | + |
| 25 | +use Doctrine\Common\Cache\Cache; |
| 26 | +use Symfony\Bridge\Monolog\Logger; |
| 27 | + |
| 28 | +/** |
| 29 | + * @author Keith Kirk <kkirk@undergroundelephant.com> |
| 30 | + */ |
| 31 | +class CustomProvider extends AbstractProvider |
| 32 | +{ |
| 33 | + /** |
| 34 | + * @type ProviderInterface |
| 35 | + */ |
| 36 | + private $client; |
| 37 | + |
| 38 | + /** |
| 39 | + * @param string $name |
| 40 | + * @param array $options |
| 41 | + * @param mixed $client |
| 42 | + * @param Cache $cache |
| 43 | + * @param Logger $logger |
| 44 | + */ |
| 45 | + public function __construct($name, array $options, $client, Cache $cache, Logger $logger) |
| 46 | + { |
| 47 | + $this->name = $name; |
| 48 | + $this->options = $options; |
| 49 | + $this->cache = $cache; |
| 50 | + $this->logger = $logger; |
| 51 | + |
| 52 | + $this->setClient($client); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * @param ProviderInterface $client |
| 57 | + * |
| 58 | + * @return CustomProvider |
| 59 | + */ |
| 60 | + public function setClient(ProviderInterface $client) |
| 61 | + { |
| 62 | + $this->client = $client; |
| 63 | + |
| 64 | + return $this; |
| 65 | + } |
| 66 | + |
| 67 | + public function getProvider() |
| 68 | + { |
| 69 | + return 'Custom'; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Builds the configured queues |
| 74 | + * |
| 75 | + * If a Queue name is passed and configured, this method will build only that |
| 76 | + * Queue. |
| 77 | + * |
| 78 | + * All Create methods are idempotent, if the resource exists, the current ARN |
| 79 | + * will be returned |
| 80 | + * |
| 81 | + */ |
| 82 | + public function create() |
| 83 | + { |
| 84 | + return $this->client->create(); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * @return Boolean |
| 89 | + */ |
| 90 | + public function destroy() |
| 91 | + { |
| 92 | + return $this->client->destroy(); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * {@inheritDoc} |
| 97 | + * |
| 98 | + * This method will either use a SNS Topic to publish a queued message or |
| 99 | + * straight to SQS depending on the application configuration. |
| 100 | + * |
| 101 | + * @return string |
| 102 | + */ |
| 103 | + public function publish(array $message, array $options = []) |
| 104 | + { |
| 105 | + return $this->client->publish($message, $options); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * {@inheritDoc} |
| 110 | + */ |
| 111 | + public function receive(array $options = []) |
| 112 | + { |
| 113 | + return $this->client->receive($options); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * {@inheritDoc} |
| 118 | + * |
| 119 | + * @return bool |
| 120 | + */ |
| 121 | + public function delete($id) |
| 122 | + { |
| 123 | + return $this->client->delete($id); |
| 124 | + } |
| 125 | +} |
0 commit comments