@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | use phoponent\framework\traits\command; |
| 14 | 14 | |
| 15 | 15 | class make { |
| 16 | - use command; |
|
| 16 | + use command; |
|
| 17 | 17 | |
| 18 | - private function create_component($type, $tag) { |
|
| 18 | + private function create_component($type, $tag) { |
|
| 19 | 19 | if(!is_dir("phoponent/app/components/{$type}/{$tag}")) { |
| 20 | 20 | mkdir("phoponent/app/components/{$type}/{$tag}/models", 0777, true); |
| 21 | 21 | mkdir("phoponent/app/components/{$type}/{$tag}/views/src", 0777, true); |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | ); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function component() { |
|
| 74 | - if(($tag = $this->argument('tag')) !== null) { |
|
| 75 | - $tag = ucfirst($tag); |
|
| 76 | - $type = $this->argument('type') ? $this->argument('type') : 'core'; |
|
| 77 | - if($type === 'custom' && !is_dir("phoponent/app/components/core/{$tag}")) { |
|
| 73 | + public function component() { |
|
| 74 | + if(($tag = $this->argument('tag')) !== null) { |
|
| 75 | + $tag = ucfirst($tag); |
|
| 76 | + $type = $this->argument('type') ? $this->argument('type') : 'core'; |
|
| 77 | + if($type === 'custom' && !is_dir("phoponent/app/components/core/{$tag}")) { |
|
| 78 | 78 | $this->create_component('core', $tag); |
| 79 | 79 | $this->create_component('custom', $tag); |
| 80 | 80 | } |
| 81 | 81 | else { |
| 82 | 82 | $this->create_component($type, $tag); |
| 83 | 83 | } |
| 84 | - } |
|
| 85 | - } |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - public function debug() { |
|
| 87 | + public function debug() { |
|
| 88 | 88 | debug::set_debug(); |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | \ No newline at end of file |
@@ -12,40 +12,40 @@ |
||
| 12 | 12 | use phoponent\framework\traits\command; |
| 13 | 13 | |
| 14 | 14 | class help { |
| 15 | - use command; |
|
| 16 | - |
|
| 17 | - private $commands = []; |
|
| 18 | - |
|
| 19 | - protected function after_connstruct() { |
|
| 20 | - self::$LOG_FILE = 'phoponent/logs/commands/help.log'; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - protected function before_run() { |
|
| 24 | - $this->commands[] = '-h'; |
|
| 25 | - $this->commands[] = '--help'; |
|
| 26 | - $this->commands[] = 'make:component tag=<valeur> ?type=<core/custom>'; |
|
| 27 | - $this->commands[] = ''; |
|
| 28 | - $this->commands[] = ''; |
|
| 29 | - $this->commands[] = 'LEGENDE : '; |
|
| 30 | - $this->commands[] = '? = optionnel'; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - protected function run() { |
|
| 34 | - echo '/**********************************************/'."\n"; |
|
| 35 | - echo '/* © '.date('Y').' - Phoponent *************************/'."\n"; |
|
| 36 | - echo '/* Author: Nicolas Choquet ********************/'."\n"; |
|
| 37 | - echo '/* LICENSE GPL ( GNU General Public License ) */'."\n"; |
|
| 38 | - echo '/**********************************************/'."\n\n"; |
|
| 39 | - echo "/***********************************************************************/\n"; |
|
| 40 | - echo "/* PPPPPP hh tt */\n"; |
|
| 15 | + use command; |
|
| 16 | + |
|
| 17 | + private $commands = []; |
|
| 18 | + |
|
| 19 | + protected function after_connstruct() { |
|
| 20 | + self::$LOG_FILE = 'phoponent/logs/commands/help.log'; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + protected function before_run() { |
|
| 24 | + $this->commands[] = '-h'; |
|
| 25 | + $this->commands[] = '--help'; |
|
| 26 | + $this->commands[] = 'make:component tag=<valeur> ?type=<core/custom>'; |
|
| 27 | + $this->commands[] = ''; |
|
| 28 | + $this->commands[] = ''; |
|
| 29 | + $this->commands[] = 'LEGENDE : '; |
|
| 30 | + $this->commands[] = '? = optionnel'; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + protected function run() { |
|
| 34 | + echo '/**********************************************/'."\n"; |
|
| 35 | + echo '/* © '.date('Y').' - Phoponent *************************/'."\n"; |
|
| 36 | + echo '/* Author: Nicolas Choquet ********************/'."\n"; |
|
| 37 | + echo '/* LICENSE GPL ( GNU General Public License ) */'."\n"; |
|
| 38 | + echo '/**********************************************/'."\n\n"; |
|
| 39 | + echo "/***********************************************************************/\n"; |
|
| 40 | + echo "/* PPPPPP hh tt */\n"; |
|
| 41 | 41 | echo "/* PP PP hh oooo pp pp oooo nn nnn eee nn nnn tt */\n"; |
| 42 | 42 | echo "/* PPPPPP hhhhhh oo oo ppp pp oo oo nnn nn ee e nnn nn tttt */\n"; |
| 43 | 43 | echo "/* PP hh hh oo oo pppppp oo oo nn nn eeeee nn nn tt */\n"; |
| 44 | 44 | echo "/* PP hh hh oooo pp oooo nn nn eeeee nn nn tttt */\n"; |
| 45 | 45 | echo "/* pp */\n"; |
| 46 | 46 | echo "/***********************************************************************/\n\n"; |
| 47 | - foreach ($this->commands as $command) { |
|
| 48 | - $this->log($command); |
|
| 49 | - } |
|
| 50 | - } |
|
| 47 | + foreach ($this->commands as $command) { |
|
| 48 | + $this->log($command); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |
@@ -22,25 +22,25 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public static function load() { |
|
| 26 | - require_once 'traits/static_class.php'; |
|
| 25 | + public static function load() { |
|
| 26 | + require_once 'traits/static_class.php'; |
|
| 27 | 27 | require_once 'classes/debug.php'; |
| 28 | 28 | self::debug_page(); |
| 29 | - require_once 'traits/view.php'; |
|
| 30 | - require_once 'traits/model.php'; |
|
| 31 | - require_once 'traits/service.php'; |
|
| 32 | - require_once 'traits/command.php'; |
|
| 33 | - require_once 'classes/regexp.php'; |
|
| 34 | - require_once 'classes/xphp.php'; |
|
| 35 | - require_once 'classes/xphp_tag.php'; |
|
| 36 | - require_once 'classes/command.php'; |
|
| 29 | + require_once 'traits/view.php'; |
|
| 30 | + require_once 'traits/model.php'; |
|
| 31 | + require_once 'traits/service.php'; |
|
| 32 | + require_once 'traits/command.php'; |
|
| 33 | + require_once 'classes/regexp.php'; |
|
| 34 | + require_once 'classes/xphp.php'; |
|
| 35 | + require_once 'classes/xphp_tag.php'; |
|
| 36 | + require_once 'classes/command.php'; |
|
| 37 | 37 | |
| 38 | - require_once 'classes/index.php'; |
|
| 39 | - } |
|
| 38 | + require_once 'classes/index.php'; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public static function dependencies() { |
|
| 42 | - self::$dependencies = [ |
|
| 43 | - // Framework |
|
| 41 | + public static function dependencies() { |
|
| 42 | + self::$dependencies = [ |
|
| 43 | + // Framework |
|
| 44 | 44 | |
| 45 | 45 | // Traits |
| 46 | 46 | 'traits' => [ |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | 'path' => __DIR__.'/classes/command.php', |
| 85 | 85 | \phoponent\framework\static_classe\command::class, |
| 86 | 86 | ], |
| 87 | - ], |
|
| 87 | + ], |
|
| 88 | 88 | |
| 89 | 89 | // Services |
| 90 | 90 | 'services' => [ |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | 'class' => \phoponent\framework\command\make::class, |
| 114 | 114 | ] |
| 115 | 115 | ], |
| 116 | - ]; |
|
| 117 | - } |
|
| 116 | + ]; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - public static function dependencie($type, $name = null) { |
|
| 120 | - self::dependencies(); |
|
| 121 | - if($name) { |
|
| 122 | - if(isset(self::$dependencies[$type][$name]) && is_file(self::$dependencies[$type][$name]['path'])) { |
|
| 123 | - require_once self::$dependencies[$type][$name]['path']; |
|
| 124 | - return self::$dependencies[$type][$name]['class']; |
|
| 119 | + public static function dependencie($type, $name = null) { |
|
| 120 | + self::dependencies(); |
|
| 121 | + if($name) { |
|
| 122 | + if(isset(self::$dependencies[$type][$name]) && is_file(self::$dependencies[$type][$name]['path'])) { |
|
| 123 | + require_once self::$dependencies[$type][$name]['path']; |
|
| 124 | + return self::$dependencies[$type][$name]['class']; |
|
| 125 | 125 | } |
| 126 | 126 | return null; |
| 127 | 127 | } |
| 128 | - return isset(self::$dependencies[$type]) ? self::$dependencies[$type] : null; |
|
| 128 | + return isset(self::$dependencies[$type]) ? self::$dependencies[$type] : null; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | \ No newline at end of file |
@@ -10,5 +10,5 @@ |
||
| 10 | 10 | namespace phoponent\framework\traits; |
| 11 | 11 | |
| 12 | 12 | trait static_class { |
| 13 | - private function __construct() {} |
|
| 13 | + private function __construct() {} |
|
| 14 | 14 | } |
| 15 | 15 | \ No newline at end of file |
@@ -12,63 +12,63 @@ |
||
| 12 | 12 | use Exception; |
| 13 | 13 | |
| 14 | 14 | trait command { |
| 15 | - private $argv = []; |
|
| 15 | + private $argv = []; |
|
| 16 | 16 | |
| 17 | - protected static $LOG_ECHO = 'echo'; |
|
| 18 | - protected static $LOG_FILE = ''; |
|
| 17 | + protected static $LOG_ECHO = 'echo'; |
|
| 18 | + protected static $LOG_FILE = ''; |
|
| 19 | 19 | |
| 20 | - public function __construct($argv = []) { |
|
| 21 | - $this->argv = $argv; |
|
| 22 | - $this->after_connstruct(); |
|
| 23 | - } |
|
| 20 | + public function __construct($argv = []) { |
|
| 21 | + $this->argv = $argv; |
|
| 22 | + $this->after_connstruct(); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - protected function after_connstruct() {} |
|
| 25 | + protected function after_connstruct() {} |
|
| 26 | 26 | |
| 27 | - protected function log($text = '', $type_log = 'echo') { |
|
| 28 | - if ($type_log === self::$LOG_FILE) { |
|
| 29 | - $path = str_replace('/'.basename(self::$LOG_FILE), '', self::$LOG_FILE); |
|
| 30 | - if(!is_dir($path)) { |
|
| 31 | - mkdir($path, 0777, true); |
|
| 32 | - } |
|
| 33 | - $content = ''; |
|
| 34 | - if(is_file(self::$LOG_FILE)) { |
|
| 35 | - $content = file_get_contents(self::$LOG_FILE); |
|
| 36 | - } |
|
| 27 | + protected function log($text = '', $type_log = 'echo') { |
|
| 28 | + if ($type_log === self::$LOG_FILE) { |
|
| 29 | + $path = str_replace('/'.basename(self::$LOG_FILE), '', self::$LOG_FILE); |
|
| 30 | + if(!is_dir($path)) { |
|
| 31 | + mkdir($path, 0777, true); |
|
| 32 | + } |
|
| 33 | + $content = ''; |
|
| 34 | + if(is_file(self::$LOG_FILE)) { |
|
| 35 | + $content = file_get_contents(self::$LOG_FILE); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - file_put_contents(self::$LOG_FILE, $content."\n".date('#~ '.exec('echo $USER').': '.$text)); |
|
| 39 | - } |
|
| 40 | - else { |
|
| 41 | - echo date('Y-m-d H:i:s').' '.exec('echo $USER').' #~ '.$text."\n"; |
|
| 42 | - } |
|
| 43 | - } |
|
| 38 | + file_put_contents(self::$LOG_FILE, $content."\n".date('#~ '.exec('echo $USER').': '.$text)); |
|
| 39 | + } |
|
| 40 | + else { |
|
| 41 | + echo date('Y-m-d H:i:s').' '.exec('echo $USER').' #~ '.$text."\n"; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - protected function before_run() {} |
|
| 45 | + protected function before_run() {} |
|
| 46 | 46 | |
| 47 | - protected function after_run() {} |
|
| 47 | + protected function after_run() {} |
|
| 48 | 48 | |
| 49 | - protected function run() {} |
|
| 49 | + protected function run() {} |
|
| 50 | 50 | |
| 51 | - protected function argument($name) { |
|
| 52 | - foreach ($this->argv as $argv) { |
|
| 53 | - if(explode('=', $argv)[0] === $name) { |
|
| 54 | - return explode('=', $argv)[1]; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - return null; |
|
| 58 | - } |
|
| 51 | + protected function argument($name) { |
|
| 52 | + foreach ($this->argv as $argv) { |
|
| 53 | + if(explode('=', $argv)[0] === $name) { |
|
| 54 | + return explode('=', $argv)[1]; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + return null; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @param string $method |
|
| 62 | - * @return bool |
|
| 63 | - * @throws Exception |
|
| 64 | - */ |
|
| 65 | - public function execute($method = 'run') { |
|
| 66 | - $this->before_run(); |
|
| 67 | - if(in_array($method, get_class_methods(get_class($this)))) { |
|
| 68 | - $this->$method(); |
|
| 69 | - $this->after_run(); |
|
| 70 | - return true; |
|
| 71 | - } |
|
| 72 | - throw new Exception("method ".explode('\\', __CLASS__)[count(explode('\\', __CLASS__))-1]."::{$method}() not found"); |
|
| 73 | - } |
|
| 60 | + /** |
|
| 61 | + * @param string $method |
|
| 62 | + * @return bool |
|
| 63 | + * @throws Exception |
|
| 64 | + */ |
|
| 65 | + public function execute($method = 'run') { |
|
| 66 | + $this->before_run(); |
|
| 67 | + if(in_array($method, get_class_methods(get_class($this)))) { |
|
| 68 | + $this->$method(); |
|
| 69 | + $this->after_run(); |
|
| 70 | + return true; |
|
| 71 | + } |
|
| 72 | + throw new Exception("method ".explode('\\', __CLASS__)[count(explode('\\', __CLASS__))-1]."::{$method}() not found"); |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | \ No newline at end of file |
@@ -10,25 +10,25 @@ |
||
| 10 | 10 | namespace phoponent\framework\traits; |
| 11 | 11 | |
| 12 | 12 | trait service { |
| 13 | - public function get($name) { |
|
| 14 | - if(in_array($name, get_class_vars(get_class($this)))) { |
|
| 15 | - return $this->$name; |
|
| 16 | - } |
|
| 17 | - elseif (in_array("get_{$name}", get_class_methods($this))) { |
|
| 18 | - $func = "get_{$name}"; |
|
| 19 | - return $this->$func(); |
|
| 20 | - } |
|
| 21 | - return null; |
|
| 22 | - } |
|
| 13 | + public function get($name) { |
|
| 14 | + if(in_array($name, get_class_vars(get_class($this)))) { |
|
| 15 | + return $this->$name; |
|
| 16 | + } |
|
| 17 | + elseif (in_array("get_{$name}", get_class_methods($this))) { |
|
| 18 | + $func = "get_{$name}"; |
|
| 19 | + return $this->$func(); |
|
| 20 | + } |
|
| 21 | + return null; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function set($name, $value) { |
|
| 25 | - if(in_array($name, array_keys(get_class_vars(get_class($this))))) { |
|
| 26 | - $this->$name = $value; |
|
| 27 | - } |
|
| 28 | - elseif (in_array("set_{$name}", get_class_methods($this))) { |
|
| 29 | - $func = "set_{$name}"; |
|
| 30 | - return $this->$func($value); |
|
| 31 | - } |
|
| 32 | - return $this; |
|
| 33 | - } |
|
| 24 | + public function set($name, $value) { |
|
| 25 | + if(in_array($name, array_keys(get_class_vars(get_class($this))))) { |
|
| 26 | + $this->$name = $value; |
|
| 27 | + } |
|
| 28 | + elseif (in_array("set_{$name}", get_class_methods($this))) { |
|
| 29 | + $func = "set_{$name}"; |
|
| 30 | + return $this->$func($value); |
|
| 31 | + } |
|
| 32 | + return $this; |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | protected $component = ''; |
| 18 | 18 | |
| 19 | 19 | public function __construct($path) { |
| 20 | - $view_name = explode('\\', get_class($this))[count(explode('\\', get_class($this)))-1]; |
|
| 20 | + $view_name = explode('\\', get_class($this))[count(explode('\\', get_class($this)))-1]; |
|
| 21 | 21 | if(is_file("{$path}/src/{$view_name}.view.html")) { |
| 22 | 22 | $this->template = file_get_contents("{$path}/src/{$view_name}.view.html"); |
| 23 | 23 | } |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function before_render() {} |
| 44 | 44 | |
| 45 | - protected function render_end(&$template) { |
|
| 46 | - xphp::parse_template_content($template); |
|
| 47 | - } |
|
| 45 | + protected function render_end(&$template) { |
|
| 46 | + xphp::parse_template_content($template); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | public function render():string { |
| 50 | 50 | $this->before_render(); |
@@ -10,26 +10,26 @@ |
||
| 10 | 10 | namespace phoponent\framework\traits; |
| 11 | 11 | |
| 12 | 12 | trait model { |
| 13 | - private $services = []; |
|
| 14 | - private $component = ''; |
|
| 13 | + private $services = []; |
|
| 14 | + private $component = ''; |
|
| 15 | 15 | public function __construct($services, string $component) { |
| 16 | 16 | $this->services = $services; |
| 17 | - $this->component = $component; |
|
| 17 | + $this->component = $component; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | protected function get_services() { |
| 21 | - return $this->services; |
|
| 22 | - } |
|
| 21 | + return $this->services; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @param $name |
|
| 26 | - * @return service|null |
|
| 27 | - */ |
|
| 28 | - protected function get_service($name) { |
|
| 29 | - return isset($this->services[$name]) ? $this->services[$name] : null; |
|
| 30 | - } |
|
| 24 | + /** |
|
| 25 | + * @param $name |
|
| 26 | + * @return service|null |
|
| 27 | + */ |
|
| 28 | + protected function get_service($name) { |
|
| 29 | + return isset($this->services[$name]) ? $this->services[$name] : null; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function get_component() { |
|
| 33 | - return $this->component; |
|
| 34 | - } |
|
| 32 | + public function get_component() { |
|
| 33 | + return $this->component; |
|
| 34 | + } |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -12,15 +12,15 @@ |
||
| 12 | 12 | use phoponent\framework\traits\service; |
| 13 | 13 | |
| 14 | 14 | class json_reader { |
| 15 | - use service; |
|
| 16 | - protected $file = ''; |
|
| 15 | + use service; |
|
| 16 | + protected $file = ''; |
|
| 17 | 17 | |
| 18 | - public function set_file($file) { |
|
| 19 | - $this->file = "$file.json"; |
|
| 20 | - return $this; |
|
| 21 | - } |
|
| 18 | + public function set_file($file) { |
|
| 19 | + $this->file = "$file.json"; |
|
| 20 | + return $this; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function get_datas() { |
|
| 24 | - return json_decode(file_get_contents($this->file)); |
|
| 25 | - } |
|
| 23 | + public function get_datas() { |
|
| 24 | + return json_decode(file_get_contents($this->file)); |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |