本文整理汇总了PHP中Illuminate\Support\Arr::pull方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::pull方法的具体用法?PHP Arr::pull怎么用?PHP Arr::pull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Arr
的用法示例。
在下文中一共展示了Arr::pull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceNamedParameters
/**
* Replace all of the named parameters in the path.
*
* @param string $path
* @param array $parameters
*
* @return string
*/
protected function replaceNamedParameters($path, &$parameters)
{
$this->ensureTenancyInParameters($path, $parameters);
return preg_replace_callback('/\\{(.*?)\\??\\}/', function ($m) use(&$parameters) {
return isset($parameters[$m[1]]) ? Arr::pull($parameters, $m[1]) : $m[0];
}, $path);
}
示例2: __construct
/**
* 根据配置文件初始化client
* @param array $servers
* @param int $timeOut
* @return void
*/
public function __construct(array $servers = [], $timeOut = 5)
{
$cluster = Arr::pull($servers, 'cluster');
$options = (array) Arr::pull($servers, 'options');
$this->timeOut = Arr::pull($servers, 'timeout');
$this->clients = $this->createClients($servers, $options);
}
示例3: createClusters
/**
* Create multiple clusters (aggregate clients).
*
* @param array $clusters
* @param array $options
* @return void
*/
protected function createClusters(array $clusters, array $options = [])
{
$options = array_merge($options, (array) Arr::pull($clusters, 'options'));
foreach ($clusters as $name => $servers) {
$this->clients += $this->createAggregateClient($name, $servers, array_merge($options, (array) Arr::pull($servers, 'options')));
}
}
示例4: __construct
/**
* 根据配置文件初始化client
*
* @param array $servers
* @return void
*/
public function __construct(array $servers = [], $timeOut = 5)
{
$cluster = Arr::pull($servers, 'cluster');
$options = (array) Arr::pull($servers, 'options');
$this->clients = $this->createClients($servers, $options);
$this->timeOut = $timeOut;
$this->curConnection = $this->clients['default'];
}
示例5: broadcast
/**
* Broadcast the given event.
*
* @param array $channels
* @param string $event
* @param array $payload
* @return void
*/
public function broadcast(array $channels, $event, array $payload = [])
{
$socket = Arr::pull($payload, 'socket');
$payload = ['event' => $event, 'data' => $payload, 'socket' => $socket];
foreach ($this->formatChannels($channels) as $channel) {
LaravooleFacade::task(['channel' => $channel, 'payload' => $payload]);
}
}
示例6: getAccessTokenResponse
/**
* {@inheritdoc}
*/
public function getAccessTokenResponse($code)
{
$postKey = version_compare(ClientInterface::VERSION, '6') === 1 ? 'form_params' : 'body';
$response = $this->getHttpClient()->post($this->getTokenUrl(), [$postKey => $this->getTokenFields($code)]);
$data = [];
parse_str($response->getBody(), $data);
return Arr::add($data, 'expires_in', Arr::pull($data, 'expires'));
}
示例7: broadcast
/**
* Broadcast the given event.
*
* @param array $channels
* @param string $event
* @param array $payload
* @return void
*/
public function broadcast(array $channels, $event, array $payload = [])
{
$socket = Arr::pull($payload, 'socket');
$response = $this->pusher->trigger($this->formatChannels($channels), $event, $payload, $socket);
if (is_array($response) && $response['status'] >= 200 && $response['status'] <= 299 || $response === true) {
return;
}
throw new BroadcastException(is_bool($response) ? 'Failed to connect to Pusher.' : $response['body']);
}
示例8: createDriver
/**
* Create a new driver instance.
*
* @param string $driver
*
* @return \Orchestra\Tenanti\Migrator\FactoryInterface
*
* @throws \InvalidArgumentException
*/
protected function createDriver($driver)
{
$config = Arr::pull($this->config, "drivers.{$driver}");
$chunk = Arr::pull($this->config, 'chunk', 100);
if (is_null($config)) {
throw new InvalidArgumentException("Driver [{$driver}] not supported.");
}
return $this->app->make($this->resolver, [$this->app, $driver, $config, $chunk]);
}
示例9: broadcast
/**
* Broadcast the given event.
*
* @param array $channels
* @param string $event
* @param array $payload
* @return void
*/
public function broadcast(array $channels, $event, array $payload = [])
{
$connection = $this->redis->connection($this->connection);
$socket = Arr::pull($payload, 'socket');
$payload = json_encode(['event' => $event, 'data' => $payload, 'socket' => $socket]);
foreach ($this->formatChannels($channels) as $channel) {
$connection->publish($channel, $payload);
}
}
示例10: __construct
/**
* Create a new Redis connection instance.
*
* @param array $servers
* @return void
*/
public function __construct(array $servers = [])
{
$cluster = Arr::pull($servers, 'cluster');
$options = array_merge(['timeout' => 10.0], (array) Arr::pull($servers, 'options'));
if ($cluster) {
$this->clients = $this->createAggregateClient($servers, $options);
} else {
$this->clients = $this->createSingleClients($servers, $options);
}
}
示例11: __construct
/**
* Create a new Redis connection instance.
*
* @param array $servers
* @return void
*/
public function __construct(array $servers = [])
{
$cluster = Arr::pull($servers, 'cluster');
if ($cluster) {
$options = (array) Arr::pull($servers['clusterConfig'], 'options');
$this->clients = $this->createAggregateClient($servers['clusterConfig'], $options);
} else {
$options = (array) Arr::pull($servers, 'options');
$this->clients = $this->createSingleClients($servers, $options);
}
}
示例12: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('redis', function ($app) {
$servers = $app['config']['database.redis'];
$client = Arr::pull($servers, 'client', 'predis');
if ($client === 'phpredis') {
return new PhpRedisDatabase($servers);
} else {
return new PredisDatabase($servers);
}
});
}
示例13: createSingleClients
/**
* Create an array of single connection or sentinel clients
*
* @param array $servers
* @param array $options
* @return array
*/
protected function createSingleClients(array $servers, array $options = [])
{
$clients = [];
foreach ($servers as $key => $server) {
$options = array_merge($options, Arr::pull($server, 'options'));
$clients[$key] = new Client($server, $options);
if (isset($options['update_sentinels']) && boolval($options['update_sentinels']) === true) {
$clients[$key]->getConnection()->setUpdateSentinels(true);
}
}
return $clients;
}
示例14: all
public static function all($params = [])
{
$metadata = [];
$response = static::requestToArray('GET', null, $params);
if (Arr::has($response, 'metadata')) {
$metadata = Arr::pull($response, 'metadata');
$response = Arr::pull($response, 'data');
}
// Create collection of current class
$collection = Collection::makeOf(static::class, $response);
// Set metada property to main object
foreach ($metadata as $key => $value) {
$collection->{$key} = $value;
}
return $collection;
}
示例15: getModels
/**
* Get the hydrated models without eager loading.
*
* @param array $columns
*
* @return \Illuminate\Database\Eloquent\Model[]
*/
public function getModels($columns = ['*'])
{
$results = $this->query->get($columns);
$connection = $this->model->getConnectionName();
// Check for joined relations
if (!empty($this->joined)) {
foreach ($results as $key => $result) {
$relation_values = [];
foreach ($result as $column => $value) {
Arr::set($relation_values, $column, $value);
}
foreach ($this->joined as $relationName) {
$relation = $this->getRelation($relationName);
$relation_values[$relationName] = $relation->getRelated()->newFromBuilder(Arr::pull($relation_values, $relationName), $connection);
}
$results[$key] = $relation_values;
}
}
return $this->model->hydrate($results, $connection)->all();
}