本文整理汇总了PHP中Icinga\Web\Url::fromRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::fromRequest方法的具体用法?PHP Url::fromRequest怎么用?PHP Url::fromRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Web\Url
的用法示例。
在下文中一共展示了Url::fromRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preDispatch
/**
* Use a default redirection rule to welcome page
*/
public function preDispatch()
{
if ($this->getRequest()->getActionName() !== 'welcome') {
// @TODO(el): Avoid landing page redirects: https://dev.icinga.org/issues/9656
$this->redirectNow(Url::fromRequest()->setPath('dashboard'));
}
}
示例2: historyAction
/**
* @deprecated
*/
public function historyAction()
{
if ($this->params->has('service')) {
$this->redirectNow(Url::fromRequest()->setPath('monitoring/service/history'));
}
$this->redirectNow(Url::fromRequest()->setPath('monitoring/host/history'));
}
示例3: getUrl
/**
* Get the request URL
*
* @return Url
*/
public function getUrl()
{
if ($this->url === null) {
$this->url = Url::fromRequest($this);
}
return $this->url;
}
示例4: indexAction
public function indexAction()
{
$this->getTabs()->add('tactical_overview', array('title' => $this->translate('Show an overview of all hosts and services, their current' . ' states and monitoring feature utilisation'), 'label' => $this->translate('Tactical Overview'), 'url' => Url::fromRequest()))->extend(new DashboardAction())->activate('tactical_overview');
$stats = $this->backend->select()->from('statussummary', array('hosts_up', 'hosts_pending', 'hosts_down', 'hosts_down_unhandled', 'hosts_unreachable', 'hosts_unreachable_unhandled', 'services_ok_on_ok_hosts', 'services_ok_not_checked_on_ok_hosts', 'services_pending_on_ok_hosts', 'services_pending_not_checked_on_ok_hosts', 'services_warning_handled_on_ok_hosts', 'services_warning_unhandled_on_ok_hosts', 'services_warning_passive_on_ok_hosts', 'services_warning_not_checked_on_ok_hosts', 'services_critical_handled_on_ok_hosts', 'services_critical_unhandled_on_ok_hosts', 'services_critical_passive_on_ok_hosts', 'services_critical_not_checked_on_ok_hosts', 'services_unknown_handled_on_ok_hosts', 'services_unknown_unhandled_on_ok_hosts', 'services_unknown_passive_on_ok_hosts', 'services_unknown_not_checked_on_ok_hosts', 'services_ok_on_problem_hosts', 'services_ok_not_checked_on_problem_hosts', 'services_pending_on_problem_hosts', 'services_pending_not_checked_on_problem_hosts', 'services_warning_handled_on_problem_hosts', 'services_warning_unhandled_on_problem_hosts', 'services_warning_passive_on_problem_hosts', 'services_warning_not_checked_on_problem_hosts', 'services_critical_handled_on_problem_hosts', 'services_critical_unhandled_on_problem_hosts', 'services_critical_passive_on_problem_hosts', 'services_critical_not_checked_on_problem_hosts', 'services_unknown_handled_on_problem_hosts', 'services_unknown_unhandled_on_problem_hosts', 'services_unknown_passive_on_problem_hosts', 'services_unknown_not_checked_on_problem_hosts', 'hosts_active', 'hosts_passive', 'hosts_not_checked', 'services_active', 'services_passive', 'services_not_checked', 'hosts_not_processing_event_handlers', 'services_not_processing_event_handlers', 'hosts_not_triggering_notifications', 'services_not_triggering_notifications', 'hosts_without_flap_detection', 'services_without_flap_detection', 'hosts_flapping', 'services_flapping'));
$this->applyRestriction('monitoring/filter/objects', $stats);
$this->view->statusSummary = $stats->fetchRow();
}
示例5: editAction
/**
* Edit an user group backend
*/
public function editAction()
{
$backendName = $this->params->getRequired('backend');
$form = new UserGroupBackendForm();
$form->setAction(Url::fromRequest());
$form->setRedirectUrl('usergroupbackend/list');
$form->setTitle(sprintf($this->translate('Edit User Group Backend %s'), $backendName));
$form->setIniConfig(Config::app('groups'));
$form->setOnSuccess(function (UserGroupBackendForm $form) use($backendName) {
try {
$form->edit($backendName, array_map(function ($v) {
return $v !== '' ? $v : null;
}, $form->getValues()));
} catch (Exception $e) {
$form->error($e->getMessage());
return false;
}
if ($form->save()) {
Notification::success(sprintf(t('User group backend "%s" successfully updated'), $backendName));
return true;
}
return false;
});
try {
$form->load($backendName);
$form->handleRequest();
} catch (NotFoundError $_) {
$this->httpNotFound(sprintf($this->translate('User group backend "%s" not found'), $backendName));
}
$this->view->form = $form;
$this->render('form');
}
示例6: showAction
public function showAction()
{
$this->setAutorefreshInterval(15);
$checkNowForm = new CheckNowCommandForm();
$checkNowForm->setObjects($this->serviceList)->handleRequest();
$this->view->checkNowForm = $checkNowForm;
$this->serviceList->setColumns(array('host_icon_image', 'host_icon_image_alt', 'host_name', 'host_address', 'host_output', 'host_state', 'host_problem', 'host_handled', 'service_icon_image', 'service_icon_image_alt', 'service_output', 'service_description', 'service_state', 'service_problem', 'service_handled', 'service_acknowledged', 'service_in_downtime', 'service_is_flapping', 'service_notifications_enabled', 'service_active_checks_enabled', 'service_passive_checks_enabled'));
$acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
if (!empty($acknowledgedObjects)) {
$removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
$this->view->removeAckForm = $removeAckForm;
}
$this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/services/process-check-result');
$this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/services/add-comment');
$this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/services/delete-comment');
$this->view->stats = $this->serviceList->getServiceStateSummary();
$this->view->objects = $this->serviceList;
$this->view->unhandledObjects = $this->serviceList->getUnhandledObjects();
$this->view->problemObjects = $this->serviceList->getProblemObjects();
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeLink = Url::fromPath('monitoring/services/schedule-downtime')->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString());
$this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->acknowledgeLink = Url::fromPath('monitoring/services/acknowledge-problem')->setQueryString($this->serviceList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
$this->view->unacknowledgedObjects = $this->serviceList->getUnacknowledgedObjects();
$this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime();
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/services')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString());
$this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show')->setQueryString($this->serviceList->getObjectsInDowntime()->objectsFilter()->toQueryString());
$this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
$this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/services/send-custom-notification');
}
示例7: __construct
/**
* The constructor starts benchmarking, loads the configuration and sets
* other useful controller properties
*
* @param Request $request
* @param Response $response
* @param array $invokeArgs Any additional invocation arguments
*/
public function __construct(Request $request, Response $response, array $invokeArgs = array())
{
$this->params = UrlParams::fromQueryString();
$this->setRequest($request)->setResponse($response)->_setInvokeArgs($invokeArgs);
$this->_helper = new ActionHelperBroker($this);
$this->handlerBrowserWindows();
$this->view->translationDomain = 'icinga';
$this->_helper->layout()->isIframe = $request->getUrl()->shift('isIframe');
$this->_helper->layout()->showFullscreen = $request->getUrl()->shift('showFullscreen');
$this->_helper->layout()->moduleName = false;
$this->view->compact = $request->getParam('view') === 'compact';
if ($request->getUrl()->shift('showCompact')) {
$this->view->compact = true;
}
if ($this->rerenderLayout = $request->getUrl()->shift('renderLayout')) {
$this->xhrLayout = 'body';
}
if ($request->getUrl()->shift('_disableLayout')) {
$this->_helper->layout()->disableLayout();
}
if ($this->requiresLogin()) {
$this->redirectToLogin(Url::fromRequest());
}
$this->view->tabs = new Tabs();
$this->prepareInit();
$this->init();
}
示例8: indexAction
/**
* Create full report
*/
public function indexAction()
{
$this->getTabs()->add('alertsummary', array('title' => $this->translate('Show recent alerts and visualize notifications and problems' . ' based on their amount and chronological distribution'), 'label' => $this->translate('Alert Summary'), 'url' => Url::fromRequest()))->extend(new DashboardAction())->extend(new MenuAction())->activate('alertsummary');
$this->view->title = $this->translate('Alert Summary');
$this->view->intervalBox = $this->createIntervalBox();
list($recentAlerts, $recentAlertsUrl) = $this->createRecentAlerts();
$this->view->recentAlerts = $recentAlerts;
$this->view->recentAlertsUrl = $recentAlertsUrl;
$this->view->interval = $this->getInterval();
$this->view->defectChart = $this->createDefectImage();
$this->view->healingChart = $this->createHealingChart();
$this->view->perf = $this->createNotificationPerfdata();
$this->view->trend = $this->createTrendInformation();
$this->setAutorefreshInterval(15);
$query = $this->backend->select()->from('notification', array('host_name', 'host_display_name', 'service_description', 'service_display_name', 'notification_output', 'notification_contact_name', 'notification_start_time', 'notification_state'));
$this->applyRestriction('monitoring/filter/objects', $query);
$this->view->notifications = $query;
$this->view->notificationsUrl = 'monitoring/list/notifications';
$this->setupLimitControl();
if ($limit = $this->params->get('limit')) {
$query->limit($limit);
} else {
$query->limit(25);
}
}
示例9: showAction
public function showAction()
{
$this->setAutorefreshInterval(15);
$checkNowForm = new CheckNowCommandForm();
$checkNowForm->setObjects($this->hostList)->handleRequest();
$this->view->checkNowForm = $checkNowForm;
$this->hostList->setColumns(array('host_acknowledged', 'host_active_checks_enabled', 'host_display_name', 'host_handled', 'host_in_downtime', 'host_is_flapping', 'host_last_state_change', 'host_name', 'host_notifications_enabled', 'host_passive_checks_enabled', 'host_problem', 'host_state'));
$acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
if (!empty($acknowledgedObjects)) {
$removeAckForm = new RemoveAcknowledgementCommandForm();
$removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
$this->view->removeAckForm = $removeAckForm;
}
$hostStates = $this->hostList->getStateSummary();
$this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result');
$this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment');
$this->view->stats = $hostStates;
$this->view->objects = $this->hostList;
$this->view->unhandledObjects = $this->hostList->getUnhandledObjects();
$this->view->problemObjects = $this->hostList->getProblemObjects();
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
$this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getProblemObjects()->objectsFilter()->toQueryString());
$this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
$this->view->acknowledgeLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
$this->view->unacknowledgedObjects = $this->hostList->getUnacknowledgedObjects();
$this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime();
$this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts')->setQueryString($this->hostList->getObjectsInDowntime()->objectsFilter()->toQueryString());
$this->view->showDowntimesLink = Url::fromPath('monitoring/list/downtimes')->setQueryString($this->hostList->objectsFilter()->andFilter(FilterEqual::where('object_type', 'host'))->toQueryString());
$this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
$this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification');
}
示例10: render
public function render()
{
if ($this->url === null) {
$this->url = Url::fromRequest();
}
$currentLimit = (int) $this->url->getParam('limit', $this->default);
$availableLimits = array(10 => '10', 25 => '25', 50 => '50', 100 => '100', 500 => '500');
if ($currentLimit === 0) {
$availableLimits[0] = t('all');
}
// if ($this->pages === 1 && $currentLimit === 10) return '';
$limits = array();
$view = $this->view();
$gotCurrent = false;
foreach ($availableLimits as $limit => $caption) {
if ($gotCurrent) {
if ($this->pages === 1) {
// break;
}
}
if ($this->max !== null && ($limit === 0 || $limit > $this->max)) {
//echo "$limit > $this->max"; break;
}
if ($limit === $currentLimit) {
$gotCurrent = true;
$limits[] = $caption;
} else {
$limits[] = $view->qlink($caption, $this->url->setParam('limit', $limit), null, array('title' => sprintf($view->translate('Limit each page to a maximum of %u rows'), $caption)));
}
}
if (empty($limits)) {
return '';
}
return '<span class="widgetLimiter">' . implode(' ', $limits) . '</span>';
}
示例11: init
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_dashboard_addurl');
if (!$this->getSubmitLabel()) {
$this->setSubmitLabel($this->translate('Add To Dashboard'));
}
$this->setAction(Url::fromRequest());
}
示例12: getTabs
/**
* {@inheritdoc}
*/
public function getTabs()
{
if ($this->tabs === null) {
$this->tabs = new Tabs();
$this->tabs->add('search', array('title' => t('Show Search', 'dashboard.pane.tooltip'), 'label' => t('Search'), 'url' => Url::fromRequest()));
}
return $this->tabs;
}
示例13: __construct
public function __construct($options = null)
{
parent::__construct($this->handleOptions($options));
$this->setMethod('post');
$this->setAction(Url::fromRequest());
$this->createIdElement();
$this->regenerateCsrfToken();
}
示例14: menuAction
/**
* Render the menu
*/
public function menuAction()
{
$this->setAutorefreshInterval(15);
$this->_helper->layout()->disableLayout();
$url = Url::fromRequest();
$menu = new MenuRenderer(Menu::load(), $url->getRelativeUrl());
$this->view->menuRenderer = $menu->useCustomRenderer();
}
示例15: testWhetherFromRequestAcceptsAdditionalParameters
public function testWhetherFromRequestAcceptsAdditionalParameters()
{
$request = Mockery::mock('Icinga\\Web\\Request');
$request->shouldReceive('getPathInfo')->andReturn('')->shouldReceive('getBaseUrl')->andReturn('/')->shouldReceive('getQuery')->andReturn(array('key1' => 'val1'));
$url = Url::fromRequest(array('key1' => 'newval1', 'key2' => 'val2'), $request);
$this->assertEquals('val2', $url->getParam('key2', 'wrongval'), 'Url::fromRequest does not accept additional parameters');
$this->assertEquals('newval1', $url->getParam('key1', 'wrongval1'), 'Url::fromRequest does not overwrite existing parameters with additional ones');
}