當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Arr::set方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Arr::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP Arr::set方法的具體用法?PHP Arr::set怎麽用?PHP Arr::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Arr的用法示例。


在下文中一共展示了Arr::set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handleDotCase

 protected function handleDotCase(&$array, $key, $value)
 {
     if (strpos($key, '.') !== false) {
         unset($array[$key]);
         Arr::set($array, $key, $value);
     }
 }
開發者ID:spira,項目名稱:api-core,代碼行數:7,代碼來源:ValidationExceptionTransformer.php

示例2: set

 /**
  * Set a given configuration value.
  *
  * @param  array|string  $key
  * @param  mixed   $value
  * @return void
  */
 public function set($key, $value = null)
 {
     $keys = is_array($key) ? $key : [$key => $value];
     foreach ($keys as $key => $value) {
         Arr::set($this->items, $key, $value);
     }
 }
開發者ID:bryanashley,項目名稱:framework,代碼行數:14,代碼來源:Repository.php

示例3: testPasswordResetUsingConfirmationCode

 public function testPasswordResetUsingConfirmationCode()
 {
     if (!$this->serviceExists('mymail')) {
         $emailService = \DreamFactory\Core\Models\Service::create(["name" => "mymail", "label" => "Test mail service", "description" => "Test mail service", "is_active" => true, "type" => "local_email", "mutable" => true, "deletable" => true, "config" => ["driver" => "sendmail", "command" => "/usr/sbin/sendmail -bs"]]);
         $userConfig = \DreamFactory\Core\User\Models\UserConfig::find(4);
         $userConfig->password_email_service_id = $emailService->id;
         $userConfig->save();
     }
     if (!\DreamFactory\Core\Models\EmailTemplate::whereName('mytemplate')->exists()) {
         $template = \DreamFactory\Core\Models\EmailTemplate::create(['name' => 'mytemplate', 'description' => 'test', 'to' => $this->user2['email'], 'subject' => 'rest password test', 'body_text' => 'link {link}']);
         $userConfig = \DreamFactory\Core\User\Models\UserConfig::find(4);
         $userConfig->password_email_template_id = $template->id;
         $userConfig->save();
     }
     Arr::set($this->user2, 'email', 'arif@dreamfactory.com');
     $user = $this->createUser(2);
     Config::set('mail.pretend', true);
     $rs = $this->makeRequest(Verbs::POST, static::RESOURCE, ['reset' => 'true'], ['email' => $user['email']]);
     $content = $rs->getContent();
     $this->assertTrue($content['success']);
     /** @var User $userModel */
     $userModel = User::find($user['id']);
     $code = $userModel->confirm_code;
     $rs = $this->makeRequest(Verbs::POST, static::RESOURCE, ['login' => 'true'], ['email' => $user['email'], 'code' => $code, 'new_password' => '778877']);
     $content = $rs->getContent();
     $this->assertTrue($content['success']);
     $this->assertTrue(Session::isAuthenticated());
     $userModel = User::find($user['id']);
     $this->assertEquals('y', $userModel->confirm_code);
     $this->service = ServiceHandler::getService($this->serviceId);
     $rs = $this->makeRequest(Verbs::POST, 'session', [], ['email' => $user['email'], 'password' => '778877']);
     $content = $rs->getContent();
     $this->assertTrue(!empty($content['session_id']));
 }
開發者ID:df-arif,項目名稱:df-user,代碼行數:34,代碼來源:PasswordResourceTest.php

示例4: setRequestInput

 /**
  * Replace a single item in a given Request’s input using dot-notation
  * @param Request $request to modify
  * @param string $key in dot-notation
  * @param mixed $value to set
  */
 protected function setRequestInput(Request $request, $key, $value)
 {
     if (strpos($key, '.')) {
         // The data to set is deeper than 1 level down
         // meaning the final value of the input's first level key is expected to be an array
         list($first_level_key, $key_rest) = explode('.', $key, 2);
         // Pull out the input's existing first level value to modify it as an array
         $first_level_value = $request->input($first_level_key);
         //Request::input() pulls from all input data using dot-notation (ArrayAccess on Request would also pull out files which is undesirable here).
         if (!is_array($first_level_value)) {
             $first_level_value = [];
         }
         Arr::set($first_level_value, $key_rest, $value);
     } else {
         // The data to set is in the first level
         $first_level_key = $key;
         $first_level_value = $value;
     }
     $request->merge([$first_level_key => $first_level_value]);
     // The only current alternatives for modifying Request input data are merge() and replace(), the latter replacing the whole input data.
     /*
      * It could look tempting to skip all of the above code and just
      * Arr::set() on the Request object utilizing it's ArrayAccess...
      * But it doesn't work for the second- or higher dot-levels because of the
      * non-reference return value of ArrayAccess::offsetGet()
      */
 }
開發者ID:fewagency,項目名稱:laravel-reformulator,代碼行數:33,代碼來源:ModifiesRequestInputTrait.php

示例5: set

 /**
  * Update setting
  *
  * @param $key
  * @param $value
  * @return mixed
  */
 public function set($key, $value)
 {
     $this->prepare();
     if (!$this->has($key) || $this->get($key) != $value) {
         $this->isDirty = true;
     }
     Arr::set($this->data, $key, $value);
 }
開發者ID:bitempest,項目名稱:laravel-settings,代碼行數:15,代碼來源:Json.php

