Skip to content

Change Command Name and fix Typo #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 14, 2022
Prev Previous commit
Next Next commit
Create an alias command and mark the old style as deprecated for futu…
…re major release.
  • Loading branch information
syntafin committed Aug 13, 2022
commit 4a8c56bd4314c64e80a9fab1b1856b2abf5120c0
69 changes: 69 additions & 0 deletions src/Console/OldPresenterMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Coderflex\LaravelPresenter\Console;

use Illuminate\Console\GeneratorCommand;

class PresenterMakeCommand extends GeneratorCommand
{
public $name = 'presenter:make';

public $description = '(Deprecated) Create a new presenter class';

/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Presenter';

/**
* Determine if the class already exists.
*
* @param string $rawName
* @return bool
*/
protected function alreadyExists($rawName)
{
return class_exists($rawName) ||
$this->files->exists($this->getPath($this->qualifyClass($rawName)));
}

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return $this->resolveStubPath('/stubs/presenter.stub');
}

/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
* @return string
*/
protected function resolveStubPath($stub)
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__ . $stub;
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
$configNamespace = config('laravel-presenter.presenter_namespace');

return is_null($configNamespace)
? $rootNamespace . '\Presenters'
: $configNamespace;
}
}