本文整理汇总了PHP中CM_Params类的典型用法代码示例。如果您正苦于以下问题:PHP CM_Params类的具体用法?PHP CM_Params怎么用?PHP CM_Params使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CM_Params类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _execute
protected function _execute(CM_Params $params)
{
$id = $params->getInt('id');
$values = $params->getArray('values');
$svm = new CM_SVM_Model($id);
return $svm->predict($values);
}
示例2: _execute
protected function _execute(CM_Params $params)
{
$propertyId = $params->getString('propertyId');
$parameterList = $params->getArray('parameterList');
$client = new CMService_GoogleAnalytics_MeasurementProtocol_Client($propertyId);
$client->_submitHit($parameterList);
}
示例3: _execute
protected function _execute(CM_Params $params)
{
$user = $params->getUser('user');
if (null === CM_Model_StreamChannel_Message_User::findByUser($user)) {
$user->setOnline(false);
}
}
示例4: prepare
public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
{
$text = $this->getParams()->has('text') ? $renderParams->getString('text') : null;
$skipDropZone = $renderParams->getBoolean('skipDropZone', false);
$viewResponse->set('text', $text);
$viewResponse->set('skipDropZone', $skipDropZone);
}
示例5: _execute
protected function _execute(CM_Params $params)
{
$id = $params->getInt('id');
$class = $params->getInt('class');
$values = $params->getArray('values');
$svm = new CM_SVM_Model($id);
$svm->addTraining($class, $values);
}
示例6: ajax_loadComponent
public function ajax_loadComponent(CM_Params $params, CM_Frontend_JavascriptContainer_View $handler, CM_Http_Response_View_Ajax $response)
{
$className = $params->getString('className');
$params->remove('className');
if (!class_exists($className)) {
throw new CM_Exception_Invalid('Class not found', CM_Exception::WARN, ['className' => $className]);
}
return $response->loadComponent($className, $params);
}
示例7: _execute
protected function _execute(CM_Params $params)
{
$indexClassName = $params->getString('indexClassName');
$id = $params->getString('id');
/** @var CM_Elasticsearch_Type_Abstract $index */
$index = new $indexClassName();
$index->update(array($id));
$index->getIndex()->refresh();
}
示例8: ajax_flushLog
public function ajax_flushLog(CM_Params $params, CM_Frontend_JavascriptContainer $handler, CM_Http_Response_View_Ajax $response)
{
if (!$this->_getAllowedFlush($response->getRender()->getEnvironment())) {
throw new CM_Exception_NotAllowed();
}
$type = $params->getInt('type');
$logList = CM_Paging_Log_Abstract::factory($type);
$logList->flush();
$response->reloadComponent();
}
示例9: _execute
protected function _execute(CM_Params $params)
{
$code = $params->getString('code');
$identityList = $params->getArray('identityList');
$eventName = $params->getString('eventName');
$propertyList = $params->getArray('propertyList');
$kissMetrics = new CMService_KissMetrics_Client($code);
$kissMetrics->setIdentityList($identityList);
$kissMetrics->trackEvent($eventName, $propertyList);
}
示例10: _execute
protected function _execute(CM_Params $params)
{
$indexClassName = $params->getString('indexClassName');
$id = $params->getString('id');
$client = CM_Service_Manager::getInstance()->getElasticsearch()->getClient();
/** @var CM_Elasticsearch_Type_Abstract $index */
$index = new $indexClassName($client);
$index->updateDocuments(array($id));
$index->refreshIndex();
}
示例11: ajax_getSuggestionByCoordinates
public function ajax_getSuggestionByCoordinates(CM_Params $params, CM_Frontend_JavascriptContainer_View $handler, CM_Http_Response_View_Ajax $response)
{
$lat = $params->getFloat('lat');
$lon = $params->getFloat('lon');
$location = CM_Model_Location::findByCoordinates($lat, $lon);
$location = $this->_squashLocationInConstraints($location);
if (!$location) {
throw new CM_Exception('Cannot find a location by coordinates `' . $lat . '` / `' . $lon . '`.');
}
return $this->getSuggestion($location, $response->getRender());
}
示例12: prepare
public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
{
$text = $renderParams->has('text') ? $renderParams->getString('text') : null;
$buttonTheme = $this->_params->getString('buttonTheme', 'default');
$skipPreviews = $this->_params->getBoolean('skipPreviews', false);
$viewResponse->set('text', $text);
$viewResponse->set('buttonTheme', $buttonTheme);
if ($skipPreviews) {
$viewResponse->setDataAttributes(['skip-previews' => '']);
}
}
示例13: ajax_flushLog
public function ajax_flushLog(CM_Params $params, CM_Frontend_JavascriptContainer $handler, CM_Http_Response_View_Ajax $response)
{
if (!$this->_getAllowedFlush($response->getRender()->getEnvironment())) {
throw new CM_Exception_NotAllowed();
}
$level = $params->has('level') ? $params->getInt('level') : null;
$levelList = $level ? [$level] : null;
$type = $params->has('type') ? $params->getInt('type') : null;
$logList = new CM_Paging_Log($levelList, $type);
$logList->flush();
$response->reloadComponent();
}
示例14: _processView
protected function _processView(array $output)
{
$success = array();
$form = $this->_getView();
$className = get_class($form);
if (!$form instanceof CM_Form_Abstract) {
throw new CM_Exception_Invalid('`' . $className . '`is not `CM_Form_Abstract` instance');
}
$query = $this->_request->getQuery();
$actionName = (string) $query['actionName'];
$data = (array) $query['data'];
$this->_setStringRepresentation($className . '::' . $actionName);
$success['data'] = CM_Params::encode($form->process($data, $actionName, $this));
if (!empty($this->errors)) {
$success['errors'] = $this->errors;
}
$jsCode = $this->getRender()->getGlobalResponse()->getJs();
if (!empty($jsCode)) {
$success['exec'] = $jsCode;
}
if (!empty($this->messages)) {
$success['messages'] = $this->messages;
}
$output['success'] = $success;
return $output;
}
示例15: testProcessTranslationsEnableKey
public function testProcessTranslationsEnableKey()
{
$language = CMTest_TH::createLanguage('test');
$languageKey = CM_Model_LanguageKey::create('Hello World');
$this->assertSame(false, $languageKey->getJavascript());
$site = CM_Site_Abstract::factory();
$render = new CM_Frontend_Render(new CM_Frontend_Environment(null, null, $language));
// Check that key is *not* included in the JS translations list
$versionJavascript = CM_Model_Language::getVersionJavascript();
$request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
$response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$this->assertNotContains('Hello World', $response->getContent());
// Request JS-enabling of language key via RPC call
$body = CM_Params::jsonEncode(['method' => 'CM_Model_Language.requestTranslationJs', 'params' => ['Hello World']]);
$request = new CM_Http_Request_Post('/rpc', null, null, $body);
$response = CM_Http_Response_RPC::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
CMTest_TH::reinstantiateModel($languageKey);
$this->assertSame(true, $languageKey->getJavascript());
// Check that key *is* included in the JS translations list
$versionJavascript = CM_Model_Language::getVersionJavascript();
$request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
$response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$this->assertContains('Hello World', $response->getContent());
}