Browse Source

Add Generator interface as generator class contract

tags/1.1.4
Nafies Luthfi 8 years ago
parent
commit
912fecd9a6
  1. 22
      src/Contracts/Generator.php
  2. 6
      src/GeneratorCommand.php
  3. 21
      src/Generators/BaseGenerator.php
  4. 2
      src/Generators/FeatureTestGenerator.php
  5. 2
      src/Generators/FormViewGenerator.php
  6. 2
      src/Generators/IndexViewGenerator.php
  7. 2
      src/Generators/LangFileGenerator.php
  8. 2
      src/Generators/MigrationGenerator.php
  9. 2
      src/Generators/ModelFactoryGenerator.php
  10. 2
      src/Generators/ModelGenerator.php
  11. 2
      src/Generators/ModelPolicyGenerator.php
  12. 2
      src/Generators/ModelPolicyTestGenerator.php
  13. 2
      src/Generators/ModelTestGenerator.php
  14. 2
      src/Generators/RouteGenerator.php
  15. 2
      src/Generators/ShowViewGenerator.php

22
src/Contracts/Generator.php

@ -0,0 +1,22 @@
<?php
namespace Luthfi\CrudGenerator\Contracts;
interface Generator
{
/**
* Generate class file content.
*
* @param string $type Type of crud
* @return void
*/
public function generate(string $type = 'full');
/**
* Get class file content.
*
* @param string $stubName Name of stub file
* @return string
*/
public function getContent(string $stubName);
}

6
src/GeneratorCommand.php

@ -3,8 +3,8 @@
namespace Luthfi\CrudGenerator;
use Illuminate\Console\Command;
use Illuminate\Console\DetectsApplicationNamespace;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Console\DetectsApplicationNamespace;
class GeneratorCommand extends Command
{
@ -53,9 +53,9 @@ class GeneratorCommand extends Command
}
/**
* Generate class properties for model names in different usage
* Generate class properties for model names in different usage.
*
* @return void
* @return array
*/
public function getModelName($modelName = null)
{

21
src/Generators/BaseGenerator.php

@ -2,14 +2,15 @@
namespace Luthfi\CrudGenerator\Generators;
use Illuminate\Console\DetectsApplicationNamespace;
use Illuminate\Filesystem\Filesystem;
use Luthfi\CrudGenerator\GeneratorCommand;
use Illuminate\Console\DetectsApplicationNamespace;
use Luthfi\CrudGenerator\Contracts\Generator as GeneratorContract;
/**
* Base Generator Class
*/
abstract class BaseGenerator
abstract class BaseGenerator implements GeneratorContract
{
use DetectsApplicationNamespace;
@ -71,22 +72,6 @@ abstract class BaseGenerator
}
/**
* Generate class file content
*
* @param string $type Type of crud
* @return void
*/
abstract public function generate(string $type = 'full');
/**
* Get class file content
*
* @param string $stubName Name of stub file
* @return void
*/
abstract protected function getContent(string $stubName);
/**
* Make directory if the path is not exists
*
* @param string $path Absolute path of targetted directory

2
src/Generators/FeatureTestGenerator.php

@ -33,7 +33,7 @@ class FeatureTestGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$stub = $this->getStubFileContent($stubName);
$baseTestClass = config('simple-crud.base_test_class');

2
src/Generators/FormViewGenerator.php

@ -27,7 +27,7 @@ class FormViewGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
return $this->replaceStubString($this->getStubFileContent($stubName));
}

2
src/Generators/IndexViewGenerator.php

@ -22,7 +22,7 @@ class IndexViewGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
return $this->replaceStubString($this->getStubFileContent($stubName));
}

2
src/Generators/LangFileGenerator.php

@ -25,7 +25,7 @@ class LangFileGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$langStubPath = __DIR__.'/../stubs/'.$stubName.'.stub';

2
src/Generators/MigrationGenerator.php

@ -26,7 +26,7 @@ class MigrationGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
return $this->replaceStubString($this->getStubFileContent($stubName));
}

2
src/Generators/ModelFactoryGenerator.php

@ -25,7 +25,7 @@ class ModelFactoryGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$modelFactoryFileContent = $this->getStubFileContent($stubName);

2
src/Generators/ModelGenerator.php

@ -26,7 +26,7 @@ class ModelGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$modelFileContent = $this->getStubFileContent($stubName);

2
src/Generators/ModelPolicyGenerator.php

@ -31,7 +31,7 @@ class ModelPolicyGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$stub = $this->getStubFileContent($stubName);

2
src/Generators/ModelPolicyTestGenerator.php

@ -25,7 +25,7 @@ class ModelPolicyTestGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$stub = $this->getStubFileContent($stubName);
$baseTestClass = config('simple-crud.base_test_class');

2
src/Generators/ModelTestGenerator.php

@ -25,7 +25,7 @@ class ModelTestGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$modelFileContent = $this->getStubFileContent($stubName);

2
src/Generators/RouteGenerator.php

@ -22,7 +22,7 @@ class RouteGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
$stub = $this->getStubFileContent($stubName);

2
src/Generators/ShowViewGenerator.php

@ -22,7 +22,7 @@ class ShowViewGenerator extends BaseGenerator
/**
* {@inheritDoc}
*/
protected function getContent(string $stubName)
public function getContent(string $stubName)
{
return $this->replaceStubString($this->getStubFileContent($stubName));
}

Loading…
Cancel
Save