本文整理汇总了PHP中yii\helpers\ArrayHelper::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::filter方法的具体用法?PHP ArrayHelper::filter怎么用?PHP ArrayHelper::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::filter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContextMessage
/**
* If [[includeContext]] property is false, returns context message normally.
* If [[includeContext]] is true, returns an empty string (so that context message in [[collect]] is not generated),
* expecting that context will be appended to every message in [[prepareMessage]].
* @return array the context information
*/
protected function getContextMessage()
{
if (null === $this->_contextMessage || !$this->cacheContext) {
$this->_contextMessage = ArrayHelper::filter($GLOBALS, $this->logVars);
}
return $this->_contextMessage;
}
示例2: dirname
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Json;
/**
* Get local enviroment params
*/
$parameters = dirname(dirname(__DIR__)) . '/conf.d/parameters.json';
if (is_file($parameters)) {
$filters = ['db', 'db.host', 'db.name', 'db.username', 'db.password', 'host', 'host.info', 'host.baseUrl', 'git', 'git.cmd', 'hg', 'hg.cmd', 'emailFrom', 'smtp', 'smtp.host', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.encryption'];
return ArrayHelper::filter(Json::decode(file_get_contents($parameters)), $filters);
} else {
return [];
}
示例3: getContextMessage
/**
* Generates the context information to be logged.
* The default implementation will dump user information, system variables, etc.
* @return string the context information. If an empty string, it means no context information.
*/
protected function getContextMessage()
{
$context = ArrayHelper::filter($GLOBALS, $this->logVars);
$result = [];
foreach ($context as $key => $value) {
$result[] = "\${$key} = " . VarDumper::dumpAsString($value);
}
return implode("\n\n", $result);
}
示例4: cacheAttributeItems
/**
* Cache attribute items
*
* @since 0.0.1
* @param {string} $attribute
* @return {none}
*/
private function cacheAttributeItems($attribute)
{
$nameItems = [];
$unsupportItems = [];
$_attribute = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute)))) . 'Items';
if ($this->hasMethod($_attribute)) {
$attributeitems = $this->{$_attribute}();
$_defaultNameItems = $attributeitems[0];
if ($_defaultNameItems && is_array($_defaultNameItems)) {
$_scenario = [];
foreach ($this->getActiveValidators($attribute) as $validator) {
if ($validator instanceof RangeValidator) {
$_scenario = ArrayHelper::merge($_scenario, ArrayHelper::filter($_defaultNameItems, $validator->range));
}
}
$nameItems[$this->scenario] = array_unique($_scenario);
$nameItems['_default'] = $_defaultNameItems;
}
if (isset($attributeitems[1]) && is_array($attributeitems[1])) {
$unsupportItems = $attributeitems[1];
}
}
$this->_attributeNameItemsList[$attribute] = $nameItems;
$this->_attributeUnsupportItemsList[$attribute] = $unsupportItems;
}