示例#1
0
文件: Cookies.php 项目: yeephp/yeephp
 /**
  * Set cookie
  *
  * The second argument may be a single scalar value, in which case
  * it will be merged with the default settings and considered the `value`
  * of the merged result.
  *
  * The second argument may also be an array containing any or all of
  * the keys shown in the default settings above. This array will be
  * merged with the defaults shown above.
  *
  * @param string $key   Cookie name
  * @param mixed  $value Cookie settings
  */
 public function set($key, $value)
 {
     if (is_array($value)) {
         $cookieSettings = array_replace($this->defaults, $value);
     } else {
         $cookieSettings = array_replace($this->defaults, array('value' => $value));
     }
     parent::set($key, $cookieSettings);
 }
示例#2
0
文件: View.php 项目: yeephp/yeephp
 /**
  * DEPRECATION WARNING! This method will be removed in the next major point release
  *
  * Set data for view
  */
 public function setData()
 {
     $args = func_get_args();
     if (count($args) === 1 && is_array($args[0])) {
         $this->data->replace($args[0]);
     } elseif (count($args) === 2) {
         // Ensure original behavior is maintained. DO NOT invoke stored Closures.
         if (is_object($args[1]) && method_exists($args[1], '__invoke')) {
             $this->data->set($args[0], $this->data->protect($args[1]));
         } else {
             $this->data->set($args[0], $args[1]);
         }
     } else {
         throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`');
     }
 }