/** * Get service actions from hook * * @return Navigation */ protected function getServiceActions() { $navigation = new Navigation(); foreach (Hook::all('Monitoring\\ServiceActions') as $hook) { $navigation->merge($hook->getNavigation($this->object)); } return $navigation; }
/** * Get host actions from hook * * @return array */ protected function getHostActions() { $urls = array(); foreach (Hook::all('Monitoring\\HostActions') as $hook) { foreach ($hook->getActionsForHost($this->object) as $id => $url) { $urls[$id] = $url; } } return $urls; }
protected function enumSourceTypes() { $hooks = Hook::all('Director\\ImportSource'); $enum = array(); foreach ($hooks as $hook) { $enum[get_class($hook)] = $hook->getName(); } asort($enum); return $enum; }
/** * Build the tabs * */ public function build() { /** @var ConfigurationTab $configTab */ $configTab = null; foreach (Hook::all(self::HOOK_NAMESPACE) as $configTab) { if (!$configTab instanceof ConfigurationTabInterface) { throw new ProgrammingError('tab not instance of ConfigTabInterface'); } $this->getTabs()->add($configTab->getModuleName(), $configTab->getTab()); } }
protected function collectExtraFiles() { foreach (Hook::all('Director\\ShipConfigFiles') as $hook) { foreach ($hook->fetchFiles() as $filename => $file) { if (array_key_exists($filename, $this->files)) { throw new ProgrammingError('Cannot ship one file twice: %s', $filename); } if ($file instanceof IcingaConfigFile) { $this->files[$filename] = $file; } else { $this->configFile($filename, '')->setContent((string) $file); } } } return $this; }
public function testReturnsAnEmptyArrayWithNoRegisteredHook() { $this->assertEquals(array(), Hook::all('not_existing')); }
/** * Fetch all entries and forecasts by using the dataview associated with this timeline * * @return array The dataview's result */ private function fetchResults() { $hookResults = array(); foreach (Hook::all('timeline') as $timelineProvider) { $hookResults = array_merge($hookResults, $timelineProvider->fetchEntries($this->displayRange), $timelineProvider->fetchForecasts($this->forecastRange)); foreach ($timelineProvider->getIdentifiers() as $identifier => $attributes) { if (!array_key_exists($identifier, $this->identifiers)) { $this->identifiers[$identifier] = $attributes; } } } $query = $this->dataview; $filter = Filter::matchAll(Filter::where('type', array_keys($this->identifiers)), Filter::expression('timestamp', '<=', $this->displayRange->getStart()->getTimestamp()), Filter::expression('timestamp', '>', $this->displayRange->getEnd()->getTimestamp())); $query->applyFilter($filter); return array_merge($query->getQuery()->fetchAll(), $hookResults); }
protected function enumDataTypes() { $hooks = Hook::all('Director\\DataType'); $enum = array(null => '- please choose -'); foreach ($hooks as $hook) { $enum[get_class($hook)] = $hook->getName(); } return $enum; }