当前位置: 首页>>代码示例>>PHP>>正文


PHP ResponseBuilder::getResponse方法代码示例

本文整理汇总了PHP中Piwik\API\ResponseBuilder::getResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP ResponseBuilder::getResponse方法的具体用法?PHP ResponseBuilder::getResponse怎么用?PHP ResponseBuilder::getResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\API\ResponseBuilder的用法示例。


在下文中一共展示了ResponseBuilder::getResponse方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setGlobalSettings

 /**
  * Records Global settings when user submit changes
  */
 public function setGlobalSettings()
 {
     $response = new ResponseBuilder(Common::getRequestVar('format'));
     try {
         $this->checkTokenInUrl();
         $timezone = Common::getRequestVar('timezone', false);
         $excludedIps = Common::getRequestVar('excludedIps', false);
         $excludedQueryParameters = Common::getRequestVar('excludedQueryParameters', false);
         $excludedUserAgents = Common::getRequestVar('excludedUserAgents', false);
         $currency = Common::getRequestVar('currency', false);
         $searchKeywordParameters = Common::getRequestVar('searchKeywordParameters', $default = "");
         $searchCategoryParameters = Common::getRequestVar('searchCategoryParameters', $default = "");
         $enableSiteUserAgentExclude = Common::getRequestVar('enableSiteUserAgentExclude', $default = 0);
         $keepURLFragments = Common::getRequestVar('keepURLFragments', $default = 0);
         $api = API::getInstance();
         $api->setDefaultTimezone($timezone);
         $api->setDefaultCurrency($currency);
         $api->setGlobalExcludedQueryParameters($excludedQueryParameters);
         $api->setGlobalExcludedIps($excludedIps);
         $api->setGlobalExcludedUserAgents($excludedUserAgents);
         $api->setGlobalSearchParameters($searchKeywordParameters, $searchCategoryParameters);
         $api->setSiteSpecificUserAgentExcludeEnabled($enableSiteUserAgentExclude == 1);
         $api->setKeepURLFragmentsGlobal($keepURLFragments);
         $toReturn = $response->getResponse();
     } catch (Exception $e) {
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:32,代码来源:Controller.php

示例2: setGeneralSettings

 public function setGeneralSettings()
 {
     Piwik::checkUserHasSuperUserAccess();
     $response = new ResponseBuilder(Common::getRequestVar('format'));
     try {
         $this->checkTokenInUrl();
         $this->saveGeneralSettings();
         $customLogo = new CustomLogo();
         if (Common::getRequestVar('useCustomLogo', '0')) {
             $customLogo->enable();
         } else {
             $customLogo->disable();
         }
         $toReturn = $response->getResponse();
     } catch (Exception $e) {
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:19,代码来源:Controller.php

示例3: callApiAndReturnDataTable

 protected function callApiAndReturnDataTable($apiModule, $method, $request)
 {
     $class = Request::getClassNameAPI($apiModule);
     $request = $this->manipulateSubtableRequest($request);
     $request['serialize'] = 0;
     $request['expanded'] = 0;
     // don't want to run recursive filters on the subtables as they are loaded,
     // otherwise the result will be empty in places (or everywhere). instead we
     // run it on the flattened table.
     unset($request['filter_pattern_recursive']);
     $dataTable = Proxy::getInstance()->call($class, $method, $request);
     $response = new ResponseBuilder($format = 'original', $request);
     $response->disableSendHeader();
     $dataTable = $response->getResponse($dataTable);
     if (Common::getRequestVar('disable_queued_filters', 0, 'int', $request) == 0) {
         if (method_exists($dataTable, 'applyQueuedFilters')) {
             $dataTable->applyQueuedFilters();
         }
     }
     return $dataTable;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:21,代码来源:DataTableManipulator.php

示例4: recordUserSettings

 /**
  * Records settings from the "User Settings" page
  * @throws Exception
  */
 public function recordUserSettings()
 {
     $response = new ResponseBuilder(Common::getRequestVar('format'));
     try {
         $this->checkTokenInUrl();
         $defaultReport = Common::getRequestVar('defaultReport');
         $defaultDate = Common::getRequestVar('defaultDate');
         $language = Common::getRequestVar('language');
         $userLogin = Piwik::getCurrentUserLogin();
         $this->processPasswordChange($userLogin);
         LanguagesManager::setLanguageForSession($language);
         APILanguagesManager::getInstance()->setLanguageForUser($userLogin, $language);
         APIUsersManager::getInstance()->setUserPreference($userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT, $defaultReport);
         APIUsersManager::getInstance()->setUserPreference($userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE, $defaultDate);
         $toReturn = $response->getResponse();
     } catch (Exception $e) {
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:24,代码来源:Controller.php

示例5: convertDataTableToArrayAndApplyQueuedFilters

 private function convertDataTableToArrayAndApplyQueuedFilters(DataTable $table, $request)
 {
     $request['serialize'] = 0;
     $request['expanded'] = 0;
     $request['totals'] = 0;
     $request['format_metrics'] = 1;
     $request['disable_generic_filters'] = 1;
     $responseBuilder = new ResponseBuilder('php', $request);
     $rows = $responseBuilder->getResponse($table, 'MultiSites', 'getAll');
     return $rows;
 }
开发者ID:piwik,项目名称:piwik,代码行数:11,代码来源:Dashboard.php

示例6: loadDataTableFromAPI

 /**
  * @internal
  */
 protected function loadDataTableFromAPI()
 {
     if (!is_null($this->dataTable)) {
         // data table is already there
         // this happens when setDataTable has been used
         return $this->dataTable;
     }
     // we build the request (URL) to call the API
     $request = $this->buildApiRequestArray();
     $module = $this->requestConfig->getApiModuleToRequest();
     $method = $this->requestConfig->getApiMethodToRequest();
     PluginManager::getInstance()->checkIsPluginActivated($module);
     $class = ApiRequest::getClassNameAPI($module);
     $dataTable = Proxy::getInstance()->call($class, $method, $request);
     $response = new ResponseBuilder($format = 'original', $request);
     $response->disableSendHeader();
     $response->disableDataTablePostProcessor();
     $this->dataTable = $response->getResponse($dataTable, $module, $method);
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:22,代码来源:Visualization.php

示例7: process

 /**
  * Dispatches the API request to the appropriate API method and returns the result
  * after post-processing.
  *
  * Post-processing includes:
  *
  * - flattening if **flat** is 0
  * - running generic filters unless **disable_generic_filters** is set to 1
  * - URL decoding label column values
  * - running queued filters unless **disable_queued_filters** is set to 1
  * - removing columns based on the values of the **hideColumns** and **showColumns** query parameters
  * - filtering rows if the **label** query parameter is set
  * - converting the result to the appropriate format (ie, XML, JSON, etc.)
  *
  * If `'original'` is supplied for the output format, the result is returned as a PHP
  * object.
  *
  * @throws PluginDeactivatedException if the module plugin is not activated.
  * @throws Exception if the requested API method cannot be called, if required parameters for the
  *                   API method are missing or if the API method throws an exception and the **format**
  *                   query parameter is **original**.
  * @return DataTable|Map|string The data resulting from the API call.
  */
 public function process()
 {
     // read the format requested for the output data
     $outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $this->request));
     // create the response
     $response = new ResponseBuilder($outputFormat, $this->request);
     $corsHandler = new CORSHandler();
     $corsHandler->handle();
     try {
         // read parameters
         $moduleMethod = Common::getRequestVar('method', null, 'string', $this->request);
         list($module, $method) = $this->extractModuleAndMethod($moduleMethod);
         $module = $this->renameModule($module);
         if (!\Piwik\Plugin\Manager::getInstance()->isPluginActivated($module)) {
             throw new PluginDeactivatedException($module);
         }
         $apiClassName = $this->getClassNameAPI($module);
         self::reloadAuthUsingTokenAuth($this->request);
         // call the method
         $returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request);
         $toReturn = $response->getResponse($returnedValue, $module, $method);
     } catch (Exception $e) {
         Log::debug($e);
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:50,代码来源:Request.php

示例8: getLabelsFromTable

 protected function getLabelsFromTable($table)
 {
     $request = $_GET;
     $request['serialize'] = 0;
     // Apply generic filters
     $response = new ResponseBuilder($format = 'original', $request);
     $table = $response->getResponse($table);
     // If period=lastX we only keep the first resultset as we want to return a plain list
     if ($table instanceof DataTable\Map) {
         $tables = $table->getDataTables();
         $table = current($tables);
     }
     // Keep the response simple, only include keywords
     $keywords = $table->getColumn('label');
     return $keywords;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:16,代码来源:API.php

示例9: test_getResponse_shouldReturnAllOnIndexedArray_IfFilterLimitIsMinusOne

 public function test_getResponse_shouldReturnAllOnIndexedArray_IfFilterLimitIsMinusOne()
 {
     $input = range(0, 100);
     $builder = new ResponseBuilder('php', array('serialize' => 0, 'filter_limit' => -1));
     $response = $builder->getResponse($input);
     $this->assertEquals($input, $response);
 }
开发者ID:igorclark,项目名称:piwik,代码行数:7,代码来源:ResponseBuilderTest.php

示例10: convertDataTableToArrayAndApplyFilters

 private function convertDataTableToArrayAndApplyFilters(DataTable $table, $request)
 {
     $request['serialize'] = 0;
     $request['expanded'] = 1;
     $request['totals'] = 0;
     $request['format_metrics'] = 1;
     // filter_sort_column does not work correctly is a bug in MultiSites.getAll
     if (!empty($request['filter_sort_column']) && $request['filter_sort_column'] === 'nb_pageviews') {
         $request['filter_sort_column'] = 'Actions_nb_pageviews';
     } elseif (!empty($request['filter_sort_column']) && $request['filter_sort_column'] === 'revenue') {
         $request['filter_sort_column'] = 'Goal_revenue';
     }
     $responseBuilder = new ResponseBuilder('php', $request);
     $rows = $responseBuilder->getResponse($table, 'MultiSites', 'getAll');
     return $rows;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:16,代码来源:Dashboard.php

示例11: process

 /**
  * Dispatches the API request to the appropriate API method and returns the result
  * after post-processing.
  *
  * Post-processing includes:
  *
  * - flattening if **flat** is 0
  * - running generic filters unless **disable_generic_filters** is set to 1
  * - URL decoding label column values
  * - running queued filters unless **disable_queued_filters** is set to 1
  * - removing columns based on the values of the **hideColumns** and **showColumns** query parameters
  * - filtering rows if the **label** query parameter is set
  * - converting the result to the appropriate format (ie, XML, JSON, etc.)
  *
  * If `'original'` is supplied for the output format, the result is returned as a PHP
  * object.
  *
  * @throws PluginDeactivatedException if the module plugin is not activated.
  * @throws Exception if the requested API method cannot be called, if required parameters for the
  *                   API method are missing or if the API method throws an exception and the **format**
  *                   query parameter is **original**.
  * @return DataTable|Map|string The data resulting from the API call.
  */
 public function process()
 {
     // read the format requested for the output data
     $outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $this->request));
     // create the response
     $response = new ResponseBuilder($outputFormat, $this->request);
     $corsHandler = new CORSHandler();
     $corsHandler->handle();
     $tokenAuth = Common::getRequestVar('token_auth', '', 'string', $this->request);
     $shouldReloadAuth = false;
     try {
         // read parameters
         $moduleMethod = Common::getRequestVar('method', null, 'string', $this->request);
         list($module, $method) = $this->extractModuleAndMethod($moduleMethod);
         list($module, $method) = self::getRenamedModuleAndAction($module, $method);
         PluginManager::getInstance()->checkIsPluginActivated($module);
         $apiClassName = self::getClassNameAPI($module);
         if ($shouldReloadAuth = self::shouldReloadAuthUsingTokenAuth($this->request)) {
             $access = Access::getInstance();
             $tokenAuthToRestore = $access->getTokenAuth();
             $hadSuperUserAccess = $access->hasSuperUserAccess();
             self::forceReloadAuthUsingTokenAuth($tokenAuth);
         }
         // call the method
         $returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request);
         $toReturn = $response->getResponse($returnedValue, $module, $method);
     } catch (Exception $e) {
         Log::debug($e);
         $toReturn = $response->getResponseException($e);
     }
     if ($shouldReloadAuth) {
         $this->restoreAuthUsingTokenAuth($tokenAuthToRestore, $hadSuperUserAccess);
     }
     return $toReturn;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:58,代码来源:Request.php

示例12: setGeneralSettings

 public function setGeneralSettings()
 {
     Piwik::checkUserIsSuperUser();
     $response = new ResponseBuilder(Common::getRequestVar('format'));
     try {
         $this->checkTokenInUrl();
         $this->saveGeneralSettings();
         // update trusted host settings
         $trustedHosts = Common::getRequestVar('trustedHosts', false, 'json');
         if ($trustedHosts !== false) {
             Url::saveTrustedHostnameInConfig($trustedHosts);
         }
         // update branding settings
         $branding = Config::getInstance()->branding;
         $branding['use_custom_logo'] = Common::getRequestVar('useCustomLogo', '0');
         Config::getInstance()->branding = $branding;
         Config::getInstance()->forceSave();
         $toReturn = $response->getResponse();
     } catch (Exception $e) {
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:23,代码来源:Controller.php

示例13: test_getResponse_shouldBeAbleToApplyColumFilterAndLimitFilterOnIndexedAssociativeArray

 public function test_getResponse_shouldBeAbleToApplyColumFilterAndLimitFilterOnIndexedAssociativeArray()
 {
     $input = array();
     for ($i = 0; $i < 10; $i++) {
         $input[] = array('test' => 'two' . $i, 'test2' => 'three');
     }
     $limit = 3;
     $builder = new ResponseBuilder('php', array('serialize' => 0, 'filter_limit' => $limit, 'filter_offset' => 3, 'showColumns' => 'test'));
     $response = $builder->getResponse($input);
     $this->assertEquals(array(0 => array('test' => 'two3'), 1 => array('test' => 'two4'), 2 => array('test' => 'two5')), $response);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:ResponseBuilderTest.php

示例14: setMailSettings

 public function setMailSettings()
 {
     Piwik::checkUserHasSuperUserAccess();
     if (!self::isGeneralSettingsAdminEnabled()) {
         // General settings + Beta channel + SMTP settings is disabled
         return '';
     }
     $response = new ResponseBuilder('json');
     try {
         $this->checkTokenInUrl();
         // Update email settings
         $mail = array();
         $mail['transport'] = Common::getRequestVar('mailUseSmtp') == '1' ? 'smtp' : '';
         $mail['port'] = Common::getRequestVar('mailPort', '');
         $mail['host'] = Common::unsanitizeInputValue(Common::getRequestVar('mailHost', ''));
         $mail['type'] = Common::getRequestVar('mailType', '');
         $mail['username'] = Common::unsanitizeInputValue(Common::getRequestVar('mailUsername', ''));
         $mail['password'] = Common::unsanitizeInputValue(Common::getRequestVar('mailPassword', ''));
         $mail['encryption'] = Common::getRequestVar('mailEncryption', '');
         Config::getInstance()->mail = $mail;
         Config::getInstance()->forceSave();
         $toReturn = $response->getResponse();
     } catch (Exception $e) {
         $toReturn = $response->getResponseException($e);
     }
     return $toReturn;
 }
开发者ID:piwik,项目名称:piwik,代码行数:27,代码来源:Controller.php


注:本文中的Piwik\API\ResponseBuilder::getResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。