本文整理汇总了PHP中CM_Params::getString方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Params::getString方法的具体用法?PHP CM_Params::getString怎么用?PHP CM_Params::getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CM_Params
的用法示例。
在下文中一共展示了CM_Params::getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
{
$viewResponse->set('class', $renderParams->has('class') ? $renderParams->getString('class') : null);
$viewResponse->set('optionList', $this->_getOptionList());
$viewResponse->set('translate', $renderParams->getBoolean('translate', $this->_translate) || $renderParams->has('translatePrefix'));
$viewResponse->set('translatePrefix', $renderParams->has('translatePrefix') ? $renderParams->getString('translatePrefix') : null);
}
示例2: prepare
public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
{
$viewResponse->set('autocorrect', $renderParams->has('autocorrect') ? $renderParams->getString('autocorrect') : null);
$viewResponse->set('autocapitalize', $renderParams->has('autocapitalize') ? $renderParams->getString('autocapitalize') : null);
$viewResponse->set('tabindex', $renderParams->has('tabindex') ? $renderParams->getInt('tabindex') : null);
$viewResponse->set('class', $renderParams->has('class') ? $renderParams->getString('class') : null);
$viewResponse->set('placeholder', $renderParams->has('placeholder') ? $renderParams->getString('placeholder') : null);
}
示例3: _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();
}
示例4: _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);
}
示例5: _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();
}
示例6: prepare
public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
{
$display = $renderParams->get('display', self::DISPLAY_CHECKBOX);
if (!in_array($display, array(self::DISPLAY_CHECKBOX, self::DISPLAY_SWITCH))) {
throw new CM_Exception_InvalidParam('Display needs to be either `checkbox` or `switch`');
}
$viewResponse->set('display', $display);
$viewResponse->set('tabindex', $renderParams->has('tabindex') ? $renderParams->getInt('tabindex') : null);
$viewResponse->set('class', $renderParams->has('class') ? $renderParams->getString('class') : null);
$viewResponse->set('checked', $this->getValue() ? 'checked' : null);
$viewResponse->set('text', $renderParams->has('text') ? $renderParams->getString('text') : null);
}
示例7: loadPage
/**
* @param CM_Params $params
* @param CM_Http_Response_View_Ajax $response
* @throws CM_Exception_Invalid
* @return array
*/
public function loadPage(CM_Params $params, CM_Http_Response_View_Ajax $response)
{
$path = $params->getString('path');
$currentLayoutClass = $params->getString('currentLayout');
$request = $this->_createGetRequestWithUrl($path);
$responseFactory = new CM_Http_ResponseFactory($this->getServiceManager());
$count = 0;
$fragments = [];
do {
$fragment = CM_Util::link($request->getPath(), $request->getQuery());
$fragments[] = $fragment;
$url = $this->getRender()->getSite()->getUrlBase() . $fragment;
if ($count++ > 10) {
throw new CM_Exception_Invalid('Page redirect loop detected (' . implode(' -> ', $fragments) . ').');
}
$responsePage = $responseFactory->getResponse($request);
if (!$responsePage->getSite()->equals($this->getSite())) {
$redirectExternalFragment = CM_Util::link($responsePage->getRequest()->getPath(), $responsePage->getRequest()->getQuery());
return array('redirectExternal' => $responsePage->getRender()->getUrl($redirectExternalFragment));
}
$responseEmbed = new CM_Http_Response_Page_Embed($responsePage->getRequest(), $responsePage->getSite(), $this->getServiceManager());
$responseEmbed->process();
$request = $responseEmbed->getRequest();
if ($redirectUrl = $responseEmbed->getRedirectUrl()) {
if (!$this->_isPageOnSameSite($redirectUrl)) {
return array('redirectExternal' => $redirectUrl);
}
}
} while ($redirectUrl);
foreach ($responseEmbed->getCookies() as $name => $cookieParameters) {
$response->setCookie($name, $cookieParameters['value'], $cookieParameters['expire'], $cookieParameters['path']);
}
$page = $responseEmbed->getPage();
$this->_setStringRepresentation(get_class($page));
$frontend = $responseEmbed->getRender()->getGlobalResponse();
$html = $responseEmbed->getContent();
$js = $frontend->getJs();
$autoId = $frontend->getTreeRoot()->getValue()->getAutoId();
$frontend->clear();
$layoutRendering = null;
$layoutClass = $page->getLayout($this->getRender()->getEnvironment());
if ($layoutClass !== $currentLayoutClass) {
$layout = new $layoutClass();
$layoutRendering = $this->_getComponentRendering($layout);
}
$title = $responseEmbed->getTitle();
$menuList = array_merge($this->getSite()->getMenus($this->getRender()->getEnvironment()), $responseEmbed->getRender()->getMenuList());
$menuEntryHashList = $this->_getMenuEntryHashList($menuList, get_class($page), $page->getParams());
$jsTracking = $responseEmbed->getRender()->getServiceManager()->getTrackings()->getJs();
return ['pageRendering' => ['js' => $js, 'html' => $html, 'autoId' => $autoId], 'layoutRendering' => $layoutRendering, 'title' => $title, 'url' => $url, 'menuEntryHashList' => $menuEntryHashList, 'jsTracking' => $jsTracking];
}
示例8: testProcessInvalidCharsRequired
public function testProcessInvalidCharsRequired()
{
$invalidChars = array(chr(192), chr(214), chr(255), chr(140));
foreach ($invalidChars as $inputChar) {
$form = new CM_Form_MockForm();
$formAction = new CM_FormAction_MockForm_TestExampleAction($form);
$data = array('must_check' => 'checked', 'text' => $inputChar);
$response = $this->getResponseFormAction($formAction, $data);
try {
$this->assertFormResponseError($response, null, 'text');
} catch (PHPUnit_Framework_AssertionFailedError $e) {
$this->assertNotSame($inputChar, self::$formActionData->getString('text'));
}
}
}
示例9: testGetString
public function testGetString()
{
$text = "Foo Bar, Bar Foo";
$notText = new stdClass();
$params = new CM_Params(array('text1' => CM_Params::encode($text), 'text2' => $text, 'text3' => $notText));
$this->assertEquals($text, $params->getString('text1'));
$this->assertEquals($text, $params->getString('text2'));
try {
$params->getString('text3');
$this->fail('invalid param. should not exist');
} catch (CM_Exception_InvalidParam $e) {
$this->assertTrue(true);
}
$this->assertEquals('foo', $params->getString('text4', 'foo'));
}
示例10: 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);
}
示例11: ajax_error
public function ajax_error(CM_Params $params, CM_Frontend_JavascriptContainer_View $handler, CM_Http_Response_View_Ajax $response)
{
$status = $params->getInt('status', 200);
$message = $params->has('text') ? $params->getString('text') : null;
$messagePublic = $params->getBoolean('public', false) ? $message : null;
if (in_array($status, array(500, 599), true)) {
$response->addHeaderRaw('HTTP/1.1 ' . $status . ' Internal Server Error');
$response->sendHeaders();
exit($message);
}
$exception = $params->getString('exception');
if (!in_array($exception, array('CM_Exception', 'CM_Exception_AuthRequired'), true)) {
$exception = 'CM_Exception';
}
throw new $exception($message, $messagePublic);
}
示例12: _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);
}
示例13: 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);
}
示例14: 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' => '']);
}
}
示例15: prepare
public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
{
$viewResponse->set('class', $renderParams->has('class') ? $renderParams->getString('class') : null);
$years = range($this->_yearFirst, $this->_yearLast);
$months = range(1, 12);
$days = range(1, 31);
$viewResponse->set('years', array_combine($years, $years));
$viewResponse->set('months', array_combine($months, $months));
$viewResponse->set('days', array_combine($days, $days));
/** @var DateTime|null $value */
$value = $this->getValue();
$year = $month = $day = null;
if (null !== $value) {
$value->setTimezone($this->_getTimeZone($environment));
$year = $value->format('Y');
$month = $value->format('n');
$day = $value->format('j');
}
$viewResponse->set('yy', $year);
$viewResponse->set('mm', $month);
$viewResponse->set('dd', $day);
$viewResponse->set('placeholderStart', $renderParams->has('placeholderStart') ? $renderParams->getString('placeholderStart') : null);
$viewResponse->set('placeholderEnd', $renderParams->has('placeholderEnd') ? $renderParams->getString('placeholderEnd') : null);
}