mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-09 04:52:42 +00:00
Simplify CookieComponent::read()
Also, this commit fixes an issue of when the second level key is empty. Previously, read('foo.0') returned incorrect result.
This commit is contained in:
parent
bbea91090d
commit
19bbb7da17
2 changed files with 15 additions and 16 deletions
|
@ -261,22 +261,7 @@ class CookieComponent extends Component {
|
|||
if ($key === null) {
|
||||
return $this->_values[$this->name];
|
||||
}
|
||||
|
||||
if (strpos($key, '.') !== false) {
|
||||
$names = explode('.', $key, 2);
|
||||
$key = $names[0];
|
||||
}
|
||||
if (!isset($this->_values[$this->name][$key])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!empty($names[1])) {
|
||||
if (is_array($this->_values[$this->name][$key])) {
|
||||
return Hash::get($this->_values[$this->name][$key], $names[1]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return $this->_values[$this->name][$key];
|
||||
return Hash::get($this->_values[$this->name], $key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue