Contao\Session::getData PHP 메소드

getData() 공개 메소드

Return the session data as array
public getData ( ) : array
리턴 array The session data
    public function getData()
    {
        $data = $this->sessionBag->all();
        // Map the referer (see #281)
        foreach ($this->mappedKeys as $strKey) {
            unset($data[$strKey]);
            if ($this->session->has($strKey)) {
                $data[$strKey] = $this->session->get($strKey);
            }
        }
        return $data;
    }

Usage Example

 /**
  * Restrict content element ids.
  *
  * @param array $allowedElements List of allowed elements.
  * @param int   $contentId       The id of the current content element.
  *
  * @return void
  * @throws AccessDeniedException When an invalid content element type is accessed.
  */
 private function restrictIds($allowedElements, $contentId)
 {
     $session = $this->session->getData();
     $allowedElements = ArrayUtil::flatten($allowedElements);
     // Set allowed content element IDs (edit multiple)
     if (!empty($session['CURRENT']['IDS']) && is_array($session['CURRENT']['IDS'])) {
         $session['CURRENT']['IDS'] = $this->filterIds($session['CURRENT']['IDS'], $allowedElements);
     }
     // Set allowed clipboard IDs
     if (!empty($session['CLIPBOARD']['tl_content']['id'])) {
         $session['CLIPBOARD']['tl_content']['id'] = $this->filterIds((array) $session['CLIPBOARD']['tl_content']['id'], $allowedElements, 'sorting');
     }
     // Overwrite session
     $this->session->setData($session);
     $this->guardAllowedAccess($allowedElements, $contentId);
 }