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


PHP Utility\ArrayUtils类代码示例

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


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

示例1: setDriver

 /**
  * Sets the Active Directory Driver.
  */
 protected function setDriver()
 {
     $host = $this->getHost();
     $baseDn = $this->getBaseDn();
     $accountSuffix = ArrayUtils::get($this->config, 'account_suffix');
     $this->driver = new \DreamFactory\Core\ADLdap\Components\ADLdap($host, $baseDn, $accountSuffix);
 }
开发者ID:rajeshpillai,项目名称:df-adldap,代码行数:10,代码来源:ADLdap.php

示例2: getCachedInfo

 /**
  * Returns role info cached, or reads from db if not present.
  * Pass in a key to return a portion/index of the cached data.
  *
  * @param int         $id
  * @param null|string $key
  * @param null        $default
  *
  * @return mixed|null
  */
 public static function getCachedInfo($id, $key = null, $default = null)
 {
     $cacheKey = 'role:' . $id;
     try {
         $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'), function () use($id) {
             $role = Role::with(['role_lookup_by_role_id', 'role_service_access_by_role_id', 'service_by_role_service_access'])->whereId($id)->first();
             if (empty($role)) {
                 throw new NotFoundException("Role not found.");
             }
             $roleInfo = $role->toArray();
             $services = ArrayUtils::get($roleInfo, 'service_by_role_service_access');
             unset($roleInfo['service_by_role_service_access']);
             foreach ($roleInfo['role_service_access_by_role_id'] as $key => $value) {
                 $serviceName = ArrayUtils::findByKeyValue($services, 'id', ArrayUtils::get($value, 'service_id'), 'name');
                 $component = ArrayUtils::get($value, 'component');
                 $roleInfo['role_service_access_by_role_id'][$key]['service'] = $serviceName;
                 $roleInfo['role_service_access_by_role_id'][$key]['component'] = trim($component, '/');
             }
             return $roleInfo;
         });
         if (is_null($result)) {
             return $default;
         }
     } catch (ModelNotFoundException $ex) {
         return $default;
     }
     if (is_null($key)) {
         return $result;
     }
     return isset($result[$key]) ? $result[$key] : $default;
 }
开发者ID:pkdevboxy,项目名称:df-core,代码行数:41,代码来源:Role.php

示例3: __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

示例4: getJWTFromAuthHeader

 /**
  * Gets the token from Authorization header.
  *
  * @return string
  */
 protected static function getJWTFromAuthHeader()
 {
     if ('testing' === env('APP_ENV')) {
         //getallheaders method is not available in unit test mode.
         return [];
     }
     if (!function_exists('getallheaders')) {
         function getallheaders()
         {
             if (!is_array($_SERVER)) {
                 return [];
             }
             $headers = [];
             foreach ($_SERVER as $name => $value) {
                 if (substr($name, 0, 5) == 'HTTP_') {
                     $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
                 }
             }
             return $headers;
         }
     }
     $token = null;
     $headers = getallheaders();
     $authHeader = ArrayUtils::get($headers, 'Authorization');
     if (strpos($authHeader, 'Bearer') !== false) {
         $token = substr($authHeader, 7);
     }
     return $token;
 }
开发者ID:tvpsoft,项目名称:dreamfactory,代码行数:34,代码来源:AuthCheck.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: setTransport

 /**
  * {@inheritdoc}
  */
 protected function setTransport($config)
 {
     $key = ArrayUtils::get($config, 'key');
     $secret = ArrayUtils::get($config, 'secret');
     $region = ArrayUtils::get($config, 'region', 'us-east-1');
     $this->transport = static::getTransport($key, $secret, $region);
 }
开发者ID:pkdevboxy,项目名称:df-aws,代码行数:10,代码来源:Ses.php

示例7: setConfig

 /**
  * {@inheritdoc}
  */
 public static function setConfig($id, $config)
 {
     $rosConfig = OpenStackConfig::find($id);
     $pathConfig = FilePublicPath::find($id);
     $configPath = ['public_path' => ArrayUtils::get($config, 'public_path'), 'container' => ArrayUtils::get($config, 'container')];
     $configRos = ['service_id' => ArrayUtils::get($config, 'service_id'), 'username' => ArrayUtils::get($config, 'username'), 'password' => ArrayUtils::get($config, 'password'), 'tenant_name' => ArrayUtils::get($config, 'tenant_name'), 'api_key' => ArrayUtils::get($config, 'api_key'), 'url' => ArrayUtils::get($config, 'url'), 'region' => ArrayUtils::get($config, 'region'), 'storage_type' => ArrayUtils::get($config, 'storage_type')];
     ArrayUtils::removeNull($configRos);
     ArrayUtils::removeNull($configPath);
     if (!empty($rosConfig)) {
         $rosConfig->update($configRos);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configRos = array_reverse($configRos, true);
         $configRos['service_id'] = $id;
         $configRos = array_reverse($configRos, true);
         OpenStackConfig::create($configRos);
     }
     if (!empty($pathConfig)) {
         $pathConfig->update($configPath);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configPath = array_reverse($configPath, true);
         $configPath['service_id'] = $id;
         $configPath = array_reverse($configPath, true);
         FilePublicPath::create($configPath);
     }
 }
