本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\Session::offsetGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::offsetGet方法的具体用法?PHP Session::offsetGet怎么用?PHP Session::offsetGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Session\Session
的用法示例。
在下文中一共展示了Session::offsetGet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Returns value for given name
*
* @param string $name
* @return mixed
*/
public function get($name)
{
if ($this->container instanceof WP_Session) {
$value = $this->container->offsetGet($name);
} else {
$value = $this->container->get($name);
}
return $value;
}
示例2: display
/**
* Заключительная сборка готовой формы
*
* @return string
*/
public function display()
{
// Информационные сообщения об ошибке, или успехе
$message = '';
$saved = filter_has_var(INPUT_GET, 'saved');
if ($this->infoMessages !== false && $this->isSubmitted || $saved) {
if ($this->isValid || $saved) {
// Сообщение об удачном сохранении данных
$message = sprintf($this->infoMessages, 'alert-success', $this->successMessage);
if ($this->confirmation) {
// Если задано отдельное окно подтверждения
//TODO: Переделать App
$message .= '<a class="btn btn-primary" href="' . ($this->continueLink === null ? \App::getInstance()->request()->getBaseUrl() : $this->continueLink) . '/">' . _s('Continue') . '</a>';
return $message;
}
} else {
// Сообщение, что имеются ошибки
$message = sprintf($this->infoMessages, 'alert-danger', $this->errorMessage);
}
}
$out = [];
foreach ($this->fields as &$element) {
// Создаем элемент формы
switch ($element['type']) {
case 'html':
$out[] = $element['content'];
break;
case 'captcha':
$captcha = new Captcha();
$code = $captcha->generateCode();
$this->session->offsetSet('captcha', $code);
$out[] = '<img alt="' . _s('If you do not see the picture with the code, turn the graphics support in your browser and refresh the page') . '" width="' . $captcha->width . '" height="' . $captcha->height . '" src="' . $captcha->generateImage($code) . '"/>';
break;
default:
if ($this->isSubmitted && isset($element['reset_value'])) {
$element['value'] = $element['reset_value'];
}
$out[] = (new Fields($element))->display();
}
}
// Добавляем токен валидации
if (!$this->session->offsetExists('form_token')) {
$this->session->offsetSet('form_token', md5(rand(1, 1000) . microtime()));
}
$out[] = (new Fields(['type' => 'hidden', 'name' => 'form_token', 'value' => $this->session->offsetGet('form_token')]))->display();
return sprintf(PHP_EOL . $message . PHP_EOL . '<form role="form" name="%s" method="%s"%s%s%s>%s</form>' . PHP_EOL, $this->form['name'], $this->form['method'], isset($this->form['action']) ? ' action="' . $this->form['action'] . '"' : '', isset($this->form['enctype']) ? ' enctype="multipart/form-data"' : '', isset($this->form['class']) ? ' class="' . $this->form['class'] . '"' : '', PHP_EOL . implode(PHP_EOL, $out) . PHP_EOL);
}