Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function later($delay, $job, $data = '', string $queue = null)
 {
     $payload = $this->createPayload($job, $data);
     $delay = $this->getSeconds($delay);
     $this->redis->zadd($this->getQueue($queue) . ':delayed', $this->getTime() + $delay, $payload);
     return Arr::get(json_decode($payload, true), 'id');
 }
Ejemplo n.º 2
0
 /**
  * Get the cache configuration.
  *
  * @param string $name
  *
  * @throws \InvalidArgumentException
  *
  * @return array
  */
 protected function getCacheConfig(string $name) : array
 {
     $cache = $this->config->get($this->getConfigName() . '.cached');
     if (!is_array($config = Arr::get($cache, $name)) && !$config) {
         throw new InvalidArgumentException(sprintf('Cache [%s] not configured.', $name));
     }
     $config['name'] = $name;
     return $config;
 }
Ejemplo n.º 3
0
 /**
  * Get a fresh Guzzle HTTP client instance.
  *
  * @param array $config
  *
  * @return \GuzzleHttp\Client
  */
 protected function getHttpClient(array $config) : HttpClient
 {
     $guzzleConfig = Arr::get($config, 'guzzle', []);
     return new HttpClient(Arr::add($guzzleConfig, 'connect_timeout', 90));
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function getJobId() : string
 {
     return Arr::get($this->decoded, 'id');
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function shared(string $key, $default = null)
 {
     return Arr::get($this->shared, $key, $default);
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function get(string $name, $default = null)
 {
     return Arr::get($this->values, $name, $default);
 }
Ejemplo n.º 7
0
 /**
  * Parse the given view name or array.
  *
  * @param string|array $view
  *
  * @throws \InvalidArgumentException
  *
  * @return array
  */
 protected function parseView($view)
 {
     if (is_string($view)) {
         return [$view, null, null];
     }
     // If the given view is an array with numeric keys, we will just assume that
     // both a "pretty" and "plain" view were provided, so we will return this
     // array as is, since must should contain both views with numeric keys.
     if (is_array($view) && isset($view[0])) {
         return [$view[0], $view[1], null];
         // If the view is an array, but doesn't contain numeric keys, we will assume
         // the the views are being explicitly specified and will extract them via
         // named keys instead, allowing the developers to use one or the other.
     } elseif (is_array($view)) {
         return [Arr::get($view, 'html'), Arr::get($view, 'text'), Arr::get($view, 'raw')];
     }
     throw new InvalidArgumentException('Invalid view.');
 }
Ejemplo n.º 8
0
 /**
  * Filter directory contents by type.
  *
  * @param array  $contents
  * @param string $type
  *
  * @return array
  */
 private function filterContentsByType(array $contents, string $type) : array
 {
     $return = [];
     foreach ($contents as $key => $value) {
         if (Arr::get($contents, $key) === $value) {
             if (isset($value['path'])) {
                 $return[$key] = $value['path'];
             }
         }
     }
     return array_values($return);
 }
Ejemplo n.º 9
0
 /**
  * Create Redis connection.
  *
  * @return \Viserio\Queue\Connectors\RedisQueue
  */
 protected function createRedisConnection(array $config) : RedisQueue
 {
     $connect = new ConnectManager($this->config);
     $queue = new RedisQueue($connect->connection($config['connection']), $config['queue'], Arr::get($config, 'expire', 90));
     return $queue;
 }
Ejemplo n.º 10
0
 /**
  * Get a value from a nested array based on a separated key.
  *
  * @param string $key
  *
  * @return mixed
  */
 public function offsetGet($key)
 {
     return Arr::get($this->data, $key);
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function resolveName() : string
 {
     $name = $this->getName();
     $payload = json_decode($this->getRawBody(), true);
     if ($name === sprintf('%s@call', CallQueuedHandler::class)) {
         return Arr::get($payload, 'data.commandName', $name);
     }
     return $name;
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 protected function getClient(array $auth)
 {
     $client = new Rackspace($auth['endpoint'], ['username' => $auth['username'], 'apiKey' => $auth['apiKey']]);
     $urlType = Arr::get($auth, 'internal', false) ? 'internalURL' : 'publicURL';
     return $client->objectStoreService('cloudFiles', $auth['region'], $urlType)->getContainer($auth['container']);
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function getParameter(string $name, $default = null)
 {
     return Arr::get($this->parameters, $name, $default);
 }