开发者ID:digideskio,项目名称:df-rackspace,代码行数:36,代码来源:OpenStackObjectStorageConfig.php

示例8: setDriver

 /**
  * {@inheritdoc}
  */
 protected function setDriver($config)
 {
     $clientId = ArrayUtils::get($config, 'client_id');
     $clientSecret = ArrayUtils::get($config, 'client_secret');
     $redirectUrl = ArrayUtils::get($config, 'redirect_url');
     $this->driver = new TwitterProvider($clientId, $clientSecret, $redirectUrl);
 }
开发者ID:df-arif,项目名称:df-oauth,代码行数:10,代码来源:Twitter.php

示例9: validateConfig

 public static function validateConfig($config, $create = true)
 {
     if (null === ArrayUtils::get($config, 'username', null, true) || null === ArrayUtils::get($config, 'password', null, true)) {
         throw new BadRequestException('Both Username and Password are required');
     }
     return true;
 }
开发者ID:rajeshpillai,项目名称:df-salesforce,代码行数:7,代码来源:SalesforceConfig.php

示例10: __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

示例11: setConfig

 /**
  * {@inheritdoc}
  */
 public static function setConfig($id, $config)
 {
     $azureConfig = AzureConfig::find($id);
     $pathConfig = FilePublicPath::find($id);
     $configPath = ['public_path' => ArrayUtils::get($config, 'public_path'), 'container' => ArrayUtils::get($config, 'container')];
     $configAzure = ['service_id' => ArrayUtils::get($config, 'service_id'), 'account_name' => ArrayUtils::get($config, 'account_name'), 'account_key' => ArrayUtils::get($config, 'account_key'), 'protocol' => ArrayUtils::get($config, 'protocol')];
     ArrayUtils::removeNull($configAzure);
     ArrayUtils::removeNull($configPath);
     if (!empty($azureConfig)) {
         $azureConfig->update($configAzure);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configAzure = array_reverse($configAzure, true);
         $configAzure['service_id'] = $id;
         $configAzure = array_reverse($configAzure, true);
         AzureConfig::create($configAzure);
     }
     if (!empty($pathConfig)) {
         $pathConfig->update($configPath);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configPath = array_reverse($configPath, true);
         $configPath['service_id'] = $id;
         $configPath = array_reverse($configPath, true);
         FilePublicPath::create($configPath);
     }
 }
开发者ID:rajeshpillai,项目名称:df-azure,代码行数:36,代码来源:AzureBlobConfig.php

示例12: __construct

 public function __construct($settings = [])
 {
     $verbAliases = [Verbs::PUT => Verbs::POST, Verbs::MERGE => Verbs::POST, Verbs::PATCH => Verbs::POST];
     ArrayUtils::set($settings, "verbAliases", $verbAliases);
     parent::__construct($settings);
     $this->model = \DreamFactory\Core\Models\Config::class;
 }
开发者ID:df-arif,项目名称:df-core,代码行数:7,代码来源:Config.php

示例13: __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

示例14: getApiDocInfo

 /**
  * {@inheritdoc}
  */
 public function getApiDocInfo()
 {
     $base = parent::getApiDocInfo();
     $apis = [];
     $models = [];
     foreach ($this->getResources(true) as $resourceInfo) {
         $className = ArrayUtils::get($resourceInfo, 'class_name');
         if (!class_exists($className)) {
             throw new InternalServerErrorException('Service configuration class name lookup failed for resource ' . $this->resourcePath);
         }
         /** @var BaseRestResource $resource */
         $resource = $this->instantiateResource($className, $resourceInfo);
         $name = ArrayUtils::get($resourceInfo, 'name', '') . '/';
         $access = $this->getPermissions($name);
         if (!empty($access)) {
             $results = $resource->getApiDocInfo();
             if (isset($results, $results['apis'])) {
                 $apis = array_merge($apis, $results['apis']);
             }
             if (isset($results, $results['models'])) {
                 $models = array_merge($models, $results['models']);
             }
         }
     }
     $base['apis'] = array_merge($base['apis'], $apis);
     $base['models'] = array_merge($base['models'], $models);
     return $base;
 }
开发者ID:df-arif,项目名称:df-user,代码行数:31,代码来源:User.php

示例15: 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


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