mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 20:51:53 +02:00
e107::getSession()->set will now accept multi-dimensional key format. Test added. Form-handler PHP8 fix.
This commit is contained in:
parent
608c0c57b1
commit
72c54371cc
@ -5648,24 +5648,31 @@ var_dump($select_options);*/
|
||||
break;
|
||||
|
||||
case 'files':
|
||||
if(!empty($value) && !is_array($value))
|
||||
{
|
||||
return "Type 'files' must have a data type of 'array' or 'json'";
|
||||
}
|
||||
$ret = '<ol>';
|
||||
for ($i=0; $i < 5; $i++)
|
||||
{
|
||||
$ival = $value[$i]['path'];
|
||||
|
||||
if(empty($ival))
|
||||
if(!empty($value))
|
||||
{
|
||||
if(!is_array($value))
|
||||
{
|
||||
continue;
|
||||
return "Type 'files' must have a data type of 'array' or 'json'";
|
||||
}
|
||||
|
||||
$ret .= '<li>'.$ival.'</li>';
|
||||
$ret = '<ol>';
|
||||
for ($i=0; $i < 5; $i++)
|
||||
{
|
||||
$ival = $value[$i]['path'];
|
||||
|
||||
if(empty($ival))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$ret .= '<li>'.$ival.'</li>';
|
||||
}
|
||||
$ret .= '</ol>';
|
||||
$value = $ret;
|
||||
}
|
||||
$ret .= '</ol>';
|
||||
$value = $ret;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 'datestamp':
|
||||
|
@ -303,13 +303,34 @@ class e_session
|
||||
/**
|
||||
* Set value in current session namespace
|
||||
* Equals to $_SESSION[NAMESPACE][$key] = $value
|
||||
* @param string $key
|
||||
* @param string $key Also accepts multi-dimensinal format. key1/key2
|
||||
* @param mixed $value
|
||||
* @return e_session
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->_data[$key] = $value;
|
||||
if(strpos($key,'/') !== false) // multi-dimensional
|
||||
{
|
||||
$keyArr = explode('/',$key);
|
||||
$count = count($keyArr);
|
||||
|
||||
if($count === 2)
|
||||
{
|
||||
list($k1, $k2) = $keyArr;
|
||||
$this->_data[$k1][$k2] = $value;
|
||||
}
|
||||
elseif($count === 3)
|
||||
{
|
||||
list($k1, $k2, $k3) = $keyArr;
|
||||
$this->_data[$k1][$k2][$k3] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_data[$key] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ class e107Test extends \Codeception\Test\Unit
|
||||
$all = e107::getAddonConfig('e_url');
|
||||
foreach($all as $plugin => $var)
|
||||
{
|
||||
if($plugin === 'gallery' || $plugin === 'rss_menu') // fixme - sef may be enabled or disabled each time tests are run
|
||||
if($plugin === 'gallery' || $plugin === 'rss_menu' || $plugin === 'vstore') // fixme - sef may be enabled or disabled each time tests are run
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -60,6 +60,20 @@
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
||||
// Multi-dimensional array support.
|
||||
$newsess = e107::getSession('newtest');
|
||||
|
||||
$newsess->set('customer', array('firstname'=>'Fred'));
|
||||
$newsess->set('customer/lastname', 'Smith');
|
||||
|
||||
$expected = array (
|
||||
'firstname' => 'Fred',
|
||||
'lastname' => 'Smith',
|
||||
);
|
||||
|
||||
$result = $newsess->get('customer');
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
}
|
||||
/*
|
||||
public function testGetOption()
|
||||
|
Loading…
x
Reference in New Issue
Block a user