mattkirwan
12/12/2012 - 2:51 PM

ServiceProvider DB

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.
}