|
|
@@ -1,7 +1,5 @@
|
|
|
<?php
|
|
|
/**
|
|
|
- * Cookie Component
|
|
|
- *
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
*
|
|
|
@@ -71,30 +69,24 @@ class CookieComponent extends Component {
|
|
|
];
|
|
|
|
|
|
/**
|
|
|
- * Values stored in the cookie.
|
|
|
- *
|
|
|
- * Accessed in the controller using $this->Cookie->read('Name.key');
|
|
|
+ * Config specific to a given top level key name.
|
|
|
*
|
|
|
- * @see CookieComponent::read();
|
|
|
- * @var string
|
|
|
- */
|
|
|
- protected $_values = array();
|
|
|
-
|
|
|
-/**
|
|
|
- * Used to reset cookie time if $expire is passed to CookieComponent::write()
|
|
|
+ * The values in this array are merged with the general config
|
|
|
+ * to generate the configuration for a given top level cookie name.
|
|
|
*
|
|
|
- * @var string
|
|
|
+ * @var array
|
|
|
*/
|
|
|
- protected $_reset = null;
|
|
|
+ protected $_keyConfig = [];
|
|
|
|
|
|
/**
|
|
|
- * Expire time of the cookie
|
|
|
+ * Values stored in the cookie.
|
|
|
*
|
|
|
- * This is controlled by CookieComponent::time;
|
|
|
+ * Accessed in the controller using $this->Cookie->read('Name.key');
|
|
|
*
|
|
|
+ * @see CookieComponent::read();
|
|
|
* @var string
|
|
|
*/
|
|
|
- protected $_expires = 0;
|
|
|
+ protected $_values = array();
|
|
|
|
|
|
/**
|
|
|
* A reference to the Controller's Cake\Network\Response object
|
|
|
@@ -142,6 +134,27 @@ class CookieComponent extends Component {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the configuration for a specific top level key.
|
|
|
+ *
|
|
|
+ * @param string $keyname The top level keyname to configure.
|
|
|
+ * @param null|string|array $option Either the option name to set, or an array of options to set,
|
|
|
+ * or null to read config options for a given key.
|
|
|
+ * @param string|null $value Either the value to set, or empty when $option is an array.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function configKey($keyname, $option = null, $value = null) {
|
|
|
+ if ($option === null) {
|
|
|
+ $default = $this->_config;
|
|
|
+ $local = isset($this->_keyConfig[$keyname]) ? $this->_keyConfig[$keyname] : [];
|
|
|
+ return $local + $default;
|
|
|
+ }
|
|
|
+ if (!is_array($option)) {
|
|
|
+ $option = [$option => $value];
|
|
|
+ }
|
|
|
+ $this->_keyConfig[$keyname] = $option;
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Start CookieComponent for use in the controller
|
|
|
*
|
|
|
* @param Event $event An Event instance
|