本文整理汇总了PHP中Fuel::value方法的典型用法代码示例。如果您正苦于以下问题:PHP Fuel::value方法的具体用法?PHP Fuel::value怎么用?PHP Fuel::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fuel
的用法示例。
在下文中一共展示了Fuel::value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: option
/**
* Returns the option with the given name. You can also give the option
* number.
*
* Named options must be in the following formats:
* php index.php user -v --v -name=John --name=John
*
* @param string|int $name the name of the option (int if unnamed)
* @return string
*/
public static function option($name, $default = null)
{
if (!isset(static::$args[$name])) {
return \Fuel::value($default);
}
return static::$args[$name];
}
示例2: get
/**
* Gets a dot-notated key from an array, with a default value if it does
* not exist.
*
* @param array $array The search array
* @param mixed $key The dot-notated key or array of keys
* @param string $default The default value
* @return mixed
*/
public static function get($array, $key, $default = null)
{
if (!is_array($array) and !$array instanceof \ArrayAccess) {
throw new \InvalidArgumentException('First parameter must be an array or ArrayAccess object.');
}
if (is_null($key)) {
return $array;
}
if (is_array($key)) {
$return = array();
foreach ($key as $k) {
$return[$k] = static::get($array, $k, $default);
}
return $return;
}
foreach (explode('.', $key) as $key_part) {
if (($array instanceof \ArrayAccess and isset($array[$key_part])) === false) {
if (!is_array($array) or !array_key_exists($key_part, $array)) {
return \Fuel::value($default);
}
}
$array = $array[$key_part];
}
return $array;
}
示例3: forge
/**
* {@inheritdoc}
*/
public static function forge($instance = 'default', array $handlers = array())
{
$logger = new Monolog\Logger($instance);
$handlers = \Arr::merge(\Config::get('logger.' . $instance, array()), $handlers);
foreach ($handlers as $handler) {
$handler = \Fuel::value($handler);
$logger->pushHandler($handler);
}
return static::newInstance($instance, $logger);
}
示例4: get
public static function get($line, array $params = array(), $default = null, $language = null)
{
$output = parent::get($line, $params, '__NOT__FOUND__', $language);
if (!empty($output) && $output != '__NOT__FOUND__') {
return $output;
}
if ($output == '__NOT__FOUND__') {
$output = $default;
}
if (!static::$autosave || !\CMF::$lang_enabled) {
return $output;
}
$language === null and $language = static::get_lang();
$pos = strpos($line, '.');
$group = 'common';
$basename = $line;
if ($pos === false) {
if (empty($default)) {
$default = $line;
}
$line = "{$group}.{$line}";
} else {
$basename = substr($line, $pos + 1);
if (empty($default)) {
$default = $basename;
}
$group = substr($line, 0, $pos);
}
// Try and load from the DB...
if (!in_array($group . '_' . $language, static::$loaded)) {
static::load("{$group}.db", $group, $language, true, true);
static::$loaded[] = $group . '_' . $language;
}
// Don't continue if it's not the 'common' group
if ($group != 'common') {
return $output != null ? \Str::tr(\Fuel::value($output), $params) : $default;
}
$output = \Arr::get(static::$lines, "{$language}.{$line}");
if ($output == null) {
// First try and get from the fallback...
$output = \Arr::get(static::$lines, static::$fallback[0] . ".{$line}");
if (!in_array($group, static::$to_save)) {
static::$to_save[] = $group;
}
//if (!empty($default) && $default != $line)
static::set($line, $default);
static::set($line, $default, null, static::$fallback[0]);
if ($output == null) {
$output = $default;
}
}
return $output != null ? \Str::tr(\Fuel::value($output), $params) : $default;
}
示例5: set
/**
* Sets a signed cookie. Note that all cookie values must be strings and no
* automatic serialization will be performed!
*
* // Set the "theme" cookie
* Cookie::set('theme', 'red');
*
* @param string name of cookie
* @param string value of cookie
* @param integer lifetime in seconds
* @param string path of the cookie
* @param string domain of the cookie
* @param boolean if true, the cookie should only be transmitted over a secure HTTPS connection
* @param boolean if true, the cookie will be made accessible only through the HTTP protocol
* @return boolean
*/
public static function set($name, $value, $expiration = null, $path = null, $domain = null, $secure = null, $http_only = null)
{
$value = \Fuel::value($value);
// use the class defaults for the other parameters if not provided
is_null($expiration) and $expiration = static::$config['expiration'];
is_null($path) and $path = static::$config['path'];
is_null($domain) and $domain = static::$config['domain'];
is_null($secure) and $secure = static::$config['secure'];
is_null($http_only) and $http_only = static::$config['http_only'];
// add the current time so we have an offset
$expiration = $expiration > 0 ? $expiration + time() : 0;
return setcookie($name, $value, $expiration, $path, $domain, $secure, $http_only);
}
示例6: get
/**
* Return the named column from the current row.
*
* // Get the "id" value
* $id = $result->get('id');
*
* @param string $name column to get
* @param mixed $default default value if the column does not exist
*
* @return mixed
*/
public function get($name, $default = null)
{
$row = $this->current();
if ($this->_as_object) {
if (isset($row->{$name})) {
// sanitize the data if needed
if (!$this->_sanitization_enabled) {
$result = $row->{$name};
} else {
$result = \Security::clean($row->{$name}, null, 'security.output_filter');
}
return $result;
}
} else {
if (isset($row[$name])) {
// sanitize the data if needed
if (!$this->_sanitization_enabled) {
$result = $row[$name];
} else {
$result = \Security::clean($row[$name], null, 'security.output_filter');
}
return $result;
}
}
return \Fuel::value($default);
}
示例7: set
/**
* Sets a (dot notated) config item
*
* @param
* string a (dot notated) config key
* @param
* mixed the config value
* @return void the \Arr::set result
*/
public static function set($item, $value)
{
strpos($item, '.') === false or static::$itemcache[$item] = $value;
return \Arr::set(static::$items, $item, \Fuel::value($value));
}
示例8: set
/**
* Front for writing the cache, ensures interchangebility of storage drivers. Actual writing
* is being done by the _set() method which needs to be extended.
*
* @param mixed The identifier of the cache, can be anything but empty
* @param mixed The content to be cached
* @param int The time in seconds until the cache will expire, =< 0 or null means no expiration
* @param array Contains the identifiers of caches this one will depend on (not supported by all drivers!)
* @return Cache_Storage_Driver The new Cache object
*/
public static function set($identifier, $contents = null, $expiration = false, $dependencies = array())
{
$contents = \Fuel::value($contents);
$cache = static::forge($identifier);
return $cache->set($contents, $expiration, $dependencies);
}
示例9: get
/**
* Return the named column from the current row.
*
* // Get the "id" value
* $id = $result->get('id');
*
* @param string column to get
* @param mixed default value if the column does not exist
* @return mixed
*/
public function get($name, $default = null)
{
$row = $this->current();
if ($this->_as_object) {
if (isset($row->{$name})) {
return $row->{$name};
}
} else {
if (isset($row[$name])) {
return $row[$name];
}
}
return \Fuel::value($default);
}
示例10: elseif
/**
* Searches for the given variable and returns its value.
* Local variables will be returned before global variables.
*
* $value = $view->get('foo', 'bar');
*
* If the key is not given or null, the entire data array is returned.
*
* If a default parameter is not given and the variable does not
* exist, it will throw an OutOfBoundsException.
*
* @param string The variable name
* @param mixed The default value to return
* @return mixed
* @throws OutOfBoundsException
*/
public function &get($key = null, $default = null)
{
if (func_num_args() === 0 or $key === null) {
return $this->data;
} elseif (array_key_exists($key, $this->data)) {
return $this->data[$key];
} elseif (array_key_exists($key, static::$global_data)) {
return static::$global_data[$key];
}
if (is_null($default) and func_num_args() === 1) {
throw new \OutOfBoundsException('View variable is not set: ' . $key);
} else {
// assign it first, you can't return a return value by reference directly!
$default = \Fuel::value($default);
return $default;
}
}
示例11: param
/**
* Gets a specific named parameter
*
* @param string $param Name of the parameter
* @param mixed $default Default value
* @return mixed
*/
public function param($param, $default = null)
{
if (!isset($this->named_params[$param])) {
return \Fuel::value($default);
}
return $this->named_params[$param];
}
示例12: set
/**
* Sets a (dot notated) language string
*
* @param string a (dot notated) language key
* @param mixed the language string
* @param string group
* @return void the \Arr::set result
*/
public static function set($line, $value, $group = null)
{
$group === null or $line = $group . '.' . $line;
return \Arr::set(static::$lines, $line, \Fuel::value($value));
}
示例13: get_segment
/**
* Get the specified URI segment, return default if it doesn't exist.
*
* Segment index is 1 based, not 0 based
*
* @param string $segment The 1-based segment index
* @param mixed $default The default value
* @return mixed
*/
public function get_segment($segment, $default = null)
{
if (isset($this->segments[$segment - 1])) {
return $this->segments[$segment - 1];
}
return \Fuel::value($default);
}
示例14: set
/**
* Front for writing the cache, ensures interchangeability of storage engines.
* Actual writing
* is being done by the _set() method which needs to be extended.
*
* @param
* mixed The content to be cached
* @param
* int The time in seconds until the cache will expire, =< 0 or null means no expiration
* @param
* array array of names on which this cache depends for
* @return Cache_Storage_Driver The new request
*/
public final function set($contents = null, $expiration = false, $dependencies = array())
{
$contents = \Fuel::value($contents);
// save the current expiration
$current_expiration = $this->expiration;
// Use either the given value or the class property
if (!is_null($contents)) {
$this->set_contents($contents);
}
$this->expiration = $expiration !== false ? $expiration : $this->expiration;
$this->dependencies = !empty($dependencies) ? $dependencies : $this->dependencies;
$this->created = time();
// Create expiration timestamp when other then null
if (!is_null($this->expiration)) {
if (!is_numeric($this->expiration)) {
throw new \InvalidArgumentException('Expiration must be a valid number.');
}
$this->expiration = $this->created + intval($this->expiration);
}
// Convert dependency identifiers to string when set
$this->dependencies = !is_array($this->dependencies) ? array($this->dependencies) : $this->dependencies;
if (!empty($this->dependencies)) {
foreach ($this->dependencies as $key => $id) {
$this->dependencies[$key] = $this->stringify_identifier($id);
}
}
// Turn everything over to the storage specific method
$this->_set();
// restore the expiration
$this->expiration = $current_expiration;
}
示例15: elseif
/**
* Searches for the given variable and returns its value.
* Local variables will be returned before global variables.
*
* $value = $view->get('foo', 'bar');
*
* If a default parameter is not given and the variable does not
* exist, it will throw an OutOfBoundsException.
*
* @param string The variable name
* @param mixed The default value to return
* @return mixed
* @throws OutOfBoundsException
*/
public function &get($key, $default = null)
{
if (array_key_exists($key, $this->data)) {
return $this->data[$key];
} elseif (array_key_exists($key, static::$global_data)) {
return static::$global_data[$key];
}
if (is_null($default) and func_num_args() === 1) {
throw new \OutOfBoundsException('View variable is not set: ' . $key);
} else {
return \Fuel::value($default);
}
}