sirgrimorum /
transarticles
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Sirgrimorum\TransArticles; |
||||
| 4 | |||||
| 5 | use Illuminate\Support\ServiceProvider; |
||||
| 6 | use Illuminate\Support\Facades\Blade; |
||||
| 7 | use Illuminate\Foundation\AliasLoader; |
||||
| 8 | use Sirgrimorum\TransArticles\GetArticleFromDataBase; |
||||
| 9 | use Illuminate\Support\Facades\Artisan; |
||||
| 10 | |||||
| 11 | class TransArticlesServiceProvider extends ServiceProvider {
|
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * Perform post-registration booting of services. |
||||
| 15 | * |
||||
| 16 | * @return void |
||||
| 17 | */ |
||||
| 18 | public function boot() |
||||
| 19 | {
|
||||
| 20 | $this->publishes([ |
||||
| 21 | __DIR__ . '/Config/transarticles.php' => config_path('sirgrimorum/transarticles.php'),
|
||||
| 22 | ], 'config'); |
||||
| 23 | $this->loadMigrationsFrom(__DIR__ . '/Migrations'); |
||||
| 24 | |||||
| 25 | Blade::directive('transarticles', function($nickname) {
|
||||
| 26 | $translations = new \Sirgrimorum\TransArticles\GetArticleFromDataBase($this->app); |
||||
| 27 | return $translations->get(str_replace(['(', ')', ' ', '"', "'"], '', $nickname));
|
||||
| 28 | }); |
||||
| 29 | Blade::directive('transarticles_tojs', function($expression) {
|
||||
| 30 | $auxExpression = explode(',', str_replace(['(', ')', ' ', '"', "'"], '', $expression));
|
||||
| 31 | if (count($auxExpression) > 1) |
||||
| 32 | {
|
||||
| 33 | $scope = $auxExpression[0]; |
||||
| 34 | $basevar = $auxExpression[1]; |
||||
| 35 | } |
||||
| 36 | else |
||||
| 37 | {
|
||||
| 38 | $scope = $auxExpression[0]; |
||||
| 39 | $basevar = ""; |
||||
| 40 | } |
||||
| 41 | $translations = new \Sirgrimorum\TransArticles\GetArticleFromDataBase($this->app); |
||||
| 42 | return $translations->getjs($scope, $basevar); |
||||
| 43 | }); |
||||
| 44 | |||||
| 45 | Artisan::command('transarticles:createseed {--all : Create a seed for all database tables except migrations table} {--force : Force the iseed}', function () {
|
||||
| 46 | $options = $this->options('all');
|
||||
|
0 ignored issues
–
show
|
|||||
| 47 | if ($options['all']) {
|
||||
| 48 | $dbName = env('DB_DATABASE');
|
||||
| 49 | |||||
| 50 | $query = \DB::select("SHOW TABLES WHERE Tables_in_$dbName <> 'migrations'");
|
||||
| 51 | $collection = new \Illuminate\Support\Collection($query); |
||||
| 52 | $tables = $collection->implode("Tables_in_$dbName",',');
|
||||
| 53 | $options = $this->options('force');
|
||||
| 54 | if ($options['force']) {
|
||||
| 55 | $nombre = ""; |
||||
| 56 | }else{
|
||||
| 57 | $nombre = date("YmdHis");
|
||||
| 58 | } |
||||
| 59 | $this->info('Calling iseed for all tables except migrations with suffix "{$nombre}" ...');
|
||||
|
0 ignored issues
–
show
The method
info() does not exist on Sirgrimorum\TransArticle...ArticlesServiceProvider.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 60 | $this->call('iseed', [
|
||||
|
0 ignored issues
–
show
The method
call() does not exist on Sirgrimorum\TransArticle...ArticlesServiceProvider.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 61 | 'tables' => $tables, |
||||
| 62 | '--classnamesuffix' => $nombre, |
||||
| 63 | '--chunksize' => "100", |
||||
| 64 | '--force' => $options['force'], |
||||
| 65 | ]); |
||||
| 66 | }else{
|
||||
| 67 | $bar = $this->output->createProgressBar(2); |
||||
|
0 ignored issues
–
show
|
|||||
| 68 | $confirm = $this->choice("Do you wisth to clean the DatabaseSeeder.php list?", ['yes', 'no'], 0);
|
||||
|
0 ignored issues
–
show
The method
choice() does not exist on Sirgrimorum\TransArticle...ArticlesServiceProvider.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 69 | $bar->advance(); |
||||
| 70 | $nombre = date("YmdHis");
|
||||
| 71 | if ($confirm == 'yes') {
|
||||
| 72 | $this->line("Creating seed archive of articles table and celaning DatabaseSeeder");
|
||||
|
0 ignored issues
–
show
The method
line() does not exist on Sirgrimorum\TransArticle...ArticlesServiceProvider.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 73 | Artisan::call("iseed articles --classnamesuffix={$nombre} --chunksize=100 --clean");
|
||||
| 74 | } else {
|
||||
| 75 | $this->line("Creating seed archive of articles table and adding to DatabaseSeeder list");
|
||||
| 76 | Artisan::call("iseed articles --classnamesuffix={$nombre} --chunksize=100");
|
||||
| 77 | } |
||||
| 78 | $this->info("Seed file created with the name Articles{$nombre}Seeder.php");
|
||||
| 79 | $bar->advance(); |
||||
| 80 | $bar->finish(); |
||||
| 81 | } |
||||
| 82 | })->describe('Create a seeder file with the current table Articles');
|
||||
| 83 | } |
||||
| 84 | |||||
| 85 | /** |
||||
| 86 | * Register any package services. |
||||
| 87 | * |
||||
| 88 | * @return void |
||||
| 89 | */ |
||||
| 90 | public function register() |
||||
| 91 | {
|
||||
| 92 | //AliasLoader::getInstance()->alias('TransArticles', GetArticleFromDataBase::class);
|
||||
| 93 | $loader = AliasLoader::getInstance(); |
||||
| 94 | $loader->alias( |
||||
| 95 | 'TransArticles', GetArticleFromDataBase::class |
||||
| 96 | ); |
||||
| 97 | $this->app->singleton(GetArticleFromDataBase::class, function($app) {
|
||||
| 98 | return new GetArticleFromDataBase($app); |
||||
| 99 | }); |
||||
| 100 | //$this->app->alias(GetArticleFromDataBase::class, 'TransArticles'); |
||||
| 101 | $this->mergeConfigFrom( |
||||
| 102 | __DIR__ . '/Config/transarticles.php', 'sirgrimorum.transarticles' |
||||
| 103 | ); |
||||
| 104 | } |
||||
| 105 | |||||
| 106 | } |
||||
| 107 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.