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


PHP Arr::dot方法代码示例

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


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

示例1: parseJsRemoteRequest

 /**
  *  Parse Validation input request data.
  *
  * @param $attribute
  * @param $value
  * @param $parameters
  * @return array
  */
 protected function parseJsRemoteRequest($attribute, $value, $parameters)
 {
     parse_str("{$value}=", $attr_parts);
     $attr_parts = is_null($attr_parts) ? [] : $attr_parts;
     $newAttr = array_keys(Arr::dot($attr_parts));
     return [$attribute, array_pop($newAttr), $parameters];
 }
开发者ID:suhe,项目名称:bdoportal,代码行数:15,代码来源:Validator.php

示例2: tableRows

 /**
  * The output of the table rows.
  *
  * @return array
  */
 private function tableRows()
 {
     $allLanguages = $this->manager->languages();
     $filesContent = [];
     $output = [];
     foreach ($this->files as $fileName => $fileLanguages) {
         foreach ($fileLanguages as $languageKey => $filePath) {
             $lines = $filesContent[$fileName][$languageKey] = Arr::dot($this->manager->getFileContent($filePath));
             foreach ($lines as $key => $line) {
                 if (!is_array($line) && stripos($line, $this->argument('keyword')) !== false) {
                     $output[$fileName . '.' . $key][$languageKey] = "<bg=yellow;fg=black>{$line}</>";
                 }
             }
         }
     }
     // Now that we collected all values that matches the keyword argument
     // in a close match, we collect the values for the rest of the
     // languages for the found keys to complete the table view.
     foreach ($output as $fullKey => $values) {
         list($fileName, $key) = explode('.', $fullKey, 2);
         $original = [];
         foreach ($allLanguages as $languageKey) {
             $original[$languageKey] = isset($values[$languageKey]) ? $values[$languageKey] : isset($filesContent[$fileName][$languageKey][$key]) ? $filesContent[$fileName][$languageKey][$key] : '';
         }
         // Sort the language values based on language name
         ksort($original);
         $output[$fullKey] = array_merge(['key' => "<fg=yellow>{$fullKey}</>"], $original);
     }
     return array_values($output);
 }
开发者ID:themsaid,项目名称:laravel-langman,代码行数:35,代码来源:FindCommand.php

示例3: resolveCsvHeader

 /**
  * Resolve CSV header.
  *
  * @return array
  */
 protected function resolveCsvHeader()
 {
     $header = [];
     if (!$this->isEmpty()) {
         $single = $this->first();
         $header = array_keys(Arr::dot($single));
     }
     return $header;
 }
开发者ID:DavidIWilson,项目名称:site1,代码行数:14,代码来源:Collection.php

示例4: prepareBinding

 /**
  * Prepare bindings for text replacement.
  *
  * @param  array   $replacements
  * @param  string  $prefix
  * @param  string  $suffix
  *
  * @return array
  */
 protected static function prepareBinding(array $replacements = [], $prefix = '{', $suffix = '}')
 {
     $replacements = Arr::dot($replacements);
     $bindings = [];
     foreach ($replacements as $key => $value) {
         $bindings["{$prefix}{$key}{$suffix}"] = $value;
     }
     return $bindings;
 }
开发者ID:DavidIWilson,项目名称:site1,代码行数:18,代码来源:Str.php

示例5: getCustomMessageFromTranslator

 /**
  * Get the custom error message from translator.
  *
  * @param  string  $customKey
  * @return string
  */
 protected function getCustomMessageFromTranslator($customKey)
 {
     if (($message = $this->translator->trans($customKey)) !== $customKey) {
         return $message;
     }
     $shortKey = preg_replace('/^lpanel::validation\\.custom\\./', '', $customKey);
     $customMessages = Arr::dot((array) $this->translator->trans('lpanel::validation.custom'));
     foreach ($customMessages as $key => $message) {
         if (Str::contains($key, ['*']) && Str::is($key, $shortKey)) {
             return $message;
         }
     }
     return $customKey;
 }
开发者ID:Viktor-V,项目名称:LPanel,代码行数:20,代码来源:Validator.php

示例6: index

 public function index()
 {
     Audit::log(Auth::user()->id, trans('admin/settings/general.audit-log.category'), trans('admin/settings/general.audit-log.msg-index'));
     $page_title = trans('admin/settings/general.page.index.title');
     // "Admin | Settings";
     $page_description = trans('admin/settings/general.page.index.description');
     // "List of Settings";
     //        $settings = (new SettingModel())->all();
     $settings = Setting::all();
     $settings = Arr::dot($settings);
     $settingsFiltered = Utils::FilterOutUserSettings($settings);
     $settingsFiltered = Arr::sortRecursive($settingsFiltered);
     return view('admin.settings.index', compact('settingsFiltered', 'page_title', 'page_description'));
 }
开发者ID:sroutier,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:14,代码来源:SettingsController.php

