当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayUtils::clean方法代码示例

本文整理汇总了PHP中DreamFactory\Library\Utility\ArrayUtils::clean方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::clean方法的具体用法?PHP ArrayUtils::clean怎么用?PHP ArrayUtils::clean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DreamFactory\Library\Utility\ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils::clean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Create a new DynamoDb
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings = [])
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config'));
     //  Replace any private lookups
     Session::replaceLookups($config, true);
     // statically assign our supported version
     $config['version'] = '2012-08-10';
     if (isset($config['key'])) {
         $config['credentials']['key'] = $config['key'];
     }
     if (isset($config['secret'])) {
         $config['credentials']['secret'] = $config['secret'];
     }
     // set up a default table schema
     $parameters = ArrayUtils::clean(ArrayUtils::get($config, 'parameters'));
     Session::replaceLookups($parameters);
     if (null !== ($table = ArrayUtils::get($parameters, 'default_create_table'))) {
         $this->defaultCreateTable = $table;
     }
     try {
         $this->dbConn = new DynamoDbClient($config);
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("AWS DynamoDb Service Exception:\n{$ex->getMessage()}", $ex->getCode());
     }
 }
开发者ID:pkdevboxy,项目名称:df-aws,代码行数:34,代码来源:DynamoDb.php

示例2: __construct

 /**
  * Create a new CouchDbSvc
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings = [])
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config'));
     Session::replaceLookups($config, true);
     $dsn = strval(ArrayUtils::get($config, 'dsn'));
     if (empty($dsn)) {
         $dsn = 'http://localhost:5984';
     }
     $options = [];
     if (isset($config['options'])) {
         $options = $config['options'];
     }
     $db = isset($options['db']) ? $options['db'] : null;
     if (!isset($db)) {
         //  Attempt to find db in connection string
         $temp = trim(strstr($dsn, '//'), '/');
         $db = strstr($temp, '/');
         $db = trim($db, '/');
     }
     if (empty($db)) {
         $db = 'default';
     }
     try {
         $this->dbConn = @new \couchClient($dsn, $db, $options);
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("CouchDb Service Exception:\n{$ex->getMessage()}");
     }
 }
开发者ID:rajeshpillai,项目名称:df-couchdb,代码行数:37,代码来源:CouchDb.php

示例3: __construct

 /**
  * Create a new SqlDbSvc
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings = [])
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config'));
     Session::replaceLookups($config, true);
     $driver = isset($config['driver']) ? $config['driver'] : null;
     $this->dbConn = ConnectionFactory::createConnection($driver, $config);
     $this->dbConn->setCache($this);
     $this->dbConn->setExtraStore($this);
     $defaultSchemaOnly = ArrayUtils::getBool($config, 'default_schema_only');
     $this->dbConn->setDefaultSchemaOnly($defaultSchemaOnly);
     switch ($this->dbConn->getDBName()) {
         case SqlDbDriverTypes::MYSQL:
         case SqlDbDriverTypes::MYSQLI:
             $this->dbConn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
             break;
         case SqlDbDriverTypes::DBLIB:
             $this->dbConn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             break;
     }
     $attributes = ArrayUtils::clean(ArrayUtils::get($settings, 'attributes'));
     if (!empty($attributes)) {
         $this->dbConn->setAttributes($attributes);
     }
 }
开发者ID:rajeshpillai,项目名称:df-sqldb,代码行数:33,代码来源:SqlDb.php

示例4: getCacheKeys

 /**
  *
  * @return array The array of cache keys associated with this service
  */
 protected function getCacheKeys()
 {
     if (empty($this->cacheKeys)) {
         $this->cacheKeys = Cache::get($this->cachePrefix . 'cache_keys', []);
     }
     return ArrayUtils::clean($this->cacheKeys);
 }
开发者ID:df-arif,项目名称:df-core,代码行数:11,代码来源:Cacheable.php

