本文整理汇总了PHP中array_dot函数的典型用法代码示例。如果您正苦于以下问题:PHP array_dot函数的具体用法?PHP array_dot怎么用?PHP array_dot使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_dot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadPath
/**
* Load a locale from a given path.
*
* @param string $path
* @param string $locale
* @param string $group
* @return array
*/
protected function loadPath($path, $locale, $group)
{
if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
return array_dot($this->files->getRequire($full));
}
return array();
}
示例2: getTranslations
/**
* Get locale translations.
*
* @return array
*/
public function getTranslations()
{
$translations = array_map(function ($file) {
return $file['content'];
}, $this->files);
return array_dot($translations);
}
示例3: importTranslations
public function importTranslations($replace = false)
{
$counter = 0;
foreach ($this->files->directories($this->app->langPath()) as $langPath) {
$locale = basename($langPath);
foreach ($this->files->files($langPath) as $file) {
$info = pathinfo($file);
$group = $info['filename'];
if (in_array($group, $this->config['exclude_groups'])) {
continue;
}
$translations = \Lang::getLoader()->load($locale, $group);
if ($translations && is_array($translations)) {
foreach (array_dot($translations) as $key => $value) {
$value = (string) $value;
$translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
// Check if the database is different then the files
$newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
if ($newStatus !== (int) $translation->status) {
$translation->status = $newStatus;
}
// Only replace when empty, or explicitly told so
if ($replace || !$translation->value) {
$translation->value = $value;
}
$translation->save();
$counter++;
}
}
}
}
return $counter;
}
示例4: register
/** {@inheritDoc} */
public function register()
{
/** @var \Illuminate\Foundation\Application $app */
$app = parent::register();
$config = array_dot($this->app['config']['blade_extensions']);
if ($config['example_views'] === true) {
$this->viewDirs = ['views' => 'blade-ext'];
}
AssignmentDirectives::attach($app);
DebugDirectives::attach($app);
ForeachDirectives::attach($app);
EmbeddingDirectives::attach($app);
MacroDirectives::attach($app);
MinifyDirectives::attach($app);
# Optional markdown compiler, engines and directives
if ($config['markdown.enabled']) {
if (!class_exists($config['markdown.renderer'])) {
throw new Exception('The configured markdown renderer class does not exist');
}
$app->bind('Radic\\BladeExtensions\\Contracts\\MarkdownRenderer', $config['markdown.renderer']);
$app->singleton('markdown', function (Application $app) {
return $app->make('Radic\\BladeExtensions\\Contracts\\MarkdownRenderer');
});
$app->singleton('markdown.compiler', function (Application $app) {
$markdownRenderer = $app->make('markdown');
$files = $app->make('files');
$storagePath = $app['config']->get('view.compiled');
return new MarkdownCompiler($markdownRenderer, $files, $storagePath);
});
MarkdownDirectives::attach($app);
}
}
示例5: merge
public function merge($items)
{
foreach (array_dot($items) as $key => $value) {
$this->set($key, $value);
}
return $this;
}
示例6: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire(Filesystem $files)
{
$langDirectory = base_path('resources' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR);
$diff = [];
foreach (ModulesLoader::getRegisteredModules() as $module) {
if (!is_dir($module->getLocalePath()) or !$module->isPublishable()) {
continue;
}
$locale = $this->input->getOption('locale');
foreach ($files->directories($module->getLocalePath()) as $localeDir) {
foreach ($files->allFiles($localeDir) as $localeFile) {
$vendorFileDir = $module->getKey() . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $localeFile->getFilename();
$vendorFilePath = $langDirectory . $vendorFileDir;
if (file_exists($vendorFilePath)) {
$localArray = $files->getRequire($localeFile->getRealPath());
$vendorArray = $files->getRequire($vendorFilePath);
$array = array_keys_exists_recursive($localArray, $vendorArray);
$arrayDiff = '';
foreach (array_dot($array) as $key => $value) {
$arrayDiff .= "{$key}: {$value}\n";
}
if (empty($arrayDiff)) {
continue;
}
$diff[] = ['modules' . DIRECTORY_SEPARATOR . $vendorFileDir, 'vendor' . DIRECTORY_SEPARATOR . $vendorFileDir];
$diff[] = new TableSeparator();
$diff[] = [$arrayDiff, var_export(array_merge_recursive($array, $vendorArray), true)];
$diff[] = new TableSeparator();
}
}
}
}
$this->table($this->headers, $diff);
}
示例7: evaluateOne
public function evaluateOne($text, $dependencies = [])
{
$parts = explode('>', $text);
if (count($parts) < 2) {
return '';
}
if ($parts[0] == 'Dict') {
$default = '';
$item = $this->getOneDict($parts[1], $default);
if (count($parts) == 3) {
$array = array_dot($item->toArray());
if (!array_key_exists($parts[2], $array)) {
return '';
}
return $array[$parts[2]];
}
return $item;
} else {
$identifier = $parts[1];
if (starts_with($identifier, ':')) {
$identifier = str_replace(':', '', $identifier);
$identifier = $dependencies[$identifier];
}
$item = $this->getOneEntity($parts[0], $identifier);
if (!$item) {
return '';
}
$array = array_dot($item->toArray());
if (!array_key_exists($parts[2], $array)) {
return '';
}
return $array[$parts[2]];
}
}
示例8: handle
/**
* Handler
*
* @param \Illuminate\Contracts\Mail\Mailer $mailer
* @param \Illuminate\Contracts\View\Factory $view
* @param \Illuminate\Contracts\Validation\Factory $validator
* @throws \Exception
* @return void
*/
public function handle(Mailer $mailer, Factory $view, Validator $validator)
{
$queue = $this->messageQueue;
$queue->status = 'in_processes';
$queue->save();
$queue->load('event', 'event.template');
$parameters = array_merge_recursive($queue->event->template->parameters, $queue->event->parameters, $queue->parameters);
$messageParameters = array_dot($this->getMessageParameters($validator, $parameters['message']));
$renderView = $queue->event->template->getRender($parameters['view']);
$mailer->send('message-sender::providers.plain', ['content' => $renderView], function ($message) use($parameters, $messageParameters) {
$message->from($messageParameters['from.address'], $messageParameters['from.name']);
$message->to($messageParameters['to.address'], $messageParameters['from.name']);
$message->subject($parameters['provider']['subject']);
if (isset($parameters['provider']['headers'])) {
$mailHeaders = $message->getSwiftMessage()->getHeaders();
foreach ($parameters['provider']['headers'] as $header) {
$mailHeaders->addTextHeader($header['name'], $header['value']);
}
}
});
if (count($mailer->failures()) > 0) {
throw new \Exception('Mail send failed.');
} else {
$queue->status = 'sent';
$queue->save();
}
}
示例9: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
if (!$this->isInstalled()) {
$this->app['command.twostream.install'] = $this->app->share(function ($app) {
return new Install($this->getAppNamespace());
});
return $this->commands(['command.twostream.install']);
}
parent::register();
$this->app['command.twostream.listen'] = $this->app->share(function ($app) {
return new Server($app);
});
$this->app['command.twostream.stop'] = $this->app->share(function ($app) {
return new Stop();
});
$this->commands($this->commands);
$this->mergeConfigFrom(__DIR__ . '/../config/twostream.php', 'twostream');
$this->app->bindShared('CupOfTea\\TwoStream\\Contracts\\Factory', function ($app) {
$config = array_dot($this->app['config']['twostream']);
return new TwoStream($config);
});
$this->app->bindShared('CupOfTea\\TwoStream\\Contracts\\Session\\ReadOnly', function ($app) {
return new ReadOnly($this->app['config']['session.cookie']);
});
}
示例10: getGeneratorVars
/**
* getVars
*
* @param null $packageName
* @return array
*/
public function getGeneratorVars($directory)
{
$stubDir = $this->docit->config('stubs_path');
$destDir = $this->docit->getRootDir() . DIRECTORY_SEPARATOR . $directory;
$vars = ['config' => array_dot($this->docit->config()), 'open' => '<?php', 'stubDir' => $stubDir, 'destDir' => $destDir, 'directory' => $directory];
return $vars;
}
示例11: process
public function process(Request $request)
{
// Ajax-validation is only possible, if the _formID was submitted (automatically done by the FormBuilder).
if (\Request::has('_formID')) {
// The FormBuilder should have saved the requestObject this form uses inside the session.
// We check, if it is there, and can continue only, if it is.
$sessionKeyForRequestObject = 'htmlBuilder.formBuilder.requestObjects.' . \Request::input('_formID');
if (Session::has($sessionKeyForRequestObject)) {
// Normally we assume a successful submission and return just an empty JSON-array.
$returnCode = 200;
$return = [];
// We instantiate the requestObject.
$formRequest = FormBuilderTools::getRequestObject(Session::get($sessionKeyForRequestObject));
// We instantiate a controller with the submitted request-data
// and the rules and messages from the requestObject.
$validator = Validator::make(\Request::all(), $formRequest->rules(), $formRequest->messages());
// Perform validation, extract error-messages for all fields on failure, put them inside a $return['errors']-array, and return status code 422.
if ($validator->fails()) {
$errors = [];
foreach (array_dot(\Request::all()) as $fieldName => $fieldValue) {
$fieldErrors = FormBuilderTools::extractErrorsForField($fieldName, $validator->errors()->getMessages(), \Request::all());
if (count($fieldErrors) > 0) {
$errors[FormBuilderTools::convertArrayFieldDotNotation2HtmlName($fieldName)] = $fieldErrors;
}
}
$return['errors'] = $errors;
$returnCode = 422;
}
return new JsonResponse($return, $returnCode);
}
}
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 403);
} else {
return redirect()->guest('auth/login');
}
}
if (!$request->user()->isAdmin() && $request->user()->cannot('dashboard_view')) {
$this->auth->logout();
return redirect()->guest('auth/login')->withErrors(trans('messages.permission_denied'));
}
$route_array = explode('.', $request->route()->getName());
$permission_name = array_search($route_array[2], array_dot($this->permission_fields));
if ($permission_name) {
$route_array[2] = explode('.', $permission_name)[0];
}
// $route_name = implode('_', $route_array);
$route_name = $route_array[1] . '_' . $route_array[2];
if (!$request->user()->isAdmin() && $request->user()->cannot($route_name)) {
//PATCH 为null
if ($request->ajax()) {
return response()->json(['status' => trans('messages.permission_denied'), 'type' => 'error', 'code' => 403]);
} else {
return view('errors.403');
}
}
return $next($request);
}
示例13: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
//
$tutorials = objectToArray(DB::select(DB::raw('select id from tutorials')));
$tutorials = array_dot($tutorials);
$students = array_dot(objectToArray(DB::select(DB::raw('SELECT `user_id` as `id` from `students`'))));
$teachers = array_dot(objectToArray(DB::select(DB::raw('SELECT `user_id` as `id` from `teachers`'))));
$subjects = array_dot(objectToArray(DB::select(DB::raw('SELECT id from subjects'))));
$minimum = $this->option('minimum');
$assessmenttitle = "This is a {title|heading|header} for Assessment.";
$assessmentdesc = "This is a sample {data|words|description} for Assessment.";
for ($i = 1; $i <= $minimum; $i++) {
$assessment = new Assessments();
$assessment->title = self::spintax($assessmenttitle);
$assessment->description = self::spintax($assessmentdesc);
$assessment->assessmenttype = "presentation";
$assessment->tutorialid = rand(1, 100);
$assessment->teacherid = array_rand($teachers);
$assessment->subjectid = rand(1, 55);
$assessment->studentid = array_rand($students);
$assessment->marks = rand(75, 100);
$assessment->created_at = self::randDate('10th January 2013', date('jS F o'));
$assessment->save();
}
}
示例14: write
/**
* {@inheritdoc}
*/
protected function write(array $storage)
{
$storage = array_dot($storage);
$update = array();
// key-value pairs to be updated later
$delete = array();
// key-value pairs to be deleted later
$keys = Setting::withTrashed()->lists('key');
// existing keys
// check what keys we have to update/create and which to delete
foreach ($keys as $key) {
if (isset($storage[$key])) {
$update[$key] = $storage[$key];
} else {
$delete[] = $key;
}
unset($storage[$key]);
}
// $update now keeps only those key-value pairs which are to be updated
foreach ($update as $key => $value) {
Setting::withTrashed()->where('key', $key)->update(['value' => $value]);
$setting = Setting::withTrashed()->where('key', $key)->first();
if ($setting->trashed()) {
$setting->restore();
}
}
// $storage now keeps only those key-value pairs which are to be created
foreach ($storage as $key => $value) {
Setting::create(['key' => $key, 'value' => $value]);
}
// $delete now keeps only those key-value pairs which are to be deleted
Setting::whereIn('key', $delete)->delete();
}
示例15: index
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
// dd(hash_file('crc32b', app_path('Support/helpers.php')));
// hash_file(app_path(), filename);
// dd(disk_free_space('/') / disk_total_space('/') * 100);
function outputList($list)
{
$out = '<ul>';
foreach ($list as $key => $value) {
$out .= '<li class="' . (is_array($value) ? 'array' : 'string') . '">';
$out .= '<h2 style="display:inline;">' . $key . '</h2> ';
$out .= is_array($value) ? outputList($value) : $value;
$out .= '</li>';
}
$out .= '</ul>';
return $out;
}
// $trans = trans('copy.site.title');
// $output = [];
// foreach ($trans as $key => $value) {
// $output[md5($key)] = $key;
// }
// return $output;
// return $trans;
$lang = ['passwords' => trans('passwords'), 'pagination' => trans('pagination'), 'validation' => trans('validation'), 'copy' => trans('copy')];
$langDot = array_dot($lang);
$langFinal = [];
foreach ($langDot as $key => $value) {
array_set($langFinal, $key, $value);
}
$langinfo = outputList($langFinal);
return $this->view('welcome')->with('langinfo', $langinfo);
}