/**
  * Returns the current session or opens a new one if none exists yet
  * @return \Cx\Core\Session\Model\Entity\Session Session instance
  */
 public function getSession()
 {
     return \Cx\Core\Session\Model\Entity\Session::getInstance();
 }
Example #2
0
 /**
  * Ensure that the used parameter name complies with the session
  * restrictions defined for variable keys, as the parameter name
  * is being used as a sesison-variable-key.
  * @param string $parameterName The name of the session-variable-key used to store the current paging position.
  * @return string $parameterName The sanitized session-variable-key.
  */
 private static function sanitizeParameterName($parameterName)
 {
     // Important: As the parameter name is used as a session-variable-key,
     // it must not exceed the allowed session-variable-key-length.
     // Therefore, if required, the parameter name is hashed and cut to the
     // maximum allowed session-variable-key-length.
     if (strlen($parameterName) > \Cx\Core\Session\Model\Entity\Session::getVariableKeyMaxLength()) {
         $parameterName = substr(md5($parameterName), 0, \Cx\Core\Session\Model\Entity\Session::getVariableKeyMaxLength());
     }
     return $parameterName;
 }
Example #3
0
 /**
  * Adds a message of the given class
  *
  * The optional $class defaults to the CLASS_INFO class constant.
  * May be empty, or one of CLASS_OK, CLASS_INFO, CLASS_WARN,
  * or CLASS_ERROR.
  * @param   string  $message        The message to add
  * @param   string  $class          The optional class.
  *                                  Defaults to CLASS_INFO
  * @author  Reto Kohli <*****@*****.**>
  * @static
  */
 static function add($message, $class = self::CLASS_INFO)
 {
     if (!\Cx\Core\Session\Model\Entity\Session::isInitialized()) {
         throw new \Exception("\\Message can't be used at this point as no session has been initialized yet!");
     }
     if (empty($_SESSION['messages'])) {
         $_SESSION['messages'] = array();
     }
     if (empty($_SESSION['messages'][$class])) {
         $_SESSION['messages'][$class] = array();
     }
     $_SESSION['messages'][$class][] = $message;
 }