本文整理汇总了PHP中Arr::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::set方法的具体用法?PHP Arr::set怎么用?PHP Arr::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session
/**
* Get or set our $_SESSION var via . sperated array access
*
* @param key string A period seperated string of array keys and values
* @param value string The value to be set
*
* @return array
*/
static function session($key, $value = null)
{
if (!is_null($value)) {
Arr::set($_SESSION, ID . '.' . $key, $value);
}
return Arr::get($_SESSION, ID . '.' . $key);
}
示例2: setup_configs_template_body
public static function setup_configs_template_body($configs)
{
foreach ($configs as $type => $types) {
foreach ($types as $module => $modules) {
foreach ($modules as $item_key => $items) {
if (!isset($items['body'])) {
continue;
}
if (!is_array($items['body'])) {
continue;
}
if (!empty($items['body']['default']['file'])) {
$ext = !empty($items['format']) ? $items['format'] : 'php';
$body = file_get_contents(sprintf('%sviews/%s.%s', APPPATH, $items['body']['default']['file'], $ext));
} elseif (!empty($items['body']['default']['value'])) {
$body = $items['body']['default']['value'];
} else {
continue;
}
$key = implode('.', array($type, $module, $item_key, 'body'));
Arr::set($configs, $key, $body);
}
}
}
return $configs;
}
示例3: set
/**
* Set a configuration item.
*
* @param string $key
* @param mixed $value
* @return void
*/
public static function set($key, $value)
{
list($module, $file, $key) = static::parse($key);
if (!static::load($module, $file)) {
throw new \Exception("Error setting configuration option. Configuration file [{$file}] is not defined.");
}
Arr::set(static::$items[$module][$file], $key, $value);
}
示例4: update
public function update(array $menu)
{
// Set children
$root = \Config::get('menu/' . $this->id, array());
\Arr::set($root, 'children', $menu);
// Save to file
return \Config::save('menu/' . $this->id, $root);
}
示例5: set
/**
* Set a configuration item
*
* Similar to the Config::get method, this function uses "dot" notation to
* allow for setting of configuration items. Setting a configuration item does
* not save the configuration permanently, only for the life of this request.
*
* ## Usage
*
* Config::set('file.key', $value);
*
* @param string The "dot" notation key to be set
* @param mixed The value of the key to be set
* @return void No value is returned
*/
public static function set($key, $value)
{
list($package, $file, $key) = static::parse($key);
if (!static::load($package, $file)) {
throw new \OutOfBoundsException('Error setting configuration option. Configuration file [%s] is not defined.', $file);
}
Arr::set(static::$items[$package][$file], $key, $value);
}
示例6: set
/**
* 设置值
*
* @param $name 类型如get.name,post.id
* @param $value
*
* @return bool
*/
public function set($name, $value)
{
$info = explode('.', $name);
$action = strtoupper(array_shift($info));
if (isset(self::$items[$action])) {
self::$items[$action] = Arr::set(self::$items[$action], implode('.', $info), $value);
return true;
}
}
示例7: set_config
/**
* Sets a config item
*
* @param mixed $key Config key or array to merge
* @param mixed $value Config value
*
* @return this
*/
public function set_config($key, $value = null)
{
if (is_array($key)) {
$this->config = \Arr::merge($this->config, $key);
} else {
\Arr::set($this->config, $key, $value);
}
return $this;
}
示例8: newFromBuilder
/**
* @param array $attributes
* @return static
*/
public function newFromBuilder($attributes = [], $connection = null)
{
$attributes = (array) $attributes;
$nestedData = [];
foreach ($attributes as $key => $value) {
$key = str_replace('---', '.', $key);
Arr::set($nestedData, $key, $value);
}
$instance = $this->buildForeignEntity(null, $nestedData);
return $instance;
}
示例9: action_popup
public function action_popup()
{
if (empty($_GET['url'])) {
foreach ($this->config['fields'] as $key => $field) {
if (\Arr::get($field, 'form.default') && !isset($_GET[$key])) {
\Arr::set($_GET, $key, \Arr::get($field, 'form.default'));
}
}
}
return parent::action_popup();
}
示例10: set_config
/**
* Sets a config value
*
* @param string
* @param mixed
* @return Fieldset this, to allow chaining
*/
public function set_config($config, $value = null)
{
$config = is_array($config) ? $config : array($config => $value);
foreach ($config as $key => $value) {
if (strpos($key, '.') === false) {
$this->config[$key] = $value;
} else {
\Arr::set($this->config, $key, $value);
}
}
return $this;
}
示例11: _init
public static function _init()
{
// static::$_properties = \Arr::merge(static::$_properties, array(
// 'default_id' => array(
// 'form' => array(
// 'options' => function($model) {
// $model->items;
// $model = $model->to_array();
// return \Arr::pluck($model['items'], 'name', 'id');
// }
// )
// ),
// ));
if (\Auth::has_access('enum.enum[all]')) {
\Arr::set(static::$_properties, 'read_only.form', array('type' => 'checkbox', 'template' => 'switch', 'options' => array(gettext('No'), gettext('Yes'))));
}
}
示例12: set_global_offset
/**
* viewファイルからの全体オフセット量追加
*
* このメソッドによる変更はインスタンスが破棄されるまで有効です
*
* @param real $x 水平方向のオフセット量
* @param real $y 垂直方向のオフセット量
*/
public function set_global_offset($x = 0.0, $y = 0.0)
{
\Arr::set($this->config, 'global_offset.x', \Arr::get($this->config, 'global_offset.x') + $x);
\Arr::set($this->config, 'global_offset.y', \Arr::get($this->config, 'global_offset.y') + $y);
}
示例13: set
/**
* Set new or update existing config variable
*
* <code>
* Config::set('site.title', 'value');
* </code>
*
* @access public
* @param string $key Key
* @param mixed $value Value
*/
public static function set($key, $value)
{
Arr::set(static::$config, $key, $value);
}
示例14: array_set
/**
* Set an array item to a given value using "dot" notation.
*
* If no key is given to the method, the entire array will be replaced.
*
* @param array $array
* @param string $key
* @param mixed $value
* @return array
*/
function array_set(&$array, $key, $value)
{
return Arr::set($array, $key, $value);
}
示例15: set_flash
/**
* set session flash variables
*
* @param string name of the variable to set
* @param mixed value
* @access public
* @return Fuel\Core\Session_Driver
*/
public function set_flash($name, $value)
{
if (strpos($name, '.') !== false) {
$keys = explode('.', $name, 2);
$name = array_shift($keys);
} else {
$keys = false;
}
if ($keys) {
if (isset($this->flash[$this->config['flash_id'] . '::' . $name]['value'])) {
$this->flash[$this->config['flash_id'] . '::' . $name]['state'] = 'new';
} else {
$this->flash[$this->config['flash_id'] . '::' . $name] = array('state' => 'new', 'value' => array());
}
\Arr::set($this->flash[$this->config['flash_id'] . '::' . $name]['value'], $keys[0], $value);
} else {
$this->flash[$this->config['flash_id'] . '::' . $name] = array('state' => 'new', 'value' => $value);
}
return $this;
}