示例5: __construct

 /**
  * Create a new AzureTablesSvc
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings = array())
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config'));
     Session::replaceLookups($config, true);
     $dsn = strval(ArrayUtils::get($config, 'connection_string'));
     if (empty($dsn)) {
         $name = ArrayUtils::get($config, 'account_name', ArrayUtils::get($config, 'AccountName'));
         if (empty($name)) {
             throw new \InvalidArgumentException('WindowsAzure account name can not be empty.');
         }
         $key = ArrayUtils::get($config, 'account_key', ArrayUtils::get($config, 'AccountKey'));
         if (empty($key)) {
             throw new \InvalidArgumentException('WindowsAzure account key can not be empty.');
         }
         $protocol = ArrayUtils::get($config, 'protocol', 'https');
         $dsn = "DefaultEndpointsProtocol={$protocol};AccountName={$name};AccountKey={$key}";
     }
     // set up a default partition key
     $partitionKey = ArrayUtils::get($config, static::PARTITION_KEY);
     if (!empty($partitionKey)) {
         $this->defaultPartitionKey = $partitionKey;
     }
     try {
         $this->dbConn = ServicesBuilder::getInstance()->createTableService($dsn);
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("Windows Azure Table Service Exception:\n{$ex->getMessage()}");
     }
 }
开发者ID:rajeshpillai,项目名称:df-azure,代码行数:37,代码来源:Table.php

示例6: __construct

 /**
  * Create a new SqlDbSvc
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings = [])
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config'));
     $this->cacheEnabled = ArrayUtils::getBool($config, 'cache_enabled');
     $this->cacheTTL = intval(ArrayUtils::get($config, 'cache_ttl', \Config::get('df.default_cache_ttl')));
     $this->cachePrefix = 'service_' . $this->id . ':';
 }
开发者ID:pkdevboxy,项目名称:df-core,代码行数:16,代码来源:BaseDbService.php

示例7: __construct

 /**
  * Create a new Script Service
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings = [])
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config'));
     Session::replaceLookups($config, true);
     if (null === ($this->content = ArrayUtils::get($config, 'content', null, true))) {
         throw new \InvalidArgumentException('Script content can not be empty.');
     }
     if (null === ($this->engineConfig = ArrayUtils::get($config, 'engine', null, true))) {
         throw new \InvalidArgumentException('Script engine configuration can not be empty.');
     }
     $this->scriptConfig = ArrayUtils::clean(ArrayUtils::get($config, 'config', [], true));
 }
开发者ID:rajeshpillai,项目名称:df-core,代码行数:21,代码来源:Script.php

示例8: retrieveRecordsByFilter

 /**
  * {@inheritdoc}
  */
 public function retrieveRecordsByFilter($table, $filter = null, $params = [], $extras = [])
 {
     $fields = ArrayUtils::get($extras, ApiOptions::FIELDS);
     $ssFilters = ArrayUtils::get($extras, 'ss_filters');
     $scanProperties = [static::TABLE_INDICATOR => $table];
     $fields = static::buildAttributesToGet($fields);
     if (!empty($fields)) {
         $scanProperties['AttributesToGet'] = $fields;
     }
     $parsedFilter = static::buildCriteriaArray($filter, $params, $ssFilters);
     if (!empty($parsedFilter)) {
         $scanProperties['ScanFilter'] = $parsedFilter;
     }
     $limit = intval(ArrayUtils::get($extras, ApiOptions::LIMIT));
     if ($limit > 0) {
         $scanProperties['Limit'] = $limit;
         $scanProperties['Count'] = true;
     }
     $offset = intval(ArrayUtils::get($extras, ApiOptions::OFFSET));
     if ($offset > 0) {
         $scanProperties['ExclusiveStartKey'] = $offset;
         $scanProperties['Count'] = true;
     }
     try {
         $result = $this->parent->getConnection()->scan($scanProperties);
         $items = ArrayUtils::clean($result['Items']);
         $out = [];
         foreach ($items as $item) {
             $out[] = $this->unformatAttributes($item);
         }
         $next = $this->unformatAttributes($result['LastEvaluatedKey']);
         $next = current($next);
         // todo handle more than one index here.
         $count = $result['Count'];
         $out = static::cleanRecords($out);
         $needMore = $count - $offset > $limit;
         $addCount = ArrayUtils::getBool($extras, ApiOptions::INCLUDE_COUNT);
         if ($addCount || $needMore) {
             $out['meta']['count'] = $count;
             if ($needMore) {
                 $out['meta']['next'] = $next;
             }
         }
         return $out;
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("Failed to filter records from '{$table}'.\n{$ex->getMessage()}");
     }
 }
开发者ID:pkdevboxy,项目名称:df-aws,代码行数:51,代码来源:DynamoDbTable.php

示例9: __construct

 /**
  * Create a new RemoteWebService
  *
  * @param array $settings settings array
  *
  * @throws \InvalidArgumentException
  */
 public function __construct($settings)
 {
     parent::__construct($settings);
     $this->autoDispatch = false;
     $this->query = '';
     $this->cacheQuery = '';
     $config = ArrayUtils::get($settings, 'config', []);
     $this->baseUrl = ArrayUtils::get($config, 'base_url');
     // Validate url setup
     if (empty($this->baseUrl)) {
         throw new \InvalidArgumentException('Remote Web Service base url can not be empty.');
     }
     $this->parameters = ArrayUtils::clean(ArrayUtils::get($config, 'parameters', []));
     $this->headers = ArrayUtils::clean(ArrayUtils::get($config, 'headers', []));
     $this->cacheEnabled = ArrayUtils::getBool($config, 'cache_enabled');
     $this->cacheTTL = intval(ArrayUtils::get($config, 'cache_ttl', Config::get('df.default_cache_ttl')));
     $this->cachePrefix = 'service_' . $this->id . ':';
 }