示例7: setConfig

 public function setConfig(Application $app, $data)
 {
     $db = $app['config']->get('database');
     if (!$db) {
         return false;
     }
     $driver = $db['default'];
     $post_data = ['connections' => [$driver => $data]];
     $config = array_merge(Arr::dot($db), Arr::dot($post_data));
     $a = [];
     foreach ($config as $k => $v) {
         Arr::set($a, $k, $v);
     }
     $app['config']->set('database', $a);
     return $driver;
 }
开发者ID:znsstudio,项目名称:installer,代码行数:16,代码来源:DatabaseManager.php

示例8: setConfig

 public function setConfig(Application $app, DatabaseRequest $request)
 {
     $driver = $request->get('driver');
     $connections = $this->connections();
     $config = array_merge($connections[$driver], $request->get($driver));
     if (isset($config['default'])) {
         unset($config['default']);
     }
     $config = array_merge(Arr::dot($app['config']->get('database')), Arr::dot(['default' => $driver, 'connections' => [$driver => $config]]));
     $a = [];
     foreach ($config as $k => $v) {
         Arr::set($a, $k, $v);
     }
     $app['config']->set('database', $a);
     return $driver;
 }
开发者ID:viniciusferreira,项目名称:installer,代码行数:16,代码来源:DatabaseManager.php

示例9: __construct

 /**
  * __construct.
  *
  * @method __construct
  *
  * @param \Illuminate\Contracts\Config\Repository   $repository
  * @param \Recca0120\Config\Config                  $model
  * @param string                                    $config
  */
 public function __construct(Repository $repository, Config $model, Filesystem $filesystem, $config = [])
 {
     parent::__construct($repository);
     $this->original = $repository->all();
     $this->model = $model;
     $this->filesystem = $filesystem;
     $this->config = $config;
     $data = value(function () {
         $file = $this->getStorageFile();
         if ($this->filesystem->exists($file) === true) {
             return json_decode($this->filesystem->get($file), true);
         }
         $data = $this->getModel()->value;
         $this->storeToFile($data);
         return $data;
     });
     foreach (Arr::dot($data) as $key => $value) {
         $repository->set($key, $value);
     }
 }
开发者ID:recca0120,项目名称:laravel-config,代码行数:29,代码来源:DatabaseRepository.php

示例10: renameKey

 /**
  * Rename the given oldKey to the newKey.
  *
  * @return void
  */
 private function renameKey()
 {
     try {
         list($file, $key) = explode('.', $this->argument('oldKey'), 2);
     } catch (\ErrorException $e) {
         $this->error('Could not recognize the key you want to rename.');
         return;
     }
     if (Str::contains($this->argument('newKey'), '.')) {
         $this->error('Please provide the new key must not contain a dot.');
         return;
     }
     $newKey = preg_replace('/(\\w+)$/i', $this->argument('newKey'), $key);
     $files = $this->manager->files()[$file];
     $currentValues = [];
     foreach ($files as $languageKey => $filePath) {
         $content = Arr::dot($this->manager->getFileContent($filePath));
         $currentValues[$languageKey] = isset($content[$key]) ? $content[$key] : '';
     }
     $this->manager->removeKey($file, $key);
     $this->manager->fillKeys($file, [$newKey => $currentValues]);
 }
开发者ID:themsaid,项目名称:laravel-langman,代码行数:27,代码来源:RenameCommand.php

示例11: syncKeysBetweenLanguages

 /**
  * Synchronize keys that exist in a language but not the other.
  *
  * @param $translationFiles
  * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
  * @return void
  */
 private function syncKeysBetweenLanguages($translationFiles)
 {
     $this->info('Synchronizing language files...');
     $filesResults = [];
     // Here we collect the file results
     foreach ($translationFiles as $fileName => $languageFiles) {
         foreach ($languageFiles as $languageKey => $filePath) {
             $filesResults[$fileName][$languageKey] = $this->manager->getFileContent($filePath);
         }
     }
     $values = Arr::dot($filesResults);
     $missing = $this->manager->getKeysExistingInALanguageButNotTheOther($values);
     foreach ($missing as &$missingKey) {
         list($file, $key) = explode('.', $missingKey, 2);
         list($key, $language) = explode(':', $key, 2);
         $this->fillMissingKeys($file, [$key], $language);
     }
 }
开发者ID:themsaid,项目名称:laravel-langman,代码行数:25,代码来源:SyncCommand.php

