|
1 | | -<?php |
2 | | -namespace Themes\VuetifyCore\Cli; |
3 | | - |
4 | | -use WebFiori\Cli\Command; |
5 | | - |
6 | | - |
7 | | -/** |
8 | | - * A command which can be used to create a Vuetify based theme template. |
9 | | - * |
10 | | - * @author Ibrahim |
11 | | - */ |
12 | | -class CreateVuetifyThemeCommand extends Command { |
13 | | - /** |
14 | | - * Creates new instance of the class. |
15 | | - */ |
16 | | - public function __construct() { |
17 | | - parent::__construct('create-vuetify-theme', [ |
18 | | - ], 'Creates a theme which will be based on Vuetify UI framework. The created ' |
19 | | - .'theme will be based on one of the wireframes which exist at ' |
20 | | - .'https://vuetifyjs.com/en/getting-started/wireframes .'); |
21 | | - } |
22 | | - /** |
23 | | - * Execute the command. |
24 | | - * |
25 | | - * @return int The method will always return 0. |
26 | | - */ |
27 | | - public function exec() : int { |
28 | | - $wireframes = [ |
29 | | - "Base", |
30 | | - "Extended Toolbar", |
31 | | - "System Bar", |
32 | | - "Inbox", |
33 | | - "Side Navigation", |
34 | | - ]; |
35 | | - $wireframe = $this->select('Select theme wireframe:', $wireframes, 0); |
36 | | - $classInfo = $this->getClassInfo(); |
37 | | - $classInfo['wireframe'] = $wireframe; |
38 | | - $creator = new VuetifyThemeClassWriter($classInfo); |
39 | | - $this->println("Creating new vuetify theme based on '$wireframe' wireframe..."); |
40 | | - $creator->writeClass(); |
41 | | - $this->println('Your theme was successfully created.'); |
42 | | - |
43 | | - return 0; |
44 | | - } |
45 | | - |
46 | | - /** |
47 | | - * Prompts the user to enter class information such as it is name. |
48 | | - * |
49 | | - * This method is useful in case we would like to create a class. |
50 | | - * |
51 | | - * @return array The method will return an array that contains 3 indices: |
52 | | - * <ul> |
53 | | - * <li><b>name</b>: The name of the class.</li> |
54 | | - * <li><b>namespace</b>: The namespace of the class. It will be empty string if no |
55 | | - * namespace is entered.</li> |
56 | | - * <li><b>path</b>: The location at which the class will be created.</li> |
57 | | - * </ul> |
58 | | - * |
59 | | - * @since 1.0 |
60 | | - */ |
61 | | - public function getClassInfo() { |
62 | | - $classExist = true; |
63 | | - |
64 | | - do { |
65 | | - $className = $this->readClassName('Enter a name for the new class:', 'Theme'); |
66 | | - $ns = $this->readNamespace('Enter namespace for the class:', 'Themes\\Vuetify'); |
67 | | - $classWithNs = $ns.'\\'.$className; |
68 | | - $classExist = class_exists($classWithNs); |
69 | | - |
70 | | - if ($classExist) { |
71 | | - $this->error('A class in the given namespace which has the given name was found.'); |
72 | | - } |
73 | | - } while ($classExist); |
74 | | - $path = ROOT_PATH.DS.trim(trim(str_replace('\\', DS, str_replace('/', DS, $ns)),'/'),'\\'); |
75 | | - |
76 | | - return [ |
77 | | - 'name' => $className, |
78 | | - 'namespace' => $ns, |
79 | | - 'path' => $path |
80 | | - ]; |
81 | | - } |
82 | | -} |
| 1 | +<?php |
| 2 | +namespace Themes\VuetifyCore\Cli; |
| 3 | + |
| 4 | +use WebFiori\Cli\Command; |
| 5 | + |
| 6 | + |
| 7 | +/** |
| 8 | + * A command which can be used to create a Vuetify based theme template. |
| 9 | + * |
| 10 | + * @author Ibrahim |
| 11 | + */ |
| 12 | +class CreateVuetifyThemeCommand extends Command { |
| 13 | + /** |
| 14 | + * Creates new instance of the class. |
| 15 | + */ |
| 16 | + public function __construct() { |
| 17 | + parent::__construct('create-vuetify-theme', [ |
| 18 | + ], 'Creates a theme which will be based on Vuetify UI framework. The created ' |
| 19 | + .'theme will be based on one of the wireframes which exist at ' |
| 20 | + .'https://vuetifyjs.com/en/getting-started/wireframes .'); |
| 21 | + } |
| 22 | + /** |
| 23 | + * Execute the command. |
| 24 | + * |
| 25 | + * @return int The method will always return 0. |
| 26 | + */ |
| 27 | + public function exec() : int { |
| 28 | + $wireframes = [ |
| 29 | + "Base", |
| 30 | + "Extended Toolbar", |
| 31 | + "System Bar", |
| 32 | + "Inbox", |
| 33 | + "Side Navigation", |
| 34 | + ]; |
| 35 | + $wireframe = $this->select('Select theme wireframe:', $wireframes, 0); |
| 36 | + $classInfo = $this->getClassInfo(); |
| 37 | + $classInfo['wireframe'] = $wireframe; |
| 38 | + $creator = new VuetifyThemeClassWriter($classInfo); |
| 39 | + $this->println("Creating new vuetify theme based on '$wireframe' wireframe..."); |
| 40 | + $creator->writeClass(); |
| 41 | + $this->println('Your theme was successfully created.'); |
| 42 | + |
| 43 | + return 0; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Prompts the user to enter class information such as it is name. |
| 48 | + * |
| 49 | + * This method is useful in case we would like to create a class. |
| 50 | + * |
| 51 | + * @return array The method will return an array that contains 3 indices: |
| 52 | + * <ul> |
| 53 | + * <li><b>name</b>: The name of the class.</li> |
| 54 | + * <li><b>namespace</b>: The namespace of the class. It will be empty string if no |
| 55 | + * namespace is entered.</li> |
| 56 | + * <li><b>path</b>: The location at which the class will be created.</li> |
| 57 | + * </ul> |
| 58 | + * |
| 59 | + * @since 1.0 |
| 60 | + */ |
| 61 | + public function getClassInfo() { |
| 62 | + $classExist = true; |
| 63 | + |
| 64 | + do { |
| 65 | + $className = $this->readClassName('Enter a name for the new class:', 'Theme'); |
| 66 | + $ns = $this->readNamespace('Enter namespace for the class:', 'Themes\\Vuetify'); |
| 67 | + $classWithNs = $ns.'\\'.$className; |
| 68 | + $classExist = class_exists($classWithNs); |
| 69 | + |
| 70 | + if ($classExist) { |
| 71 | + $this->error('A class in the given namespace which has the given name was found.'); |
| 72 | + } |
| 73 | + } while ($classExist); |
| 74 | + $path = ROOT_PATH.DS.trim(trim(str_replace('\\', DS, str_replace('/', DS, $ns)),'/'),'\\'); |
| 75 | + |
| 76 | + return [ |
| 77 | + 'name' => $className, |
| 78 | + 'namespace' => $ns, |
| 79 | + 'path' => $path |
| 80 | + ]; |
| 81 | + } |
| 82 | +} |
0 commit comments