本文整理汇总了PHP中ArrayHelper类的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper类的具体用法?PHP ArrayHelper怎么用?PHP ArrayHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sendMessage
/**
* Sends an email submitted through a contact form.
*
* @param ContactFormModel $message
* @throws Exception
* @return bool
*/
public function sendMessage(ContactFormModel $message)
{
$settings = craft()->plugins->getPlugin('contactform')->getSettings();
if (!$settings->toEmail) {
throw new Exception('The "To Email" address is not set on the plugin’s settings page.');
}
// Fire an 'onBeforeSend' event
Craft::import('plugins.contactform.events.ContactFormEvent');
$event = new ContactFormEvent($this, array('message' => $message));
$this->onBeforeSend($event);
if ($event->isValid) {
if (!$event->fakeIt) {
$toEmails = ArrayHelper::stringToArray($settings->toEmail);
foreach ($toEmails as $toEmail) {
$email = new EmailModel();
$emailSettings = craft()->email->getSettings();
$email->fromEmail = $emailSettings['emailAddress'];
$email->replyTo = $message->fromEmail;
$email->sender = $emailSettings['emailAddress'];
$email->fromName = $settings->prependSender . ($settings->prependSender && $message->fromName ? ' ' : '') . $message->fromName;
$email->toEmail = $toEmail;
$email->subject = $settings->prependSubject . ($settings->prependSubject && $message->subject ? ' - ' : '') . $message->subject;
$email->body = $message->message;
if ($message->attachment) {
$email->addAttachment($message->attachment->getTempName(), $message->attachment->getName(), 'base64', $message->attachment->getType());
}
craft()->email->sendEmail($email);
}
}
return true;
}
return false;
}
开发者ID:besimhu,项目名称:CraftCMS-Boilerplate,代码行数:40,代码来源:ContactFormService.php
示例2: generate
public function generate(array $possiblyLinkableDatasetNames = NULL) {
$adjustedPossiblyLinkableDatasetNames = NULL;
if (isset($possiblyLinkableDatasetNames)) {
foreach ($possiblyLinkableDatasetNames as $possiblyLinkableDatasetName) {
$adjustedPossiblyLinkableDatasetName = $this->adjustDatasetName($possiblyLinkableDatasetName);
// we should not try to link with itself
if ($adjustedPossiblyLinkableDatasetName == $this->primaryDatasetName) {
continue;
}
ArrayHelper::addUniqueValue($adjustedPossiblyLinkableDatasetNames, $adjustedPossiblyLinkableDatasetName);
}
}
// preparing reference paths for all datasets which we need to test for possible linkage
$referencePaths = NULL;
if (isset($adjustedPossiblyLinkableDatasetNames)) {
foreach ($adjustedPossiblyLinkableDatasetNames as $adjustedPossiblyLinkableDatasetName) {
// column name should not be provided because we just try to link with the dataset
$referencePath = ReferencePathHelper::assembleReference($adjustedPossiblyLinkableDatasetName, NULL);
$referencePaths[$referencePath] = FALSE; // FALSE - if we cannot find link it is ok. Not everything could be connected
}
}
$linkBuilder = new ReferenceLinkBuilder();
$link = $linkBuilder->prepareReferenceBranches($this->primaryDatasetName, $referencePaths);
return $link;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:30,代码来源:ReferenceLinkView.php
示例3: 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
示例4: merge
public function merge(Statement $statement)
{
ArrayHelper::mergeArrays($this->tables, $statement->tables);
ArrayHelper::mergeArrays($this->conditions, $statement->conditions);
ArrayHelper::mergeArrays($this->groupByColumns, $statement->groupByColumns);
ArrayHelper::mergeArrays($this->havingConditions, $statement->havingConditions);
}
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:7,代码来源:Statement.php
示例5: registerRecordImpl
protected function registerRecordImpl(array &$records = NULL, $record) {
parent::registerRecordImpl($records, $record);
$recordKey = NULL;
foreach ($this->keyColumnNames as $keyColumnName) {
$recordKey[] = isset($record[$keyColumnName]) ? $record[$keyColumnName] : NULL;
}
$key = ArrayHelper::prepareCompositeKey($recordKey);
if (isset($records[$key])) {
if ($this->isColumnValueUnique) {
throw new IllegalArgumentException(t(
'Found several records for the key: %key',
array('%key' => ArrayHelper::serialize($recordKey, ', ', TRUE, TRUE))));
}
$records[$key][] = $record;
}
else {
if ($this->isColumnValueUnique) {
$records[$key] = $record;
}
else {
$records[$key][] = $record;
}
}
return TRUE;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:29,代码来源:QueryKeyResultFormatter.php
示例6: getRecipients
/**
* @param mixed|null $element
*
* @throws \Exception
* @return array|string
*/
public function getRecipients($element = null)
{
$recipientsString = $this->getAttribute('recipients');
// Possibly called from entry edit screen
if (is_null($element)) {
return $recipientsString;
}
// Previously converted to array somehow?
if (is_array($recipientsString)) {
return $recipientsString;
}
// Previously stored as JSON string?
if (stripos($recipientsString, '[') === 0) {
return JsonHelper::decode($recipientsString);
}
// Still a string with possible twig generator code?
if (stripos($recipientsString, '{') !== false) {
try {
$recipients = craft()->templates->renderObjectTemplate($recipientsString, $element);
return array_unique(ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::stringToArray($recipients)));
} catch (\Exception $e) {
throw $e;
}
}
// Just a regular CSV list
if (!empty($recipientsString)) {
return ArrayHelper::filterEmptyStringsFromArray(ArrayHelper::stringToArray($recipientsString));
}
return array();
}
开发者ID:aladrach,项目名称:Bluefoot-Craft-Starter,代码行数:36,代码来源:SproutEmail_EntryModel.php
示例7: testConstructAndGetAndSet
public function testConstructAndGetAndSet()
{
$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$ah = new ArrayHelper($array);
// Make sure we are not using by reference
$this->assertEquals(10, $ah->pop());
$this->assertEquals(10, $ah->pop());
// Make sure we are not using by reference
$this->assertEquals(1, $ah->shift());
$this->assertEquals(1, $ah->shift());
$ah->setMutable(true);
$this->assertEquals(1, $ah->shift());
$this->assertEquals(2, $ah->shift());
$ah->unshift(2, 1);
$this->assertEquals(1, $ah->shift());
}
开发者ID:seanyainkiranina,项目名称:completecontrol,代码行数:16,代码来源:arrayhelpertest.class.php
示例8: _attributesTo
protected static function _attributesTo($dimension, $modelData, $attributes = NULL)
{
$attributes = self::_parseMoneyAttributes($modelData, $attributes);
foreach ($attributes as $key => $attribute) {
$name = is_string($key) ? $key : $attribute;
if (empty($modelData[$name]) and !is_object($modelData) || empty($modelData->{$name})) {
continue;
}
$value = $modelData[$name];
if (is_array($attribute)) {
if (!ArrayHelper::isAssoc($attribute, true)) {
$modelData[$name] = self::_arrayTo($dimension, $value, $attribute);
} elseif (is_array($value) or is_object($value)) {
$modelData[$name] = self::_attributesTo($dimension, $value, $attribute);
} else {
$modelData[$name] = self::_to($dimension, $value);
}
} else {
if (is_array($value)) {
$modelData[$name] = self::_arrayTo($dimension, $value);
} else {
$modelData[$name] = self::_to($dimension, $value);
}
}
}
return $modelData;
}
开发者ID:bangkok,项目名称:CodeExample,代码行数:27,代码来源:MoneyFormat.php
示例9: 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;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:25,代码来源:AbstractDataSourceFactory.php
示例10: registerDatasetConfig
private function registerDatasetConfig(array &$datasetConfigs = NULL, $index, DatasetMetaData $dataset = NULL, $columnName = NULL, AbstractConditionSection $condition = NULL) {
if (isset($datasetConfigs[$index])) {
$datasetConfig = $datasetConfigs[$index];
}
else {
// TODO create a class
$datasetConfig = new stdClass();
$datasetConfig->dataset = NULL;
$datasetConfig->usedColumnNames = NULL;
$datasetConfig->conditions = NULL;
$datasetConfigs[$index] = $datasetConfig;
}
if (isset($dataset)) {
if (isset($datasetConfig->dataset)) {
if ($datasetConfig->dataset->name !== $dataset->name) {
throw new IllegalStateException(t(
'Inconsistent dataset configuration: [@datasetName, @tableDatasetName]',
array('@datasetName' => $dataset->publicName, '@tableDatasetName' => $datasetConfig->dataset->publicName)));
}
}
else {
$datasetConfig->dataset = $dataset;
}
}
if (isset($columnName)) {
ArrayHelper::addUniqueValue($datasetConfig->usedColumnNames, $columnName);
}
if (isset($condition)) {
$datasetConfig->conditions[] = $condition;
}
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:35,代码来源:DefaultQueryEngine.php
示例11: 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)));
}
开发者ID:ruxon,项目名称:framework,代码行数:29,代码来源:HasManyObjectRelation.class.php
示例12: prepareDataProvider
public function prepareDataProvider()
{
$params = \Yii::$app->request->queryParams;
//print_r($params);die();
$model = new $this->modelClass();
// I'm using yii\base\Model::getAttributes() here
// In a real app I'd rather properly assign
// $model->scenario then use $model->safeAttributes() instead
$modelAttr = $model->attributes;
// this will hold filtering attrs pairs ( 'name' => 'value' )
$search = [];
if (!empty($params)) {
foreach ($params as $key => $value) {
// In case if you don't want to allow wired requests
// holding 'objects', 'arrays' or 'resources'
if (!is_scalar($key) or !is_scalar($value)) {
throw new BadRequestHttpException('Bad Request');
}
// if the attr name is not a reserved Keyword like 'q' or 'sort' and
// is matching one of models attributes then we need it to filter results
if (!in_array(strtolower($key), $this->reservedParams) && ArrayHelper::keyExists($key, $modelAttr, false)) {
$search[$key] = $value;
}
}
}
// you may implement and return your 'ActiveDataProvider' instance here.
// in my case I prefer using the built in Search Class generated by Gii which is already
// performing validation and using 'like' whenever the attr is expecting a 'string' value.
$searchByAttr['ProductSearch'] = $search;
$lat = isset($params['lat']) ? $params['lat'] : 18.509111;
$lon = isset($params['lon']) ? $params['lon'] : -69.8468487;
$model = new Categorias();
$searchModel = $model->find()->all();
return $searchModel;
}
开发者ID:alejandrososa,项目名称:AB,代码行数:35,代码来源:CategoriaController.php
示例13: formatRecord
public function formatRecord(array &$records = NULL, $record)
{
$result = parent::formatRecord($records, $record);
if ($result) {
$this->errorUnsupportedChainOfResultFormatters();
}
$recordKey = NULL;
foreach ($this->keyColumnNames as $columnName) {
$recordKey[] = isset($record[$columnName]) ? $record[$columnName] : NULL;
}
$key = ArrayHelper::prepareCompositeKey($recordKey);
if (isset($records[$key])) {
if ($this->isColumnValueUnique) {
throw new IllegalArgumentException(t('Found several records for the key: @key', array('@key' => ArrayHelper::printArray($recordKey, ', ', TRUE, TRUE))));
}
$records[$key][] = $record;
} else {
if ($this->isColumnValueUnique) {
$records[$key] = $record;
} else {
$records[$key][] = $record;
}
}
return TRUE;
}
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:25,代码来源:QueryKeyResultFormatter.php
示例14: assemble
public function assemble(AbstractSQLDataSourceQueryHandler $datasourceHandler, DataControllerCallContext $callcontext, DatasetMetaData $dataset, array $columnNames = NULL)
{
$statement = new Statement();
$requestedColumnNames = self::prepareRequestedColumnNames($columnNames);
ArrayHelper::mergeArrays($statement->tables, self::prepareTableSections4Statement($datasourceHandler, $callcontext, $requestedColumnNames, TRUE));
return $statement;
}
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:7,代码来源:DateDimensionYearDatasetAssembler.php
示例15: collectReferencedFormulaNames
protected function collectReferencedFormulaNames(AbstractQueryRequest $request) {
$usedFormulaNames = NULL;
// checking dimensions
if (isset($request->dimensions)) {
foreach ($request->dimensions as $dimension) {
$dimensionName = $dimension->name;
if ($request->findFormula($dimensionName) != NULL) {
ArrayHelper::addUniqueValue($usedFormulaNames, $dimensionName);
}
}
}
// checking measures
if (isset($request->measures)) {
foreach ($request->measures as $measure) {
$measureName = $measure->name;
if ($request->findFormula($measureName) != NULL) {
ArrayHelper::addUniqueValue($usedFormulaNames, $measureName);
}
}
}
// checking conditions
if (isset($request->queries)) {
foreach ($request->queries as $query) {
$name = $query->name;
if ($request->findFormula($name) != NULL) {
ArrayHelper::addUniqueValue($usedFormulaNames, $name);
}
}
}
return $usedFormulaNames;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:33,代码来源:TotalInFormulaExpressionCubeRequestProcessor.php
示例16: prepValue
/**
* @inheritDoc IFieldType::prepValue()
*
* @param mixed $value
*
* @return mixed
*/
public function prepValue($value)
{
$selectedValues = ArrayHelper::stringToArray($value);
if ($this->multi) {
if (is_array($value)) {
// Convert all the values to OptionData objects
foreach ($value as &$val) {
$label = $this->getOptionLabel($val);
$val = new OptionData($label, $val, true);
}
} else {
$value = array();
}
$value = new MultiOptionsFieldData($value);
} else {
// Convert the value to a SingleOptionFieldData object
$label = $this->getOptionLabel($value);
$value = new SingleOptionFieldData($label, $value, true);
}
$options = array();
foreach ($this->getOptions() as $option) {
$selected = in_array($option['value'], $selectedValues);
$options[] = new OptionData($option['label'], $option['value'], $selected);
}
$value->setOptions($options);
return $value;
}
开发者ID:kant312,项目名称:sop,代码行数:34,代码来源:BaseOptionsFieldType.php
示例17: collectReferencedFormulaNames
protected function collectReferencedFormulaNames(AbstractQueryRequest $request) {
$usedFormulaNames = NULL;
// checking conditions
if (isset($request->queries)) {
foreach ($request->queries as $index => $query) {
foreach ($query as $columnName => $values) {
if ($request->findFormula($columnName) != NULL) {
ArrayHelper::addUniqueValue($usedFormulaNames, $columnName);
}
}
}
}
// checking columns
if ($request instanceof DatasetQueryRequest) {
if (isset($request->columns)) {
foreach ($request->columns as $columnName) {
if ($request->findFormula($columnName) != NULL) {
ArrayHelper::addUniqueValue($usedFormulaNames, $columnName);
}
}
}
}
return $usedFormulaNames;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:26,代码来源:TotalInFormulaExpressionDatasetRequestProcessor.php
示例18: 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 = isset($operatorMetaData) ? $operatorMetaData->getRequiredParameterCount() : 0;
$expectedTotalParameterCount = isset($operatorMetaData) ? $operatorMetaData->getParameterCount() : 0;
if ($parameterCount == $expectedTotalParameterCount) {
ArrayHelper::mergeArrays($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::mergeArrays($params, $values[0]);
} else {
throw new IllegalArgumentException(t("Inconsistent number of arguments for '@name' operator", array('@name' => $operatorName)));
}
} else {
ArrayHelper::mergeArrays($params, $values);
}
return $handlerClass->newInstanceArgs($params);
}
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:31,代码来源:DefaultOperatorFactory.php
示例19: __clone
public function __clone() {
parent::__clone();
$this->datasets = ArrayHelper::copy($this->datasets);
$this->references = ArrayHelper::copy($this->references);
$this->cubes = ArrayHelper::copy($this->cubes);
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:7,代码来源:MetaModel.php
示例20: processMetaModelFilters
protected function processMetaModelFilters(array &$processedFilters = NULL, array $filters = NULL)
{
if (!isset($filters)) {
return;
}
foreach ($filters as $className => $properties) {
foreach ($properties as $propertyName => $values) {
$uniqueValues = isset($processedFilters[$className][$propertyName]) ? $processedFilters[$className][$propertyName] : NULL;
if ($uniqueValues === FALSE) {
// this property should be ignored
} else {
foreach ($values as $value) {
if (isset($value)) {
ArrayHelper::addUniqueValue($uniqueValues, $value);
} else {
// if there is at least one NULL value we ignore the property completely
$uniqueValues = FALSE;
break;
}
}
}
$processedFilters[$className][$propertyName] = $uniqueValues;
}
}
}
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:25,代码来源:AbstractMetaModelFactory.php
注:本文中的ArrayHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论