Skip to content

Instantly share code, notes, and snippets.

@dragoonis
Last active December 10, 2015 20:58
Show Gist options
  • Save dragoonis/4491612 to your computer and use it in GitHub Desktop.
Save dragoonis/4491612 to your computer and use it in GitHub Desktop.
<?php
public function getServiceConfig()
{
return array('factories' => array(
// Create a service named foursquare.handler and map it to this lazy-loaded closure
// this is called from the controller. The code in this function is not called until a
// getService() call from a controller happens or if another service invokes it.
'foursquare.handler' => function($sm) {
// Construct the Api Handler and cache objects
$handler = new \FoursquareModule\Classes\ApiHandler();
$cache = new \Doctrine\Common\Cache\ApcCache();
// Pull the config data from the service manager ($sm)
$config = $sm->get('config');
// Call the setters on the ApiHandler, passing in its dependencies
$handler->setSecret($config['foursquare']['secret']);
$handler->setKey($config['foursquare']['key']);
$handler->setCache($cache);
return $handler;
}
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment