Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Redis/Connections/PredisConnection.php
Строк: 83
<?php

namespace IlluminateRedisConnections;

use 
Closure;
use 
IlluminateContractsRedisConnection as ConnectionContract;
use 
PredisCommandArgumentArrayableArgument;

/**
 * @mixin PredisClient
 */
class PredisConnection extends Connection implements ConnectionContract
{
    
/**
     * The Predis client.
     *
     * @var PredisClient
     */
    
protected $client;

    
/**
     * Create a new Predis connection.
     *
     * @param  PredisClient  $client
     * @return void
     */
    
public function __construct($client)
    {
        
$this->client $client;
    }

    
/**
     * Subscribe to a set of given channels for messages.
     *
     * @param  array|string  $channels
     * @param  Closure  $callback
     * @param  string  $method
     * @return void
     */
    
public function createSubscription($channelsClosure $callback$method 'subscribe')
    {
        
$loop $this->pubSubLoop();

        
$loop->{$method}(...array_values((array) $channels));

        foreach (
$loop as $message) {
            if (
$message->kind === 'message' || $message->kind === 'pmessage') {
                
$callback($message->payload$message->channel);
            }
        }

        unset(
$loop);
    }

    
/**
     * Parse the command's parameters for event dispatching.
     *
     * @param  array  $parameters
     * @return array
     */
    
protected function parseParametersForEvent(array $parameters)
    {
        return 
collect($parameters)
            ->
transform(function ($parameter) {
                return 
$parameter instanceof ArrayableArgument
                    
$parameter->toArray()
                    : 
$parameter;
            })->
all();
    }
}
Онлайн: 0
Реклама