Skip to content

Instantly share code, notes, and snippets.

@mattkirwan
Created December 12, 2012 14:51
Show Gist options
  • Save mattkirwan/4268336 to your computer and use it in GitHub Desktop.
Save mattkirwan/4268336 to your computer and use it in GitHub Desktop.
ServiceProvider DB
<?php
// Service Provider
$app->register(new Via\Content\ContentServiceProvider());
// Route
$app->get('/{id}', function(Doctrine\DBAL\Connection $db) use ($app) {
return $app['content.id_checker']($db);
});
// and in .... ContentServiceProvider
public function register(Application $app)
{
$app['content.id_checker'] = $app->protect(function ($db) use ($app) {
return new IdChecker($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