/** * Route controller entry point. In routing.yml can define how Bolt can display a calendar event directly from GCalendar. * Sample definition could be: * event: * path: /event/{calname}/{eventid} * defaults: { _controller: 'Bolt\Extension\Rixbeck\Gapps\Controller\FrontController::event', template: 'calendareventrecord.twig' } * * @param Request $request * @param \Silex\Application $app * @param string $calname Name of calendar in config.yml * @param string $eventid Id of an event in calendar * @param string $template Template to be rendered */ public static function event(Request $request, \Silex\Application $app, $calname, $eventid, $template = 'calendareventrecord.twig') { /* @var $service \Bolt\Extension\Rixbeck\Gapps\Service\CalendarService */ $service = $app[Extension::getProviderId('calendar')][$calname]; $service->initialize(); $event = $service->getEvent($eventid); $app['twig']->addGlobal('event', $event); $app['twig']->addGlobal('calendar', $calname); return $app['twig']->render($template); }
public function initialize() { // $this->initializeDefaultOptions(); if (!$this->service) { $this->account = $this->app[Extension::getProviderId('accounts')][$this->accountName]; $cred = $this->account->createCredentialsFor($this->serviceName); $client = $this->account->authenticate($cred); $this->createService($client); } return $this->service; }
public function register(Application $app) { $self = $this; $app[Extension::getProviderId($this->sectionId)] = $app->share(function ($app) use($self) { $config = $app[Extension::CONTAINER_ID]->getConfig($self->sectionId, '.'); // @todo Exception if $config == false $names = array_keys($config); $services = new Application(); foreach ($names as $name) { $services[$name] = $app->share(function ($sapp) use($app, $name) { $class = $this->className; $service = new $class($app, $name); return $service; }); } return $services; }); }
public function getService($serviceName) { $service = $this->app[Extension::getProviderId('directory.groups')][$serviceName]; $service->initialize(); return $service; }
public function getService($calendarName) { $service = $this->app[Extension::getProviderId('calendar')][$calendarName]; $service->initialize(); return $service; }