Skip to content

Commit

Permalink
merge config and translation files to make the package work without t…
Browse files Browse the repository at this point in the history
…he need of publishing config or translation
  • Loading branch information
cracker182 committed Jan 17, 2019
1 parent 3cc439e commit 681e11d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,3 +1,4 @@
composer.lock
vendor
.DS_Store
.DS_Store
.idea
9 changes: 7 additions & 2 deletions src/Providers/ReadTimeServiceProvider.php
Expand Up @@ -16,13 +16,16 @@ class ReadTimeServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->loadTranslationsFrom(__DIR__.'/../resources/lang/', 'read-time');

$this->publishes([
__DIR__ . '/../config/read-time.php' => config_path('read-time.php')
], 'read-time-config');

$this->publishes([
__DIR__ . "/../resources/lang/" => resource_path("lang/")
__DIR__ . "/../resources/lang/" => resource_path("lang/vendor/read-time")
], 'read-time-language-files');

}

/**
Expand All @@ -37,13 +40,15 @@ public function register()
throw new Exception('Content must be supplied to ReadTime class');
}

$this->mergeConfigFrom(__DIR__.'/../config/read-time.php', 'read-time');

$content = $data['content'];
$omitSeconds = isset($data['omit_seconds']) ? $data['omit_seconds'] : config('read-time.omit_seconds');
$timeOnly = isset($data['time_only']) ? $data['time_only'] : config('read-time.time_only');
$abbreviated = isset($data['abbreviated']) ? $data['abbreviated'] : config('read-time.abbreviate_time_measurements');
$wordsPerMinute = isset($data['words_per_minute']) ? $data['words_per_minute'] : config('read-time.words_per_minute');
$ltr = isset($data['ltr']) ? $data['ltr'] : __('read-time.reads_left_to_right');
$translation = isset($data['translation']) ? $data['translation'] : __('read-time');
$translation = isset($data['translation']) ? $data['translation'] : __('read-time::read-time');

return (new ReadTime($content))
->omitSeconds($omitSeconds)
Expand Down

0 comments on commit 681e11d

Please sign in to comment.