Scaffolder v2.0.0
  • Namespace
  • Class

Namespaces

  • Scaffolder
    • Commands
    • Compilers
      • Core
        • Api
      • Layout
      • View

Classes

  • Scaffolder\Commands\BaseCommand
  • Scaffolder\Commands\ClearCacheCommand
  • Scaffolder\Commands\GeneratorCommand
  • Scaffolder\Commands\InitializeApiCommand
  • Scaffolder\Compilers\AbstractCompiler
  • Scaffolder\Compilers\AbstractCoreCompiler
  • Scaffolder\Compilers\AbstractViewCompiler
  • Scaffolder\Compilers\Core\Api\ApiControllerCompiler
  • Scaffolder\Compilers\Core\Api\ApiModelCompiler
  • Scaffolder\Compilers\Core\Api\ApiRouteCompiler
  • Scaffolder\Compilers\Core\ControllerCompiler
  • Scaffolder\Compilers\Core\MigrationCompiler
  • Scaffolder\Compilers\Core\ModelCompiler
  • Scaffolder\Compilers\Core\RouteCompiler
  • Scaffolder\Compilers\Layout\CreateLayoutCompiler
  • Scaffolder\Compilers\Layout\EditLayoutCompiler
  • Scaffolder\Compilers\Layout\PageLayoutCompiler
  • Scaffolder\Compilers\View\CreateViewCompiler
  • Scaffolder\Compilers\View\DashboardViewCompiler
  • Scaffolder\Compilers\View\EditViewCompiler
  • Scaffolder\Compilers\View\IndexViewCompiler
  • Scaffolder\Compilers\View\LoginViewCompiler
  • Scaffolder\Compilers\View\WelcomeViewCompiler
  • Scaffolder\ScaffolderServiceProvider
 1 <?php
 2 
 3 namespace Scaffolder\Compilers;
 4 
 5 use Scaffolder\Support\FileToCompile;
 6 use stdClass;
 7 
 8 abstract class AbstractCompiler
 9 {
10     /**
11      * File stub.
12      * @var string
13      */
14     protected $stub;
15 
16 
17     /**
18      * Cache file extension.
19      */
20     const CACHE_EXT = '.scf';
21 
22     /**
23      * Store the compiled stub.
24      *
25      * @param $modelName
26      * @param \stdClass $scaffolderConfig
27      * @param $compiled
28      * @param \Scaffolder\Support\FileToCompile $fileToCompile
29      *
30      * @return mixed
31      */
32     abstract protected function store($modelName, stdClass $scaffolderConfig, $compiled, FileToCompile $fileToCompile);
33 
34     /**
35      * Replace the class name.
36      *
37      * @param $modelName
38      *
39      * @return $this
40      */
41     protected function replaceClassName($modelName)
42     {
43         $this->stub = str_replace('{{class_name}}', $modelName, $this->stub);
44         $this->stub = str_replace('{{class_name_lw}}', strtolower($modelName), $this->stub);
45 
46         return $this;
47     }
48 
49     /**
50      * Replace the namespace.
51      *
52      * @param \stdClass $scaffolderConfig
53      *
54      * @return $this
55      */
56     protected function replaceNamespace(stdClass $scaffolderConfig)
57     {
58         $this->stub = str_replace('{{namespace}}', $scaffolderConfig->namespaces->models, $this->stub);
59 
60         return $this;
61     }
62 
63     /**
64      * Tab helper.
65      *
66      * @param $size
67      *
68      * @return string
69      */
70     protected function tab($size)
71     {
72         return str_repeat('    ', $size);
73     }
74 }
75 
Scaffolder v2.0.0 API documentation generated by ApiGen