示例12: dot

 public static function dot(array $data)
 {
     return Arr::dot($data);
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:4,代码来源:ArrayHelpers.php

示例13: toDbIds

 /**
  * Go through an array field and deal with internal id references
  *
  * @param Model $model The eloquent model
  * @param mixed $receivingId Internal id of the model
  * @param string $field Field to work on
  * @param array $fieldData Current field data
  * @param array $rules Array of match rules
  * @return array Transformed field data
  */
 protected function toDbIds(Model $model, $receivingId, $field, array $fieldData, array $rules)
 {
     // Convert to dot array
     $dotData = Arr::dot($fieldData);
     // Iterate through all of the values
     foreach ($dotData as $path => $data) {
         $this->state->push($path);
         // Debug
         // Match only against data that starts with the internal id prefix
         if (is_string($data) && strlen($data) > 0 && substr($data, 0, strlen($this->prefix)) === $this->prefix) {
             // Iterate through the rules and see if any patterns match our data key
             foreach ($rules as $pattern => $mixed) {
                 if (is_array($mixed)) {
                     // [/regexp/ => [/regexp/ => Model]] is only for content search & replace (see further down)
                     continue;
                 }
                 // Match against exact dot pattern or regexp if it starts with a /
                 if ($path === $pattern || $pattern[0] === "/" && preg_match($pattern, $path) === 1) {
                     // Match - Update (or defer update if needed) the field with the db id
                     if (!$this->bookKeeper->update($model, "{$field}.{$path}", $receivingId, $data)) {
                         // Set to null for now
                         Arr::set($fieldData, $path, null);
                     } else {
                         // It was set directly, update $fieldData with the set value
                         Arr::set($fieldData, $path, Arr::get($model->{$field}, $path));
                     }
                 }
             }
         } elseif (is_string($data)) {
             // Another possibility: we want to match, search & replace refs in text
             // Iterate through the rules and see if any patterns match in our data string
             foreach ($rules as $pattern => $mixed) {
                 if (!is_array($mixed)) {
                     // [/regexp/ => Model] is only for key => @id matching (see above)
                     continue;
                 }
                 // Match against exact dot pattern or regexp if it starts with a /
                 if ($path === $pattern || $pattern[0] === "/" && preg_match($pattern, $path) === 1) {
                     // Key match
                     // Start out with making sure we actually have a string to work on
                     if (!is_string($model->{$field})) {
                         // Nope, let's superimpose the blueprint
                         $model->{$field} = $fieldData;
                     }
                     // Match the string against the rules given in the $mixed array
                     foreach ($mixed as $valuePattern => $fqcn) {
                         // Fetch all matches
                         preg_match_all($valuePattern, $data, $matches);
                         // 0 => ["foo=@1", "foo=@2"]
                         // 1 => ["@1", "@2"]
                         if (count($matches) !== 2) {
                             continue;
                         }
                         if (count($matches[0]) === 0) {
                             continue;
                         }
                         $searchStrings = $matches[0];
                         $refs = $matches[1];
                         // Filter out dupes and invalids
                         $uniqueRefs = [];
                         foreach ($refs as $index => $ref) {
                             // Ref must not already be matched and must start with the internal id prefix
                             if (!isset($uniqueRefs[$ref]) && isset($ref[0]) && substr($ref, 0, strlen($this->prefix)) === $this->prefix) {
                                 $uniqueRefs[$ref] = true;
                             } else {
                                 // Clear from the matches
                                 unset($refs[$index]);
                                 unset($searchStrings[$index]);
                             }
                         }
                         // Re-set array indices
                         $refs = array_values($refs);
                         $searchStrings = array_values($searchStrings);
                         foreach ($refs as $index => $ref) {
                             $searchString = $searchStrings[$index];
                             // Go through the matches, try to set directly if possible, defer otherwise
                             if ($this->bookKeeper->searchAndReplace($model, "{$field}.{$path}", $receivingId, $searchString, $ref)) {
                                 // It was set directly, update $fieldData with the set value
                                 Arr::set($fieldData, $path, Arr::get($model->{$field}, $path));
                             }
                         }
                     }
                 }
             }
         }
         $this->state->pop();
         // Debug
     }
     // Return transformed field data with db ids or temporarily set null values
     return $fieldData;
//.........这里部分代码省略.........
开发者ID:prewk,项目名称:seriquent,代码行数:101,代码来源:Deserializer.php

示例14: getOrdered

 /**
  * Get all ordered modules.
  *
  * @param string $direction
  *
  * @return array
  */
 public function getOrdered($direction = 'asc')
 {
     $modules = Arr::dot($this->all());
     uasort($modules, function ($a, $b) use($direction) {
         if ($a->getOrder() == $b->getOrder()) {
             return 0;
         }
         if ($direction == 'desc') {
             return $a->getOrder() < $b->getOrder() ? 1 : -1;
         }
         return $a->getOrder() > $b->getOrder() ? 1 : -1;
     });
     return $modules;
 }
开发者ID:jooorooo,项目名称:modulator,代码行数:21,代码来源:Modules.php

示例15: queryPayload

 /**
  * Query the payload using dot syntax to find specific data
  *
  * @param array       $payload
  * @param string|null $path
  *
  * @return mixed
  */
 private function queryPayload($payload, $path = null)
 {
     if (is_null($path)) {
         return $payload;
     }
     if (array_key_exists($path, $payload)) {
         return $payload[$path];
     }
     $dotData = Arr::dot($payload);
     if (array_key_exists($path, $dotData)) {
         return $dotData[$path];
     }
     return null;
 }
开发者ID:generationtux,项目名称:jwt-artisan,代码行数:22,代码来源:JwtToken.php


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