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


PHP ArrayUtils::remove方法代码示例

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


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

示例1: updateInternal

 /**
  * {@inheritdoc}
  */
 public static function updateInternal($id, $record, $params = [])
 {
     if (empty($record)) {
         throw new BadRequestException('There are no fields in the record to create . ');
     }
     if (empty($id)) {
         //Todo:perform logging below
         //Log::error( 'Update request with no id supplied: ' . print_r( $record, true ) );
         throw new BadRequestException('Identifying field "id" can not be empty for update request . ');
     }
     /** @type User $model */
     $model = static::find($id);
     if (!$model instanceof Model) {
         throw new NotFoundException('No resource found for ' . $id);
     }
     $pk = $model->primaryKey;
     //	Remove the PK from the record since this is an update
     ArrayUtils::remove($record, $pk);
     try {
         if ($model->is_sys_admin && !ArrayUtils::getBool($params, 'admin')) {
             throw new ForbiddenException('Not allowed to change an admin user.');
         } elseif (ArrayUtils::getBool($params, 'admin') && !$model->is_sys_admin) {
             throw new BadRequestException('Cannot update a non-admin user.');
         }
         $password = ArrayUtils::get($record, 'password');
         if (!empty($password)) {
             $model->password = $password;
         }
         $model->update($record);
         return static::buildResult($model, $params);
     } catch (\Exception $ex) {
         if (!$ex instanceof ForbiddenException && !$ex instanceof BadRequestException) {
             throw new InternalServerErrorException('Failed to update resource: ' . $ex->getMessage());
         } else {
             throw $ex;
         }
     }
 }
开发者ID:pkdevboxy,项目名称:df-core,代码行数:41,代码来源:User.php

示例2: updateInternal

 /**
  * @param       $id
  * @param       $record
  * @param array $params
  *
  * @return array
  * @throws \DreamFactory\Core\Exceptions\BadRequestException
  * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
  * @throws \DreamFactory\Core\Exceptions\NotFoundException
  */
 public static function updateInternal($id, $record, $params = [])
 {
     if (empty($record)) {
         throw new BadRequestException('There are no fields in the record to create . ');
     }
     if (empty($id)) {
         //Todo:perform logging below
         //Log::error( 'Update request with no id supplied: ' . print_r( $record, true ) );
         throw new BadRequestException('Identifying field "id" can not be empty for update request . ');
     }
     $userId = SessionUtility::getCurrentUserId();
     ArrayUtils::set($record, 'user_id', $userId);
     //Making sure name is not changed during update as it not be unique.
     ArrayUtils::set($record, 'name', $id);
     $model = static::whereUserId($userId)->whereName($id)->first();
     if (!$model instanceof Model) {
         throw new NotFoundException('No resource found for ' . $id);
     }
     $pk = $model->primaryKey;
     //	Remove the PK from the record since this is an update
     ArrayUtils::remove($record, $pk);
     try {
         $model->update($record);
         return static::buildResult($model, $params);
     } catch (\Exception $ex) {
         throw new InternalServerErrorException('Failed to update resource: ' . $ex->getMessage());
     }
 }
开发者ID:df-arif,项目名称:df-user,代码行数:38,代码来源:UserCustom.php

示例3: updateInternal

 /**
  * @param       $id
  * @param       $record
  * @param array $params
  *
  * @return array
  * @throws \DreamFactory\Core\Exceptions\BadRequestException
  * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
  * @throws \DreamFactory\Core\Exceptions\NotFoundException
  */
 public static function updateInternal($id, $record, $params = [])
 {
     if (empty($record)) {
         throw new BadRequestException('There are no fields in the record to create . ');
     }
     if (empty($id)) {
         //Todo:perform logging below
         //Log::error( 'Update request with no id supplied: ' . print_r( $record, true ) );
         throw new BadRequestException('Identifying field "id" can not be empty for update request . ');
     }
     $model = static::find($id);
     if (!$model instanceof Model) {
         throw new NotFoundException('No resource found for ' . $id);
     }
     $pk = $model->primaryKey;
     //	Remove the PK from the record since this is an update
     ArrayUtils::remove($record, $pk);
     try {
         $model->update($record);
         return static::buildResult($model, $params);
     } catch (\Exception $ex) {
         throw new InternalServerErrorException('Failed to update resource: ' . $ex->getMessage());
     }
 }
开发者ID:df-arif,项目名称:df-core,代码行数:34,代码来源:BaseModel.php


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