本文整理汇总了PHP中ArrayHelper::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::merge方法的具体用法?PHP ArrayHelper::merge怎么用?PHP ArrayHelper::merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::merge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get(Object $oObject, $aParams = array())
{
if (isset($this->aParams['ToModuleAlias'])) {
Core::import('Modules.' . $this->aParams['ToModuleAlias']);
}
$oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
$nLimit = 0;
$nOffset = 0;
$aLocCriteria = array($this->aParams['Field'] => $oObject->getId());
$aLocOrder = array('Pos' => 'ASC');
if (count($aParams) > 0) {
if (isset($aParams['Criteria'])) {
foreach ($aParams['Criteria'] as $key => $val) {
$aLocCriteria[$key] = $val;
}
}
if (isset($aParams['Order'])) {
$aLocOrder = $aParams['Order'];
}
if (isset($aParams['Limit'])) {
$nLimit = intval($aParams['Limit']);
}
if (isset($aParams['Offset'])) {
$nOffset = intval($aParams['Offset']);
}
}
$aDefaultParams = isset($this->aParams['Params']) ? $this->aParams['Params'] : array();
return $oMapper->find(ArrayHelper::merge($aDefaultParams, array('Order' => $aLocOrder, 'Criteria' => $aLocCriteria, 'Limit' => $nLimit, 'Offset' => $nOffset)));
}
示例2: serialize
protected function serialize(AbstractQueryRequest $request) {
$parameters = NULL;
// serializing columns names to sort result
if (isset($request->sortingConfigurations)) {
$sortColumns = NULL;
foreach ($request->sortingConfigurations as $sortingConfiguration) {
$sortColumns[] = ColumnBasedComparator_AbstractSortingConfiguration::assembleDirectionalColumnName(
$sortingConfiguration->getColumnName(), $sortingConfiguration->isSortAscending);
}
ArrayHelper::merge(
$parameters,
$this->serializeValue(
DataQueryControllerUIParameterNames::SORT,
DataQueryControllerUIRequestPreparer::prepareSortColumns($sortColumns)));
}
// serializing record offset
if (isset($request->startWith) && ($request->startWith > 0)) {
$parameters[DataQueryControllerUIParameterNames::OFFSET] = $request->startWith;
}
// serializing record limit
if (isset($request->limit)) {
$parameters[DataQueryControllerUIParameterNames::LIMIT] = $request->limit;
}
return $parameters;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:27,代码来源:AbstractQueryUIRequestSerializer.php
示例3: getHandler
public function getHandler($type) {
if (isset($this->handlers[$type])) {
return $this->handlers[$type];
}
$extensionConfiguration = $this->getExtensionConfiguration($type);
$handlerConfiguration = $this->getHandlerConfiguration($type);
$combinedExtensionConfigurations = NULL;
// adding generic configuration
ArrayHelper::merge($combinedExtensionConfigurations, $extensionConfiguration['extensions']);
// adding handler specific configurations
if (isset($handlerConfiguration['extensions'])) {
ArrayHelper::merge($combinedExtensionConfigurations, $handlerConfiguration['extensions']);
unset($handlerConfiguration['extensions']);
}
$classname = $handlerConfiguration['classname'];
$handler = new $classname($type, $combinedExtensionConfigurations);
$this->handlers[$type] = $handler;
return $handler;
}
示例4: serialize
public function serialize(AbstractQueryRequest $request) {
$parameters = parent::serialize($request);
$columns = NULL;
// preparing dimension-related column
if (isset($request->dimensions)) {
foreach ($request->dimensions as $dimension) {
if (isset($dimension->requestColumnIndex)) {
$columns[] = ParameterNameHelper::assemble($dimension->name);
}
if (isset($dimension->columns)) {
foreach ($dimension->columns as $column) {
$columns[] = ParameterNameHelper::assemble($dimension->name, $column->name);
}
}
}
}
// preparing measure-related columns
if (isset($request->measures)) {
foreach ($request->measures as $measure) {
$columns[] = $measure->name;
}
}
// serializing columns
if (isset($columns)) {
ArrayHelper::merge(
$parameters,
$this->serializeValue(
DataQueryControllerUIParameterNames::COLUMNS,
DataQueryControllerUIRequestPreparer::prepareColumns($columns)));
}
// serializing query
if (isset($request->queries)) {
$queryParameters = NULL;
foreach ($request->queries as $query) {
if ($query instanceof __AbstractCubeQueryRequest_DimensionQuery) {
if (isset($query->columns)) {
foreach ($query->columns as $column) {
ArrayHelper::merge(
$queryParameters,
DataQueryControllerUIRequestPreparer::prepareParameter(
ParameterNameHelper::assemble($query->name, $column->name),
$column->values));
}
}
}
elseif ($query instanceof __AbstractCubeQueryRequest_FactsDatasetColumnQuery) {
ArrayHelper::merge($queryParameters, DataQueryControllerUIRequestPreparer::prepareParameter($query->name, $query->values));
}
elseif ($query instanceof __AbstractCubeQueryRequest_MeasureQuery) {
ArrayHelper::merge($queryParameters, DataQueryControllerUIRequestPreparer::prepareParameter($query->name, $query->values));
}
}
ArrayHelper::merge($parameters, $this->serializeValue(DataQueryControllerUIParameterNames::PARAMETERS, $queryParameters));
}
return $parameters;
}
示例5: run
public function run()
{
$this->start();
$aResult = array();
$aData = array();
$oData = $this->getComponentRequest()->getData();
$buttons = $this->getComponentRequest()->getButtons();
foreach ($this->getComponentRequest()->getFields() as $alias => $header) {
$sClassName = $this->sModuleAlias . 'FormView' . $header['Type'] . 'Column';
$aTmpParams2 = array('Module' => $this->sModuleAlias, 'Component' => $this->sComponentAlias, 'Alias' => $alias, 'Type' => $header['Type'], 'Help' => isset($header['Help']) ? $header['Help'] : '', 'Title' => $header['Title'], 'Required' => isset($header['Params']['Required']) ? $header['Params']['Required'] : false);
if (isset($header['Field'])) {
if (is_object($oData)) {
$sGetter = 'get' . $header['Field'];
$aTmpParams2['Value'] = call_user_func(array($oData, $sGetter));
} else {
if (is_array($oData)) {
if (!empty($oData[$header['Field']])) {
$aTmpParams2['Value'] = $oData[$header['Field']];
} else {
$aTmpParams2['Value'] = '';
}
}
}
}
if (isset($header['Params']) && count($header['Params'])) {
$aTmpParams2 = \ArrayHelper::merge($aTmpParams2, $header['Params']);
}
$aData[$alias] = new $sClassName($aTmpParams2);
}
$backLink = $this->getComponentRequest()->getBackLink();
if ($backLink) {
$aRs = array();
if (preg_match_all("#:~(.*?)#isU", $backLink, $aRs)) {
foreach ($aRs[0] as $k => $it) {
$backLink = str_replace($it, Toolkit::getInstance()->request->get($aRs[1][$k], Request::C_GET), $backLink);
}
}
if (preg_match_all("#:(.*?)#isU", $backLink, $aRs)) {
foreach ($aRs[0] as $k => $it) {
$sGetter = 'get' . $aRs[1][$k];
$backLink = str_replace($it, call_user_func(array($oData, $sGetter)), $backLink);
}
}
}
if (!empty($buttons)) {
$aResult['Buttons'] = new \SimpleCollection();
foreach ($buttons as $button) {
$aResult['Buttons']->add(new \RuxonFormViewButton($button));
}
}
$aResult['ElementId'] = is_object($oData) ? $oData->getId() : 0;
$aResult['Title'] = $this->getComponentRequest()->getTitle();
$aResult['Errors'] = $this->getComponentRequest()->getErrors();
$aResult['BackLink'] = $backLink;
$aResult['Data'] = new \SimpleCollection($aData);
$this->end($aResult, true);
}
示例6: prepareCacheEntryName
protected function prepareCacheEntryName(AbstractQueryRequest $request) {
$serializer = NULL;
if ($request instanceof DatasetQueryRequest) {
$serializer = new DatasetQueryUIRequestSerializer();
}
elseif ($request instanceof DatasetCountRequest) {
$serializer = new DatasetCountUIRequestSerializer();
}
elseif ($request instanceof CubeQueryRequest) {
$serializer = new CubeQueryUIRequestSerializer();
}
elseif ($request instanceof CubeCountRequest) {
$serializer = new CubeQueryUIRequestSerializer();
}
if (!isset($serializer)) {
return NULL;
}
$parameters = $serializer->serialize($request);
$parameters['request'] = get_class($request);
$parameters['src'] = $request->sourceName;
// adding version of each formula
$versions = NULL;
$formulaNames = $request->getFormulaNames();
if (isset($formulaNames)) {
foreach ($formulaNames as $formulaName) {
$formula = $request->getFormula($formulaName);
if (isset($formula->version)) {
$versions[] = $formula->version;
}
}
}
if (isset($versions)) {
sort($versions);
ArrayHelper::merge($parameters, $serializer->serializeValue('ver', $versions));
}
ksort($parameters);
$entryName = '';
foreach ($parameters as $name => $value) {
if ($entryName != '') {
$entryName .= '&';
}
$entryName .= $name . '=' . $value;
}
if (($request instanceof AbstractCubeQueryRequest) && isset($request->referencedRequests)) {
foreach ($request->referencedRequests as $referencedRequest) {
$referencedEntryName = $this->prepareCacheEntryName($referencedRequest);
$entryName .= '{' . $referencedEntryName . '}';
}
}
return $entryName;
}
示例7: render
public function render()
{
$sResult = FormHelper::textbox($this->getAlias(), htmlentities($this->getValue(), ENT_QUOTES, "utf-8"), \ArrayHelper::merge(array('class' => 'TextboxField', 'id' => 'field_' . $this->getAlias()), $this->getHtmlOptions()));
$sResult .= '<script type="text/javascript">
$(document).ready(function() {
$(\'#field_' . $this->getAlias() . '\').datetimepicker();
});
</script>';
echo $sResult;
}
示例8: parseArguments
/**
* Parses the arguments of a parametrized helper.
* Arguments can be specified as a single value, or as a string in JSON format.
* @param string $text The section content specifying the helper arguments.
* @param string $defaultArgument The name of the default argument. This is used when the section content provides a plain string instead of a JSON object.
* @param array $defaultValues The default values of arguments. These are used when the section content does not specify all arguments.
* @return array The parsed arguments as an associative array.
*/
protected function parseArguments(string $text, string $defaultArgument, array $defaultValues = []) : array
{
try {
if (is_array($json = Json::decode($text))) {
return ArrayHelper::merge($defaultValues, $json);
}
throw new InvalidParamException();
} catch (InvalidParamException $e) {
$defaultValues[$defaultArgument] = $text;
return $defaultValues;
}
}
示例9: ckeditorOptions
public static function ckeditorOptions($controller, $options = [])
{
if (is_array($controller)) {
$id = $controller[0];
unset($controller[0]);
$params = $controller;
} else {
$id = $controller;
$params = [];
}
return ArrayHelper::merge(['filebrowserBrowseUrl' => self::getManagerUrl($id, $params), 'filebrowserImageBrowseUrl' => self::getManagerUrl($id, ArrayHelper::merge($params, ['filter' => 'image'])), 'filebrowserFlashBrowseUrl' => self::getManagerUrl($id, ArrayHelper::merge($params, ['filter' => 'flash']))], $options);
}
示例10: rules
public function rules()
{
$trim = [];
if (Yii::$app->cmgCore->trimFieldValue) {
$trim[] = [['widget', 'widgetId', 'options', 'icon', 'order'], 'filter', 'filter' => 'trim', 'skipOnArray' => true];
}
$rules = [[['widget', 'widgetId', 'options', 'icon', 'order'], 'safe'], ['order', 'number', 'integerOnly' => true]];
if (Yii::$app->cmgCore->trimFieldValue) {
return ArrayHelper::merge($trim, $rules);
}
return $rules;
}
示例11: actionList
/**
* List action: list of elements
*
* @param array $aParams array of input params
* @return ActionResponse
*/
public function actionList($aParams = array())
{
$aConfig = $this->config('List');
$limit = 10;
$aFindParams = array();
if (count($aParams) && $this->sMapperAlias) {
foreach ($aParams as $key => $param) {
if ($this->mapper()->isRealFieldExists($key)) {
$aFindParams['Criteria'][$key] = $param;
}
}
}
$page = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
$aFindParams['Limit'] = $limit;
$aFindParams['Offset'] = $page * $limit;
$sort_field = isset($_GET['sort_field']) ? $_GET['sort_field'] : 'Id';
$sort_direction = isset($_GET['sort_direction']) ? $_GET['sort_direction'] : 'ASC';
$aFindParams['Order'] = array();
//echo '<pre>', print_r($aFindParams, true), '</pre>'; die();
if (isset($aConfig['Component']['FindParams'])) {
$aFindParams = ArrayHelper::merge($aFindParams, $aConfig['Component']['FindParams']);
}
if (!count($aFindParams['Order'])) {
$aFindParams['Order'] = array($sort_field => $sort_direction);
}
$mResult = false;
if ($aConfig) {
if (!isset($aConfig['View']) || isset($aConfig['View']) && $aConfig['View'] != false) {
$mResult = $this->view(array(), $aConfig['View']);
} else {
if (isset($aConfig['Component'])) {
$sComponentModule = $aConfig['Component']['Component'][0];
$sComponentAlias = $aConfig['Component']['Component'][1];
$aComponentParams = isset($aConfig['Component']['Params']) ? $aConfig['Component']['Params'] : array();
// Проверка доступа
$this->checkActionAccess('List');
$aComponentParams['Data'] = $this->getListData($aFindParams);
$count = $this->getListDataCount($aFindParams);
$oPagination = new Pagination($count);
$oPagination->setPageSize($aFindParams['Limit']);
$oPagination->applyLimit(@$aFindParams['Criteria']);
$aComponentParams['Pagination'] = $oPagination;
$mResult = $this->component($sComponentModule, $sComponentAlias, $aComponentParams);
} else {
$mResult = false;
}
}
} else {
$mResult = $this->view('List');
}
return $mResult;
}
示例12: executeScriptFunction
protected function executeScriptFunction(DatasetMetaData $dataset, $functionName, array $parameters = NULL) {
$environment_metamodel = data_controller_get_environment_metamodel();
$datasource = $environment_metamodel->getDataSource($dataset->datasourceName);
// preparing URI
$uri = $datasource->protocol . '://' . $datasource->host . (isset($datasource->port) ? (':' . $datasource->port) : '') . $datasource->path;
// preparing query parameters
$queryParameters = NULL;
$queryParameters[self::PARAMETER_NAME__OPERATION] = $functionName;
$queryParameters[DataQueryControllerUIParameterNames::DATASET] = $dataset->name;
// preparing server callback name
$queryParameters[self::PARAMETER_NAME__CALLBACK_SERVER_NAME] = $this->callbackServerName;
// preparing version
$scriptFileName = data_controller_script_get_script_file_name($dataset);
$selectedVersion = data_controller_script_prepare_version($dataset, $scriptFileName);
if (isset($selectedVersion)) {
$queryParameters[DataQueryControllerUIParameterNames::PARAMETER_NAME__DATASET_VERSION] = $selectedVersion;
}
ArrayHelper::merge($queryParameters, $parameters);
// preparing CURL request
$curlProxy = $this->initiateCURLProxy($uri);
$handler = $curlProxy->initializeHandler('GET', '/dp_datasource_integration.py', $queryParameters);
// executing the request in single thread environment
$executor = new SingleCURLHandlerExecutor($handler);
$output = $executor->execute();
$records = NULL;
if (isset($output)) {
try {
$records = json_decode($output, TRUE);
if (isset($records)) {
if (count($records) == 0) {
$records = NULL;
}
}
else {
throw new IllegalStateException(t(
'Error occurred during execution of a script for the dataset: %datasetName',
array('%datasetName' => $dataset->publicName)));
}
}
catch (Exception $e) {
LogHelper::log_debug(new PreservedTextMessage($output));
throw $e;
}
}
return $records;
}
示例13: log
public function log($level, &$message) {
if ($message instanceof StatementLogMessage) {
$statementLogMessage = $message;
$statements = &drupal_static(__CLASS__ . '::statements');
if (is_array($statementLogMessage->statement)) {
ArrayHelper::merge($statements, $statementLogMessage->statement);
}
else {
$statements[$statementLogMessage->type][] = $statementLogMessage->statement;
}
}
}
示例14: initiateHandler
public function initiateHandler($operatorName) {
$values = func_get_args();
array_shift($values);
$handlerConfiguration = $this->getHandlerConfiguration($operatorName);
$classname = $handlerConfiguration['handler']['classname'];
$handlerClass = new ReflectionClass($classname);
$params = NULL;
// first parameter is the operator configuration
$operatorMetaData = $this->getOperatorMetaData($operatorName);
$params[] = $operatorMetaData;
// next are parameters which represent values
if ((count($values) === 1) && is_array($values[0])) {
$parameterCount = count($values[0]);
$expectedMinimumParameterCount = $expectedTotalParameterCount = 0;
if (isset($operatorMetaData)) {
$operatorParameters = $operatorMetaData->getParameters();
if (isset($operatorParameters)) {
$expectedTotalParameterCount = count($operatorParameters);
foreach ($operatorParameters as $operatorParameter) {
if ($operatorParameter->required) {
$expectedMinimumParameterCount++;
}
}
}
}
if ($parameterCount == $expectedTotalParameterCount) {
ArrayHelper::merge($params, $values[0]);
}
elseif ($expectedTotalParameterCount === 1) {
$params[] = $values[0];
}
elseif (($parameterCount < $expectedTotalParameterCount) && ($parameterCount >= $expectedMinimumParameterCount)) {
// we have some optional parameters which do not need to be provided
ArrayHelper::merge($params, $values[0]);
}
else {
throw new IllegalArgumentException(t('Inconsistent number of arguments for %name operator', array('%name' => $operatorName)));
}
}
else {
ArrayHelper::merge($params, $values);
}
return $handlerClass->newInstanceArgs($params);
}
示例15: serialize
public function serialize(AbstractQueryRequest $request) {
$parameters = parent::serialize($request);
// serializing column names
if (isset($request->columns)) {
ArrayHelper::merge(
$parameters,
$this->serializeValue(
DataQueryControllerUIParameterNames::COLUMNS,
DataQueryControllerUIRequestPreparer::prepareColumns($request->columns)));
}
return $parameters;
}