Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 399
Zeile 1... Zeile 1...
1
<?php
1
<?php
Zeile 2... Zeile 2...
2
 
2
 
Zeile 3... Zeile 3...
3
namespace Illuminate\Console;
3
namespace Illuminate\Console;
-
 
4
 
4
 
5
use Illuminate\Console\Concerns\CreatesMatchingTest;
5
use Illuminate\Console\Concerns\CreatesMatchingTest;
6
use Illuminate\Contracts\Console\PromptsForMissingInput;
6
use Illuminate\Filesystem\Filesystem;
7
use Illuminate\Filesystem\Filesystem;
-
 
8
use Illuminate\Support\Str;
Zeile 7... Zeile 9...
7
use Illuminate\Support\Str;
9
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Finder\Finder;
9
 
11
 
10
abstract class GeneratorCommand extends Command
12
abstract class GeneratorCommand extends Command implements PromptsForMissingInput
11
{
13
{
12
    /**
14
    /**
Zeile 232... Zeile 234...
232
                    ? $rootNamespace.'Models\\'.$model
234
                    ? $rootNamespace.'Models\\'.$model
233
                    : $rootNamespace.$model;
235
                    : $rootNamespace.$model;
234
    }
236
    }
Zeile 235... Zeile 237...
235
 
237
 
-
 
238
    /**
-
 
239
     * Get a list of possible model names.
-
 
240
     *
-
 
241
     * @return array<int, string>
-
 
242
     */
-
 
243
    protected function possibleModels()
-
 
244
    {
-
 
245
        $modelPath = is_dir(app_path('Models')) ? app_path('Models') : app_path();
-
 
246
 
-
 
247
        return collect((new Finder)->files()->depth(0)->in($modelPath))
-
 
248
            ->map(fn ($file) => $file->getBasename('.php'))
-
 
249
            ->values()
-
 
250
            ->all();
-
 
251
    }
-
 
252
 
-
 
253
    /**
-
 
254
     * Get a list of possible event names.
-
 
255
     *
-
 
256
     * @return array<int, string>
-
 
257
     */
-
 
258
    protected function possibleEvents()
-
 
259
    {
-
 
260
        $eventPath = app_path('Events');
-
 
261
 
-
 
262
        if (! is_dir($eventPath)) {
-
 
263
            return [];
-
 
264
        }
-
 
265
 
-
 
266
        return collect((new Finder)->files()->depth(0)->in($eventPath))
-
 
267
            ->map(fn ($file) => $file->getBasename('.php'))
-
 
268
            ->values()
-
 
269
            ->all();
-
 
270
    }
-
 
271
 
236
    /**
272
    /**
237
     * Get the default namespace for the class.
273
     * Get the default namespace for the class.
238
     *
274
     *
239
     * @param  string  $rootNamespace
275
     * @param  string  $rootNamespace
240
     * @return string
276
     * @return string
Zeile 434... Zeile 470...
434
     * @return array
470
     * @return array
435
     */
471
     */
436
    protected function getArguments()
472
    protected function getArguments()
437
    {
473
    {
438
        return [
474
        return [
439
            ['name', InputArgument::REQUIRED, 'The name of the class'],
475
            ['name', InputArgument::REQUIRED, 'The name of the '.strtolower($this->type)],
-
 
476
        ];
-
 
477
    }
-
 
478
 
-
 
479
    /**
-
 
480
     * Prompt for missing input arguments using the returned questions.
-
 
481
     *
-
 
482
     * @return array
-
 
483
     */
-
 
484
    protected function promptForMissingArgumentsUsing()
-
 
485
    {
-
 
486
        return [
-
 
487
            'name' => 'What should the '.strtolower($this->type).' be named?',
440
        ];
488
        ];
441
    }
489
    }
442
}
490
}