rootDir = $kernelRootDir; } public function getGlobals() { return array( 'random_header' => $this->randomHeader(), ); } private function randomHeader() { $dh = opendir($this->rootDir . '/../web/bundles/gergelypolonkaifront/images'); $files = array(); while ($fn = readdir($dh)) { if (preg_match('/^header_\d+\.png/', $fn)) { $files[] = $fn; } } return $files[array_rand($files)]; } public function getName() { return 'random_header'; } }