开发者ID:pkdevboxy,项目名称:df-rws,代码行数:25,代码来源:RemoteWeb.php

示例10: __construct

 /**
  * Create a new AwsSnsSvc
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings)
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config', []));
     //  Replace any private lookups
     Session::replaceLookups($config, true);
     // statically assign the our supported version
     $config['version'] = '2010-03-31';
     if (isset($config['key'])) {
         $config['credentials']['key'] = $config['key'];
     }
     if (isset($config['secret'])) {
         $config['credentials']['secret'] = $config['secret'];
     }
     try {
         $this->conn = new SnsClient($config);
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("AWS SNS Service Exception:\n{$ex->getMessage()}", $ex->getCode());
     }
     $this->region = ArrayUtils::get($config, 'region');
 }
开发者ID:pkdevboxy,项目名称:df-aws,代码行数:29,代码来源:Sns.php

示例11: getServiceFilters

 /**
  * @param string $action
  * @param string $service
  * @param string $component
  *
  * @returns bool
  */
 public static function getServiceFilters($action, $service, $component = null)
 {
     if (static::isSysAdmin()) {
         return [];
     }
     $services = ArrayUtils::clean(static::get('role.services'));
     $serviceAllowed = null;
     $serviceFound = false;
     $componentFound = false;
     $action = VerbsMask::toNumeric(static::cleanAction($action));
     foreach ($services as $svcInfo) {
         $tempService = ArrayUtils::get($svcInfo, 'service');
         if (null === ($tempVerbs = ArrayUtils::get($svcInfo, 'verb_mask'))) {
             //  Check for old verbs array
             if (null !== ($temp = ArrayUtils::get($svcInfo, 'verbs'))) {
                 $tempVerbs = VerbsMask::arrayToMask($temp);
             }
         }
         if (0 == strcasecmp($service, $tempService)) {
             $serviceFound = true;
             $tempComponent = ArrayUtils::get($svcInfo, 'component');
             if (!empty($component)) {
                 if (0 == strcasecmp($component, $tempComponent)) {
                     $componentFound = true;
                     if ($tempVerbs & $action) {
                         $filters = ArrayUtils::get($svcInfo, 'filters');
                         $operator = ArrayUtils::get($svcInfo, 'filter_op', 'AND');
                         if (empty($filters)) {
                             return null;
                         }
                         return ['filters' => $filters, 'filter_op' => $operator];
                     }
                 } elseif (empty($tempComponent) || '*' == $tempComponent) {
                     if ($tempVerbs & $action) {
                         $filters = ArrayUtils::get($svcInfo, 'filters');
                         $operator = ArrayUtils::get($svcInfo, 'filter_op', 'AND');
                         if (empty($filters)) {
                             return null;
                         }
                         $serviceAllowed = ['filters' => $filters, 'filter_op' => $operator];
                     }
                 }
             } else {
                 if (empty($tempComponent) || '*' == $tempComponent) {
                     if ($tempVerbs & $action) {
                         $filters = ArrayUtils::get($svcInfo, 'filters');
                         $operator = ArrayUtils::get($svcInfo, 'filter_op', 'AND');
                         if (empty($filters)) {
                             return null;
                         }
                         $serviceAllowed = ['filters' => $filters, 'filter_op' => $operator];
                     }
                 }
             }
         }
     }
     if ($componentFound) {
         // at least one service and component match was found, but not the right verb
         return null;
     } elseif ($serviceFound) {
         return $serviceAllowed;
     }
     return null;
 }
开发者ID:df-arif,项目名称:df-core,代码行数:71,代码来源:Session.php

示例12: handleEventScript

 /**
  * @param string $name
  * @param array  $event
  *
  * @return array|null
  * @throws InternalServerErrorException
  * @throws \DreamFactory\Core\Events\Exceptions\ScriptException
  */
 protected function handleEventScript($name, &$event)
 {
     $model = EventScript::with('script_type_by_type')->whereName($name)->whereIsActive(true)->first();
     if (!empty($model)) {
         $output = null;
         $result = ScriptEngineManager::runScript($model->content, $name, $model->script_type_by_type->toArray(), ArrayUtils::clean($model->config), $event, $output);
         //  Bail on errors...
         if (is_array($result) && isset($result['script_result'], $result['script_result']['error'])) {
             throw new InternalServerErrorException($result['script_result']['error']);
         }
         if (is_array($result) && isset($result['exception'])) {
             throw new InternalServerErrorException(ArrayUtils::get($result, 'exception', ''));
         }
         //  The script runner should return an array
         if (!is_array($result) || !isset($result['__tag__'])) {
             Log::error('  * Script did not return an array: ' . print_r($result, true));
         }
         if (!empty($output)) {
             Log::info('  * Script "' . $name . '" output:' . PHP_EOL . $output . PHP_EOL);
         }
         return $result;
     }
     return null;
 }
