Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Rework the whole provider for v0.4.0 (now requires Predis v0.8).
Nothing changes for single-client configurations, but there is a BC for multiple-clients configurations since the addition of the `boot()` mechanism in Silex essentially made impossible to keep this feature alive without artificially boot()-ing the provider (which was no good). Multiple clients are now supported only when using the new `Predis\Silex\MultiPredisServiceProvider` but the way clients are configured remained the same. Clients in such configuration are accessible in the following manner: $client = $app['predis'][$alias]; It is no more possible to configure a default client responding to `$app['predis']` due to the nature of the above change.
- Loading branch information
Showing
14 changed files
with
457 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.3.0 | ||
0.4.0-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the PredisServiceProvider package. | ||
* | ||
* (c) Daniele Alessandri <suppakilla@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Predis\Silex; | ||
|
||
use Pimple; | ||
use Silex\Application; | ||
|
||
/** | ||
* Exposes multiple and separate instances of Predis\Client to Silex. | ||
* | ||
* @author Daniele Alessandri <suppakilla@gmail.com> | ||
*/ | ||
class MultiPredisServiceProvider extends PredisServiceProvider | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getProviderHandler(Application $app, $prefix) | ||
{ | ||
return $app->share(function () use ($app, $prefix) { | ||
$clients = new Pimple(); | ||
|
||
foreach ($app["$prefix.clients"] as $alias => $args) { | ||
$clients[$alias] = $clients->share(function () use ($app, $prefix, $args) { | ||
$initializer = $app["$prefix.client_initializer"]; | ||
|
||
if (!isset($args['parameters']) && !isset($args['options'])) { | ||
$args = array('parameters' => $args); | ||
} | ||
|
||
return $initializer($args); | ||
}); | ||
} | ||
|
||
return $clients; | ||
}); | ||
} | ||
|
||
public function register(Application $app) | ||
{ | ||
$app["{$this->prefix}.clients"] = array(); | ||
|
||
parent::register($app); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.