render('calendar/user.html.twig', [ 'config' => $configuration, 'google' => $this->getGoogleSources($configuration), 'now' => $dateTime->createDateTime(), ]); } /** * @return Google */ protected function getGoogleSources(CalendarConfiguration $configuration) { $apiKey = $configuration->getGoogleApiKey() ?? null; $sources = []; foreach ($configuration->getGoogleSources() as $name => $config) { $source = new Source(); $source ->setColor($config['color']) ->setUri($config['id']) ->setId($name) ; $sources[] = $source; } return new Google($apiKey, $sources); } }