Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 28, 2023
1 parent 169a4f0 commit d9133ca
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 56 deletions.
29 changes: 28 additions & 1 deletion src/Commands/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@

use Illuminate\Filesystem\Filesystem;
use Orchestra\Canvas\Core\Concerns;
use Orchestra\Canvas\Core\Contracts\GeneratesCode;

/**
* @property string|null $name
* @property string|null $description
*/
abstract class GeneratorCommand extends \Illuminate\Console\GeneratorCommand
abstract class GeneratorCommand extends \Illuminate\Console\GeneratorCommandd implements GeneratesCode
{
use Concerns\CodeGenerator;
use Concerns\TestGenerator;
use Concerns\ResolvesPresetStubsOverrides;
use Concerns\UsesGeneratorOverrides;

/**
* Execute the console command.
*
* @return bool|null
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function handle()
{
return $this->generateCode() ? self::SUCCESS : self::FAILURE;
}

/**
* Get the destination class path.
*
Expand Down Expand Up @@ -83,4 +99,15 @@ protected function possibleEvents()
{
return $this->possibleEventsUsingCanvas();
}

/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
* @return string
*/
protected function resolveStubPath(string $stub)
{
return $this->resolveStubPathUsingCanvas($stub);
}
}
1 change: 1 addition & 0 deletions src/Concerns/CodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Orchestra\Canvas\Core\Concerns;

use Illuminate\Console\Concerns\CreatesMatchingTest;
use Illuminate\Console\Concerns\CreatesUsingGeneratorPreset;
use Illuminate\Support\Str;

trait CodeGenerator
Expand Down
49 changes: 0 additions & 49 deletions src/Concerns/CreatesUsingGeneratorPreset.php

This file was deleted.

2 changes: 2 additions & 0 deletions src/Concerns/MigrationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Orchestra\Canvas\Core\Concerns;

use Illuminate\Console\Concerns\CreatesUsingGeneratorPreset;

trait MigrationGenerator
{
use CreatesUsingGeneratorPreset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Orchestra\Canvas\Core\Concerns;

trait ResolvesPresetStubs
trait ResolvesPresetStubsOverrides
{
/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
* @return string
*/
protected function resolveStubPath($stub)
protected function resolveStubPathUsingCanvas(string $stub): string
{
$preset = $this->generatorPreset();

Expand All @@ -25,8 +25,5 @@ protected function resolveStubPath($stub)
* @param string $stub
* @return string
*/
protected function resolveDefaultStubPath($stub)
{
return $stub;
}
abstract protected function resolveDefaultStubPath($stub);
}

0 comments on commit d9133ca

Please sign in to comment.