示例6: htmlspecialchars

 function traitAjax_response()
 {
     $data = ['vendor' => static::getVendor(), 'package' => static::getEntity()];
     $ret = array_merge($data, $this->traitAjaxParams);
     $message = Arr::get($ret, 'message');
     $message = htmlspecialchars($message);
     Arr::set($ret, 'message', $message);
     return $ret;
 }
開發者ID:larakit,項目名稱:lk,代碼行數:9,代碼來源:TraitControllerAjax.php

示例7: set

 /**
  * Set a given configuration value.
  *
  * @param  array|string  $key
  * @param  mixed   $value
  * @return void
  */
 public function set($key, $value = null)
 {
     if (is_array($key)) {
         foreach ($key as $innerKey => $innerValue) {
             Arr::set($this->items, $innerKey, $innerValue);
         }
     } else {
         Arr::set($this->items, $key, $value);
     }
 }
開發者ID:doraemons,項目名稱:dependency-injection,代碼行數:17,代碼來源:Config.php

示例8: only

 /**
  * Get a subset of the items from the input data.
  *
  * @param  array|mixed  $keys
  * @return array
  */
 public function only($keys)
 {
     $keys = is_array($keys) ? $keys : func_get_args();
     $results = [];
     $input = self::all();
     foreach ($keys as $key) {
         Arr::set($results, $key, Arr::get($input, $key));
     }
     return $results;
 }
開發者ID:efracuadras,項目名稱:slimgeek,代碼行數:16,代碼來源:Request.php

示例9: testPATCHPassword

 public function testPATCHPassword()
 {
     $user = $this->createUser(1);
     Arr::set($user, 'password', '1234');
     $payload = json_encode($user, JSON_UNESCAPED_SLASHES);
     $rs = $this->makeRequest(Verbs::PATCH, static::RESOURCE . '/' . $user['id'], [], $payload);
     $content = $rs->getContent();
     $this->assertFalse(Session::authenticate(['email' => $user['email'], 'password' => '1234']));
     $this->assertTrue($this->adminCheck([$content]));
 }
開發者ID:df-arif,項目名稱:df-user,代碼行數:10,代碼來源:UserResourceTest.php

示例10: set

 /**
  * Set a value on the server.
  *
  * @param string|array $key
  * @param mixed|null   $value
  */
 public function set($key, $value = null)
 {
     // Set the value on the contents
     $contents = (array) $this->getContents();
     if (is_array($key)) {
         $contents = $key;
     } else {
         Arr::set($contents, $key, $value);
     }
     $this->saveContents($contents);
 }
開發者ID:clone1018,項目名稱:rocketeer,代碼行數:17,代碼來源:AbstractStorage.php

示例11: getClean

 function getClean()
 {
     $ret = $this->data;
     foreach ($this->filters as $field => $filters) {
         foreach ($filters as $filter) {
             $filtered = call_user_func($filter, Arr::get($ret, $field));
             Arr::set($ret, $field, $filtered);
         }
     }
     return $ret;
 }
開發者ID:larakit,項目名稱:lk,代碼行數:11,代碼來源:DataFilter.php

示例12: map

 public function map($data)
 {
     foreach ($data as &$item) {
         $value = Arr::get($item, $this->name);
         if ($this->hasValueWrapper()) {
             $value = call_user_func($this->valueWrapper, $value);
             Arr::set($item, $this->name, $value);
         }
     }
     return $data;
 }
開發者ID:barryzhang,項目名稱:laravel-admin,代碼行數:11,代碼來源:Column.php

示例13: createIndex

 /**
  * Create a new search index.
  *
  * @param  string|null $index
  * @param  array|null $settings
  * @param  array|null $mappings
  * @return array
  */
 public function createIndex($index = null, array $settings = null, array $mappings = null)
 {
     $indexName = $index ?: $this->getDefaultIndex();
     $params = ['index' => $indexName];
     if (!empty($settings)) {
         Arr::set($params, 'body.settings', $settings);
     }
     if (!empty($mappings)) {
         Arr::set($params, 'body.mappings', $mappings);
     }
     return $this->client->indices()->create($params);
 }
開發者ID:elodex,項目名稱:elodex,代碼行數:20,代碼來源:IndexManager.php

示例14: register

 static function register($code, $name, $aliases = [])
 {
     self::$roles[$code] = $name;
     ksort(self::$roles);
     $aliases = (array) $aliases;
     foreach ($aliases as $alias) {
         self::$aliases[$alias] = $code;
     }
     $code = str_replace('.', '.items.', $code);
     Arr::set(self::$tree, $code . '.name', $name);
     Arr::set(self::$tree, $code . '.code', $code);
 }
開發者ID:larakit,項目名稱:lk,代碼行數:12,代碼來源:UserRole.php

示例15: reqOnlyIfExists

function reqOnlyIfExists($keys)
{
    $keys = is_array($keys) ? $keys : func_get_args();
    $results = [];
    $input = request()->all();
    foreach ($keys as $key) {
        if (request()->exists($key)) {
            Arr::set($results, $key, Arr::get($input, $key));
        }
    }
    return $results;
}
開發者ID:sebalb,項目名稱:shopapp,代碼行數:12,代碼來源:helpers.php


注:本文中的Illuminate\Support\Arr::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。