Completed
Push — 4.3 ( 41dc92...731ef0 )
by Maxime
36s queued 17s
created

SessionStore::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace SilverStripe\Forms\GridField\FormAction;
3
4
use SilverStripe\Control\HTTPRequest;
5
6
/**
7
 * Stores GridField action state in the session in exactly the same way it has in the past
8
 */
9
class SessionStore extends AbstractRequestAwareStore implements StateStore
10
{
11
    /**
12
     * Save the given state against the given ID returning an associative array to be added as attributes on the form
13
     * action
14
     *
15
     * @param string $id
16
     * @param array $state
17
     * @return array
18
     */
19
    public function save($id, array $state)
20
    {
21
        $this->getRequest()->getSession()->set($id, $state);
22
23
        // This adapter does not require any additional attributes...
24
        return [];
25
    }
26
27
    /**
28
     * Load state for a given ID
29
     *
30
     * @param string $id
31
     * @return array
32
     */
33
    public function load($id)
34
    {
35
        return (array) $this->getRequest()->getSession()->get($id);
36
    }
37
}
38