开发者ID:df-arif,项目名称:df-core,代码行数:32,代码来源:ServiceEventHandler.php

示例13: initializeLibraryPaths

 /**
  * @param array $libraryPaths
  *
  * @throws ServiceUnavailableException
  */
 protected static function initializeLibraryPaths($libraryPaths = null)
 {
     static::$libraryPaths = \Cache::get('scripting.library_paths', []);
     static::$libraries = \Cache::get('scripting.libraries', []);
     //  Add ones from constructor
     $libraryPaths = ArrayUtils::clean($libraryPaths);
     //  Application storage script path
     $libraryPaths[] = storage_path('scripting');
     //  Merge in config libraries...
     $libraryPaths = array_merge($libraryPaths, ArrayUtils::clean(\Config::get('df.scripting.paths', [])));
     //  Add them to collection if valid
     if (is_array($libraryPaths)) {
         foreach ($libraryPaths as $path) {
             if (!in_array($path, static::$libraryPaths)) {
                 if (!empty($path) || is_dir($path) || is_readable($path)) {
                     static::$libraryPaths[] = $path;
                 } else {
                     Log::debug("Invalid scripting library path given {$path}.");
                 }
             }
         }
     }
     \Cache::add('scripting.library_paths', static::$libraryPaths, static::DEFAULT_CACHE_TTL);
     if (empty(static::$libraryPaths)) {
         Log::debug('No scripting library paths found.');
     }
 }
开发者ID:df-arif,项目名称:df-core,代码行数:32,代码来源:BaseEngineAdapter.php

示例14: handlePOST

 /**
  * @return array
  * @throws BadRequestException
  * @throws NotFoundException
  */
 protected function handlePOST()
 {
     $data = $this->getPayloadData();
     $templateName = $this->request->getParameter('template', null);
     $templateId = $this->request->getParameter('template_id', null);
     $templateData = [];
     if (!empty($templateName)) {
         $templateData = static::getTemplateDataByName($templateName);
     } elseif (!empty($templateId)) {
         $templateData = static::getTemplateDataById($templateId);
     }
     if (empty($templateData) && empty($data)) {
         throw new BadRequestException('No valid data in request.');
     }
     $data = array_merge(ArrayUtils::clean(ArrayUtils::get($templateData, 'defaults', [], true)), $data);
     $data = array_merge($this->parameters, $templateData, $data);
     $text = ArrayUtils::get($data, 'body_text');
     $html = ArrayUtils::get($data, 'body_html');
     $count = $this->sendEmail($data, $text, $html);
     //Mandrill and Mailgun returns Guzzle\Message\Response object.
     if (!is_int($count)) {
         $count = 1;
     }
     return ['count' => $count];
 }
开发者ID:df-arif,项目名称:df-core,代码行数:30,代码来源:BaseService.php

示例15: buildQueryStringFromData

 /**
  * @param       $filter_info
  * @param array $params
  *
  * @return null|string
  * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
  */
 protected function buildQueryStringFromData($filter_info, array &$params)
 {
     $filter_info = ArrayUtils::clean($filter_info);
     $filters = ArrayUtils::get($filter_info, 'filters');
     if (empty($filters)) {
         return null;
     }
     $sql = '';
     $combiner = ArrayUtils::get($filter_info, 'filter_op', 'and');
     foreach ($filters as $key => $filter) {
         if (!empty($sql)) {
             $sql .= " {$combiner} ";
         }
         $name = ArrayUtils::get($filter, 'name');
         $op = ArrayUtils::get($filter, 'operator');
         $value = ArrayUtils::get($filter, 'value');
         $value = static::interpretFilterValue($value);
         if (empty($name) || empty($op)) {
             // log and bail
             throw new InternalServerErrorException('Invalid server-side filter configuration detected.');
         }
         switch ($op) {
             case 'is null':
             case 'is not null':
                 $sql .= "{$name} {$op}";
                 //                    $sql .= $this->dbConn->quoteColumnName($name) . " $op";
                 break;
             default:
                 $paramName = ':ssf_' . $name . '_' . $key;
                 $params[$paramName] = $value;
                 $value = $paramName;
                 $sql .= "{$name} {$op} {$value}";
                 //                    $sql .= $this->dbConn->quoteColumnName($name) . " $op $value";
                 break;
         }
     }
     return $sql;
 }
开发者ID:pkdevboxy,项目名称:df-core,代码行数:45,代码来源:DbRequestCriteria.php


注:本文中的DreamFactory\Library\Utility\ArrayUtils::clean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。