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))); }
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; }
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; }
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; }
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); }
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; }
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; }
/** * 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; } }
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); }
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; }
/** * 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; }
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; }
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; } } }
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); }
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; }
/** * Returns a function translating a message. * @return \Closure A function translating a message. * @throws InvalidCallException The specified message has an invalid format. */ public function getTranslate() : \Closure { return function ($value, \Mustache_LambdaHelper $helper) { $defaultCategory = $this->getDefaultCategory(); $defaultArgs = ['category' => $defaultCategory, 'language' => null, 'params' => []]; $output = trim($value); $isJSON = mb_substr($output, 0, 1) == '{' && mb_substr($output, mb_strlen($output) - 1) == '}'; if ($isJSON) { $args = $this->parseArguments($helper->render($value), 'message', $defaultArgs); } else { $parts = explode($this->getArgumentSeparator(), $output, 2); $length = count($parts); if (!$length) { throw new InvalidCallException('Invalid translation format.'); } $args = ArrayHelper::merge($defaultArgs, ['category' => $length == 1 ? $defaultCategory : $parts[0], 'message' => $parts[$length - 1]]); } return \Yii::t($args['category'], $args['message'], $args['params'], $args['language']); }; }
/** * 把Hint放到Input下面 * @inheritdoc */ protected function createLayoutConfig($instanceConfig) { $config = ['hintOptions' => ['tag' => 'p', 'class' => 'help-block'], 'errorOptions' => ['tag' => 'p', 'class' => 'help-block help-block-error'], 'inputOptions' => ['class' => 'form-control']]; $layout = $instanceConfig['form']->layout; if ($layout === 'horizontal') { $config['template'] = "{label}\n{beginWrapper}\n{input}\n{hint}\n{endWrapper}\n{error}"; $cssClasses = ['offset' => 'col-sm-offset-3', 'label' => 'col-sm-3', 'wrapper' => 'col-sm-6', 'error' => '', 'hint' => '']; if (isset($instanceConfig['horizontalCssClasses'])) { $cssClasses = ArrayHelper::merge($cssClasses, $instanceConfig['horizontalCssClasses']); } $config['horizontalCssClasses'] = $cssClasses; $config['wrapperOptions'] = ['class' => $cssClasses['wrapper']]; $config['labelOptions'] = ['class' => 'control-label ' . $cssClasses['label']]; $config['errorOptions'] = ['class' => 'help-block help-block-error ' . $cssClasses['error']]; $config['hintOptions'] = ['class' => 'help-block ' . $cssClasses['hint']]; } elseif ($layout === 'inline') { $config['labelOptions'] = ['class' => 'sr-only']; $config['enableError'] = false; } return $config; }
protected function serialize(AbstractQueryRequest $request) { $parameters = parent::serialize($request); // serializing query parameters if (isset($request->queries)) { foreach ($request->queries as $index => $query) { $parameterName = DataQueryControllerUIParameterNames::PARAMETERS; if ($index != 0) { $parameterName .= $index; } if (isset($query)) { $queryParameters = NULL; foreach ($query as $name => $value) { ArrayHelper::merge($queryParameters, DataQueryControllerUIRequestPreparer::prepareParameter($name, $value)); } ArrayHelper::merge($parameters, $this->serializeValue($parameterName, $queryParameters)); } } } return $parameters; }
/** * Updates an existing Dealership model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdatedealer($id) { $modelDealership = $this->findModel($id); $modelsShowroom = $modelDealership->Showroomes; if ($modelDealership->load(Yii::$app->request->post())) { $oldIDs = ArrayHelper::map($modelsShowroom, 'id', 'id'); $modelsShowroom = Model::createMultiple(Showroom::classname(), $modelsShowroom); Model::loadMultiple($modelsShowroom, Yii::$app->request->post()); $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsShowroom, 'id', 'id'))); // ajax validation if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ArrayHelper::merge(ActiveForm::validateMultiple($modelsShowroom), ActiveForm::validate($modelDealership)); } // validate all models $valid = $modelDealership->validate(); $valid = $modelDealeraccount->validate(); $valid = Model::validateMultiple($modelsShowroom) && $valid; if ($valid) { $transaction = \Yii::$app->db->beginTransaction(); try { if (($flag = $modelDealership->save(false)) && ($flag = $modelDealeraccount->save(false))) { if (!empty($deletedIDs)) { Showroom::deleteAll(['id' => $deletedIDs]); } foreach ($modelsShowroom as $modelShowroom) { $modelShowroom->Dealership_id = $modelDealership->id; if (!($flag = $modelShowroom->save(false))) { $transaction->rollBack(); break; } } } if ($flag) { $transaction->commit(); return $this->redirect(['view', 'id' => $modelDealership->id]); } } catch (Exception $e) { $transaction->rollBack(); } } } return $this->render('update', ['modelDealership' => $modelDealership, 'modelsShowroom' => empty($modelsShowroom) ? [new Showroom()] : $modelsShowroom, 'modelsService' => empty($modelsService) ? [new Service()] : $modelsService]); }
public function render() { echo FormHelper::textbox($this->getAlias(), htmlentities($this->getValue(), ENT_QUOTES, "utf-8"), \ArrayHelper::merge(array('class' => 'TextboxField', 'id' => 'field_' . $this->getAlias()), $this->getHtmlOptions())); }
public function fields() { return ArrayHelper::merge(parent::fields(), array('DataSource', 'TextFormat', 'ValueField')); }
/** * Renders a view file. * @param \yii\base\View $view The view object used for rendering the file. * @param string $file The view file. * @param array $params The parameters to be passed to the view file. * @return string The rendering result. * @throws InvalidCallException The specified view file is not found. */ public function render($view, $file, $params) : string { $cacheId = $this->getCacheId(); $cache = mb_strlen($cacheId) ? \Yii::$app->get($cacheId) : null; $cacheKey = static::CACHE_KEY_PREFIX . ":{$file}"; if ($cache && $cache->exists($cacheKey)) { $output = $cache[$cacheKey]; } else { $path = FileHelper::localize($file); if (!is_file($path)) { throw new InvalidCallException("View file \"{$file}\" does not exist."); } $output = @file_get_contents($path); if ($cache) { $cache->set($cacheKey, $output, $this->getCachingDuration()); } } $values = ArrayHelper::merge(['this' => $view], is_array($params) ? $params : []); return $this->engine->render($output, $values); }
public function combineFrom(ReferenceRoute $route) { ArrayHelper::merge($this->segmentLinkIds, $route->segmentLinkIds); $this->weight += $route->weight; }
/** * Prompts the user for input and validates it * * @param string $text prompt string * @param array $options the options to validate the input: * * - `required`: whether it is required or not * - `default`: default value if no input is inserted by the user * - `pattern`: regular expression pattern to validate user input * - `validator`: a callable function to validate input. The function must accept two parameters: * - `input`: the user input to validate * - `error`: the error value passed by reference if validation failed. * * @return string the user input */ public static function prompt($text, $options = []) { $options = ArrayHelper::merge(['required' => false, 'default' => null, 'pattern' => null, 'validator' => null, 'error' => 'Invalid input.'], $options); $error = null; top: $input = $options['default'] ? static::input("{$text} [" . $options['default'] . '] ') : static::input("{$text} "); if (!strlen($input)) { if (isset($options['default'])) { $input = $options['default']; } elseif ($options['required']) { static::output($options['error']); goto top; } } elseif ($options['pattern'] && !preg_match($options['pattern'], $input)) { static::output($options['error']); goto top; } elseif ($options['validator'] && !call_user_func_array($options['validator'], [$input, &$error])) { static::output(isset($error) ? $error : $options['error']); goto top; } return $input; }
public function fields() { return ArrayHelper::merge(parent::fields(), array('Auto', 'AutoFieldAlias')); }
/** * * @param <type> $sFunction * @param <type> $sAlias * @param <type> $mFunctionParams * @param <type> $aParams * @return <type> */ public function findStat($sFunction, $sAlias, $mFunctionParams = false, $aParams = array()) { $paramsDefault = $this->scopeActive ? $this->scopeActive : $this->defaultScope(); $aParams = ArrayHelper::merge($paramsDefault, $aParams); $this->scopeActive = false; $sClassName = $this->sModelAlias; $oQuery = new DbFetcher($this->tableName(), $sClassName, $this->getDbConnectionAlias()); // Eager fetching if (isset($aParams['With'])) { } $oQuery->addSelectField($mFunctionParams, $sAlias, $sFunction, $mFunctionParams); // Условия выборки if (isset($aParams['Criteria']) && is_object($aParams['Criteria'])) { $oQuery->addCriteria($aParams['Criteria']->renderWhere()); } if (isset($aParams['Criteria']) && is_array($aParams['Criteria']) && count($aParams['Criteria']) > 0) { $oCriteria = new CriteriaGroup('AND'); foreach ($aParams['Criteria'] as $k => $itm) { if (is_object($itm)) { $oCriteria->addElement($itm); } else { if (is_array($itm)) { $oCriteria->addElement(new CriteriaElement($k, $itm['Type'], $itm['Value'])); } else { $oCriteria->addElement(new CriteriaElement($k, '=', $itm)); } } } $oQuery->addCriteria($this->parseFindCriteria($oCriteria->renderWhere())); } // Лимит выборки $oQuery->setLimit(1); // Смещение выборки $oQuery->setOffset(0); // Сортировка if (isset($aParams['Order']) && is_array($aParams['Order']) && count($aParams['Order']) > 0) { foreach ($aParams['Order'] as $k => $itm) { $oQuery->addOrder($this->parseFindField($k), $itm); } } if (isset($aParams['Group']) && is_array($aParams['Group']) && count($aParams['Group']) > 0) { foreach ($aParams['Group'] as $k => $itm) { $oQuery->addGroup($itm); } } if (isset($aParams['With']) && is_array($aParams['With']) && count($aParams['With'])) { foreach ($aParams['With'] as $k => $rel) { $oRelation = false; $aLocalParams = array(); if (is_array($rel)) { $oRelation = $this->oRelations->get($k); $aLocalParams = $rel; } else { if (is_string($rel)) { $oRelation = $this->oRelations->get($rel); } } if ($oRelation) { $oQuery = $oRelation->eagerFetching($oQuery, $this, $sClassName, $aParams, $aLocalParams); } } } $mResult = $oQuery->fetchCell(); return $mResult; }
/** * Creates a URL by using the current route and the GET parameters. * * You may modify or remove some of the GET parameters, or add additional query parameters through * the `$params` parameter. In particular, if you specify a parameter to be null, then this parameter * will be removed from the existing GET parameters; all other parameters specified in `$params` will * be merged with the existing GET parameters. For example, * * ```php * // assume $_GET = ['id' => 123, 'src' => 'google'], current route is "post/view" * * // /index.php?r=post/view&id=123&src=google * echo Url::current(); * * // /index.php?r=post/view&id=123 * echo Url::current(['src' => null]); * * // /index.php?r=post/view&id=100&src=google * echo Url::current(['id' => 100]); * ``` * * @param array $params an associative array of parameters that will be merged with the current GET parameters. * If a parameter value is null, the corresponding GET parameter will be removed. * @param boolean|string $scheme the URI scheme to use in the generated URL: * * - `false` (default): generating a relative URL. * - `true`: returning an absolute base URL whose scheme is the same as that in [[\Leaps\Web\UrlManager::hostInfo]]. * - string: generating an absolute URL with the specified scheme (either `http` or `https`). * * @return string the generated URL * @since 2.0.3 */ public static function current(array $params = [], $scheme = false) { $currentParams = Leaps::$app->getRequest()->getQueryParams(); $currentParams[0] = '/' . Leaps::$app->controller->getRoute(); $route = ArrayHelper::merge($currentParams, $params); return static::toRoute($route, $scheme); }
public function fields() { return ArrayHelper::merge(parent::fields(), array('UploadUrl', 'BucketName')); }
public function defaultValues() { return ArrayHelper::merge(parent::defaultValues(), array('IsTree' => false)); }
public function merge(Statement $statement) { ArrayHelper::merge($this->tables, $statement->tables); ArrayHelper::merge($this->conditions, $statement->conditions); ArrayHelper::merge($this->groupByColumns, $statement->groupByColumns); ArrayHelper::merge($this->havingConditions, $statement->havingConditions); }