public function getBaseQuery() { $ds = new ArrayDatasource($this->connection()->fetchImportedRowsetRows($this->checksum, null)); return $ds->select()->order('object_name'); // TODO: Remove? -> return $this->connection()->createImportedRowsetRowsQuery($this->checksum)->order('object_name'); }
/** * Create a state summary of all hosts that can be consumed by hostsummary.phtml * * @return SimpleQuery */ public function getHostStateSummary() { if (!$this->hostStateSummary) { $this->initStateSummaries(); } $ds = new ArrayDatasource(array((object) $this->hostStateSummary)); return $ds->select(); }
/** * Show the current user a list of his/her navigation items */ public function indexAction() { $user = $this->Auth()->getUser(); $ds = new ArrayDatasource(array_merge(Config::app('navigation')->select()->where('owner', $user->getUsername())->fetchAll(), iterator_to_array($user->loadNavigationConfig()))); $ds->setKeyColumn('name'); $query = $ds->select(); $this->view->types = $this->listItemTypes(); $this->view->items = $query; $this->getTabs()->add('navigation', array('title' => $this->translate('List and configure your own navigation items'), 'label' => $this->translate('Navigation'), 'url' => 'navigation'))->activate('navigation'); $this->setupSortControl(array('type' => $this->translate('Type'), 'owner' => $this->translate('Shared'), 'name' => $this->translate('Shared Navigation')), $query); }
/** * Create a state summary of all hosts that can be consumed by hostssummary.phtml * * @return SimpleQuery */ public function getStateSummary() { $hostStates = array_fill_keys(self::getHostStatesSummaryEmpty(), 0); foreach ($this as $host) { $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; $stateName = 'hosts_' . $host::getStateText($host->state); ++$hostStates[$stateName]; ++$hostStates[$stateName . ($unhandled ? '_unhandled' : '_handled')]; } $hostStates['hosts_total'] = count($this); $ds = new ArrayDatasource(array((object) $hostStates)); return $ds->select(); }
/** * Create a new config * * @param array $data The data to initialize the new config with */ public function __construct(array $data = array()) { // Convert all embedded arrays to ConfigObjects as well foreach ($data as &$value) { if (is_array($value)) { $value = new static($value); } } parent::__construct($data); }
/** * List all shared navigation items */ public function sharedAction() { $this->assertPermission('config/application/navigation'); $ds = new ArrayDatasource($this->fetchSharedNavigationItemConfigs()); $query = $ds->select(); $removeForm = new Form(); $removeForm->setUidDisabled(); $removeForm->addElement('hidden', 'name', array('decorators' => array('ViewHelper'))); $removeForm->addElement('hidden', 'redirect', array('value' => Url::fromPath('navigation/shared'), 'decorators' => array('ViewHelper'))); $removeForm->addElement('button', 'btn_submit', array('escape' => false, 'type' => 'submit', 'class' => 'link-button spinner', 'value' => 'btn_submit', 'decorators' => array('ViewHelper'), 'label' => $this->view->icon('trash'), 'title' => $this->translate('Unshare this navigation item'))); $this->view->removeForm = $removeForm; $this->view->types = $this->listItemTypes(); $this->view->items = $query; $this->getTabs()->add('navigation/shared', array('title' => $this->translate('List and configure shared navigation items'), 'label' => $this->translate('Shared Navigation'), 'url' => 'navigation/shared'))->activate('navigation/shared'); $this->setupSortControl(array('type' => $this->translate('Type'), 'owner' => $this->translate('Owner'), 'name' => $this->translate('Shared Navigation')), $query); }
public function testWhetherValidCsvIsRendered() { $data = new ArrayDatasource(array(array('col1' => 'val1', 'col2' => 'val2', 'col3' => 'val3', 'col4' => 'val4'), array('col1' => 'val5', 'col2' => 'val6', 'col3' => 'val7', 'col4' => 'val8'))); $csv = Csv::fromQuery($data->select()); $this->assertEquals(implode("\r\n", array('col1,col2,col3,col4', '"val1","val2","val3","val4"', '"val5","val6","val7","val8"')) . "\r\n", (string) $csv, 'Csv does not render valid/correct csv structured data'); }
/** * Query interface for the module manager * * @return SimpleQuery */ public function select() { $source = new ArrayDatasource($this->getModuleInfo()); return $source->select(); }
public function testSelectFactory() { $ds = new ArrayDatasource($this->sampleData); $query = $ds->select(); $this->assertInstanceOf('Icinga\\Data\\SimpleQuery', $query); }
public function getBaseQuery() { $ds = new ArrayDatasource($this->sourceHook()->fetchData()); return $ds->select(); }