本文整理汇总了PHP中Nette\Utils\Arrays::getRef方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::getRef方法的具体用法?PHP Arrays::getRef怎么用?PHP Arrays::getRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Arrays
的用法示例。
在下文中一共展示了Arrays::getRef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processFiles
/**
*
* @param array $files
* @param array $names Array of indexes of $files array representing current nesting level. E.g. if we are iterating over $files[k1][k2] then $names=[k1,k2]
*/
private function processFiles(array $files, array $names = [])
{
foreach ($files as $name => $controlValue) {
$names[] = $name;
// MFU sends data in this format:
//
// array(
// "token" => "blablabla",
// "files" => array(
// 0 => FileUpload(...),
// ...
// )
// )
// expanded POST array with $names indexes
$postFromHttpRequest = $this->httpRequest->getPost();
$postArr = Arrays::getRef($postFromHttpRequest, $names);
$isFormMFU = (is_array($controlValue) and isset($controlValue["files"]) and isset($postArr['token']));
if ($isFormMFU) {
$token = $postArr["token"];
foreach ($controlValue["files"] as $file) {
self::processFile($token, $file);
}
// support for nested Nette\Forms\Container
} elseif (is_array($controlValue)) {
$this->processFiles($controlValue, $names);
}
// skip files not processed by MFU
// they will be processed by Nette Forms
}
}
示例2: parse
/**
* @param array $cookies
*/
private function parse(array $cookies)
{
foreach ($cookies as $raw) {
if (!($cookie = static::readCookie($raw))) {
continue;
}
if (isset($cookie['expires']) && \DateTime::createFromFormat(static::COOKIE_DATETIME, $cookie['expires']) < date_create()) {
continue;
// cookie already expired
}
if (strpos($name = $cookie['name'], '[') === FALSE) {
$this->{$name} = $cookie['value'];
} else {
$keys = explode('[', str_replace(']', '', $name));
$cookieValue =& Arrays::getRef($arr =& $this->{array_shift($keys)}, $keys);
$cookieValue = $cookie['value'];
unset($cookieValue);
}
}
}
示例3: callOnRef
/**
* @param array
* @param array
* @param callable
* @return mixed
*/
public static function callOnRef(&$arr, $key, $callback)
{
if (!is_callable($callback, TRUE)) {
throw new JedenWeb\InvalidArgumentException("Invalid callback.");
}
return $callback(Nette\Utils\Arrays::getRef($arr, $key));
}