Skip to content

Instantly share code, notes, and snippets.

@davedevelopment
Forked from mattkirwan/ServiceProviderDB.php
Created December 12, 2012 15:58
Show Gist options
  • Save davedevelopment/4268955 to your computer and use it in GitHub Desktop.
Save davedevelopment/4268955 to your computer and use it in GitHub Desktop.
<?php
// Service Provider
$app->register(new Via\Content\ContentServiceProvider());
// Route
$app->get('/{id}', function($id) use ($app) {
return $app['content.id_checker']->check($id);
});
// and in .... ContentServiceProvider
public function register(Application $app)
{
$app['content.id_checker'] = $app->share(function () use ($app) {
return new IdChecker($app['db']);
});
};
// IdChecker() instantiates...method check($id)
public function check($id)
{
// Check against $db and return boolean.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment