@@ -84,9 +84,6 @@ public function execute(object $sender, CommandEventArgs $args): void
8484 case 'controller ' :
8585 $ result = self ::createController ($ namespace , $ className , $ basePath );
8686 break ;
87- case 'entity ' :
88- $ result = self ::createEntity ($ namespace , $ className , $ basePath );
89- break ;
9087 case 'migration ' :
9188 $ result = self ::createMigration ($ namespace , $ className , $ basePath );
9289 break ;
@@ -127,15 +124,8 @@ public static function createClass(string $namespace, ?string $className, ?strin
127124 $ context ->appendLine ();
128125 $ context ->appendLine ("namespace {$ namespace }; " );
129126 $ context ->appendLine ();
130- $ context ->appendLine ('use DevNet\System\Collections\ArrayList; ' );
131- $ context ->appendLine ('use DevNet\System\Linq; ' );
132- $ context ->appendLine ();
133127 $ context ->appendLine ("class {$ className }" );
134128 $ context ->appendLine ('{ ' );
135- $ context ->appendLine (' public function __construct() ' );
136- $ context ->appendLine (' { ' );
137- $ context ->appendLine (' // code... ' );
138- $ context ->appendLine (' } ' );
139129 $ context ->appendLine ('} ' );
140130
141131 if (!is_dir ($ destination )) {
@@ -195,58 +185,6 @@ public static function createController(string $namespace, ?string $className, ?
195185 return false ;
196186 }
197187
198- public static function createEntity (string $ namespace , ?string $ className , ?string $ basePath ): bool
199- {
200- $ basePath = $ basePath ?? 'Models ' ;
201- $ destination = implode ('/ ' , [getcwd (), $ basePath ]);
202- $ namespace = implode ('\\' , [$ namespace , $ basePath ]);
203- $ namespace = str_replace ('/ ' , '\\' , $ namespace );
204- $ namespace = rtrim ($ namespace , '\\' );
205- $ namespace = ucwords ($ namespace , '\\' );
206- $ className = $ className ?? 'MyEntity ' ;
207- $ className = ucfirst ($ className );
208-
209- $ context = new StringBuilder ();
210- $ context ->appendLine ('<?php ' );
211- $ context ->appendLine ();
212- $ context ->appendLine ("namespace {$ namespace }; " );
213- $ context ->appendLine ();
214- $ context ->appendLine ('use DevNet\Entity\IEntity; ' );
215- $ context ->appendLine ();
216- $ context ->appendLine ("class {$ className } implements IEntity " );
217- $ context ->appendLine ('{ ' );
218- $ context ->appendLine (' private int $Id; ' );
219- $ context ->appendLine ();
220- $ context ->appendLine (' public function __get(string $name) ' );
221- $ context ->appendLine (' { ' );
222- $ context ->appendLine (' return $this->$name; ' );
223- $ context ->appendLine (' } ' );
224- $ context ->appendLine ();
225- $ context ->appendLine (' public function __set(string $name, $value) ' );
226- $ context ->appendLine (' { ' );
227- $ context ->appendLine (' if (!property_exists($this, $name)) ' );
228- $ context ->appendLine (' { ' );
229- $ context ->appendLine (' throw new \Exception("The property {$name} doesn \'t exist."); ' );
230- $ context ->appendLine (' } ' );
231- $ context ->appendLine (' $this->$name = $value; ' );
232- $ context ->appendLine (' } ' );
233- $ context ->appendLine ('} ' );
234-
235- if (!is_dir ($ destination )) {
236- mkdir ($ destination , 0777 , true );
237- }
238-
239- $ myfile = fopen ($ destination . '/ ' . $ className . '.php ' , 'w ' );
240- $ size = fwrite ($ myfile , $ context ->__toString ());
241- $ status = fclose ($ myfile );
242-
243- if ($ size && $ status ) {
244- return true ;
245- }
246-
247- return false ;
248- }
249-
250188 public static function createMigration (string $ namespace , ?string $ className , ?string $ basePath ): bool
251189 {
252190 $ basePath = $ basePath ?? 'Migrations ' ;
@@ -309,7 +247,6 @@ public function showHelp()
309247 Console::writeline ('templates: ' );
310248 Console::writeline (' class Simple Class ' );
311249 Console::writeline (' controller Controller Class ' );
312- Console::writeline (' entity Entity Class ' );
313250 Console::writeline (' migration Migration Class ' );
314251 Console::writeline ();
315252 exit ;
0 commit comments