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


PHP ArrayUtils::removeNull方法代码示例

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


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

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

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

示例3: handlePOST

 /**
  * Registers new user.
  *
  * @return array
  * @throws \DreamFactory\Core\Exceptions\BadRequestException
  * @throws \DreamFactory\Core\Exceptions\ForbiddenException
  */
 protected function handlePOST()
 {
     $payload = $this->getPayloadData();
     $login = $this->request->getParameterAsBool('login');
     $registrar = new Registrar();
     $password = ArrayUtils::get($payload, 'new_password', ArrayUtils::get($payload, 'password'));
     $data = ['first_name' => ArrayUtils::get($payload, 'first_name'), 'last_name' => ArrayUtils::get($payload, 'last_name'), 'name' => ArrayUtils::get($payload, 'name'), 'email' => ArrayUtils::get($payload, 'email'), 'phone' => ArrayUtils::get($payload, 'phone'), 'security_question' => ArrayUtils::get($payload, 'security_question'), 'security_answer' => ArrayUtils::get($payload, 'security_answer'), 'password' => $password, 'password_confirmation' => ArrayUtils::get($payload, 'password_confirmation', $password)];
     if (empty($data['first_name'])) {
         list($username, $domain) = explode('@', $data['email']);
         $data['first_name'] = $username;
     }
     if (empty($data['last_name'])) {
         $names = explode('.', $data['first_name']);
         if (isset($names[1])) {
             $data['last_name'] = $names[1];
             $data['first_name'] = $names[0];
         } else {
             $data['last_name'] = $names[0];
         }
     }
     if (empty($data['name'])) {
         $data['name'] = $data['first_name'] . ' ' . $data['last_name'];
     }
     ArrayUtils::removeNull($data);
     /** @var \Illuminate\Validation\Validator $validator */
     $validator = $registrar->validator($data);
     if ($validator->fails()) {
         $messages = $validator->errors()->getMessages();
         throw new BadRequestException('Validation failed', null, null, $messages);
     } else {
         $user = $registrar->create($data);
         if ($login) {
             if ($user->confirm_code !== 'y' && !is_null($user->confirm_code)) {
                 return ['success' => true, 'confirmation_required' => true];
             } else {
                 Session::setUserInfoWithJWT($user);
                 return ['success' => true, 'session_token' => Session::getSessionToken()];
             }
         } else {
             return ['success' => true];
         }
     }
 }
开发者ID:df-arif,项目名称:df-user,代码行数:50,代码来源:Register.php

示例4: handlePOST

 /**
  * Updates user profile.
  *
  * @return array
  * @throws NotFoundException
  * @throws \Exception
  */
 protected function handlePOST()
 {
     $payload = $this->getPayloadData();
     $data = ['first_name' => ArrayUtils::get($payload, 'first_name'), 'last_name' => ArrayUtils::get($payload, 'last_name'), 'name' => ArrayUtils::get($payload, 'name'), 'email' => ArrayUtils::get($payload, 'email'), 'phone' => ArrayUtils::get($payload, 'phone'), 'security_question' => ArrayUtils::get($payload, 'security_question'), 'security_answer' => ArrayUtils::get($payload, 'security_answer'), 'default_app_id' => ArrayUtils::get($payload, 'default_app_id')];
     ArrayUtils::removeNull($data);
     $user = Session::user();
     if (empty($user)) {
         throw new NotFoundException('No user session found.');
     }
     $oldToken = Session::getSessionToken();
     $email = $user->email;
     $user->update($data);
     if (!empty($oldToken) && $email !== ArrayUtils::get($data, 'email', $email)) {
         // Email change invalidates token. Need to create a new token.
         $forever = JWTUtilities::isForever($oldToken);
         Session::setUserInfoWithJWT($user, $forever);
         $newToken = Session::getSessionToken();
         return ['success' => true, 'session_token' => $newToken];
     }
     return ['success' => true];
 }
开发者ID:df-arif,项目名称:df-core,代码行数:28,代码来源:UserProfileResource.php


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