@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @var array $urlNames |
| 23 | 23 | */ |
| 24 | - protected $urlNames = ['project','version','endpoint','method']; |
|
| 24 | + protected $urlNames = ['project', 'version', 'endpoint', 'method']; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * assign url list |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $parametersYaml = $this->app()->path()->app().'parameters.yaml'; |
| 39 | 39 | |
| 40 | - if(isset($query[0]) && $this->app->has('parametersYaml')){
|
|
| 40 | + if (isset($query[0]) && $this->app->has('parametersYaml')) {
|
|
| 41 | 41 | $callParametersYaml = $this->app->get('parametersYaml');
|
| 42 | - if(isset($callParametersYaml['workingDir'])){
|
|
| 43 | - $parametersWorkingDir = explode('@',$callParametersYaml['workingDir']);
|
|
| 44 | - if($query[0]==$parametersWorkingDir[0]){
|
|
| 42 | + if (isset($callParametersYaml['workingDir'])) {
|
|
| 43 | + $parametersWorkingDir = explode('@', $callParametersYaml['workingDir']);
|
|
| 44 | + if ($query[0]==$parametersWorkingDir[0]) {
|
|
| 45 | 45 | $query[0] = $parametersWorkingDir[1] ?? $query[0]; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -51,25 +51,25 @@ discard block |
||
| 51 | 51 | // it will be formatted. |
| 52 | 52 | $query = $this->queryFormatProcess($query); |
| 53 | 53 | |
| 54 | - foreach ($query as $key=>$value){
|
|
| 54 | + foreach ($query as $key=>$value) {
|
|
| 55 | 55 | |
| 56 | 56 | //set url list for urlNames property |
| 57 | - if(isset($this->urlNames[$key])){
|
|
| 58 | - $this->getUrlListValues($key,$value); |
|
| 57 | + if (isset($this->urlNames[$key])) {
|
|
| 58 | + $this->getUrlListValues($key, $value); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // If there is no method key in the urlList property, |
| 63 | 63 | // then by default we assign the index to the method property. |
| 64 | - if(!isset($this->urlList['method'])){
|
|
| 64 | + if (!isset($this->urlList['method'])) {
|
|
| 65 | 65 | $this->urlList['method'] = 'index'; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | //determines the endpoint method for your project |
| 69 | - $this->urlList['parameters'] = array_slice($query,3); |
|
| 69 | + $this->urlList['parameters'] = array_slice($query, 3); |
|
| 70 | 70 | |
| 71 | 71 | //url global instance |
| 72 | - if($this->app->has('routeParameters')===false){
|
|
| 72 | + if ($this->app->has('routeParameters')===false) {
|
|
| 73 | 73 | $this->definitor($this->urlList); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | //convert array for query |
| 88 | 88 | //we are removing the first empty element from the array due to the slash sign. |
| 89 | - if(is_null($this->path)){
|
|
| 89 | + if (is_null($this->path)) {
|
|
| 90 | 90 | $query = $this->getRequestPathInfo(); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function definitor($urlList) |
| 110 | 110 | {
|
| 111 | - define('version',$urlList['version']);
|
|
| 112 | - define('endpoint',$urlList['endpoint']);
|
|
| 113 | - define('app',$urlList['project']);
|
|
| 114 | - define('method',$urlList['method']);
|
|
| 111 | + define('version', $urlList['version']);
|
|
| 112 | + define('endpoint', $urlList['endpoint']);
|
|
| 113 | + define('app', $urlList['project']);
|
|
| 114 | + define('method', $urlList['method']);
|
|
| 115 | 115 | |
| 116 | 116 | //route parameters kernel object register |
| 117 | - $this->app->register('routeParameters',$urlList['parameters']);
|
|
| 117 | + $this->app->register('routeParameters', $urlList['parameters']);
|
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | * @param array $path |
| 134 | 134 | * @return array |
| 135 | 135 | */ |
| 136 | - public function getRequestPathInfo($path=array()) |
|
| 136 | + public function getRequestPathInfo($path = array()) |
|
| 137 | 137 | {
|
| 138 | - if(count($path)){
|
|
| 138 | + if (count($path)) {
|
|
| 139 | 139 | $this->path = $path; |
| 140 | 140 | } |
| 141 | - else{
|
|
| 141 | + else {
|
|
| 142 | 142 | return Utils::getRequestPathInfo(); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param $key |
| 150 | 150 | * @param $value |
| 151 | 151 | */ |
| 152 | - private function getUrlListValues($key,$value) |
|
| 152 | + private function getUrlListValues($key, $value) |
|
| 153 | 153 | {
|
| 154 | 154 | //If the value from the url is an external value, the default format is applied. |
| 155 | 155 | $this->urlList[$this->urlNames[$key]] = (strlen($value)>0) ? $value : null; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $this->assignUrlList(); |
| 169 | 169 | |
| 170 | 170 | //register to container urlComponent value |
| 171 | - $this->app->register('urlComponent',$this->urlList);
|
|
| 171 | + $this->app->register('urlComponent', $this->urlList);
|
|
| 172 | 172 | |
| 173 | 173 | //we make url parse resolving with resolved |
| 174 | 174 | return (new UrlParseParamResolved)->urlParamResolve($this); |
@@ -184,20 +184,20 @@ discard block |
||
| 184 | 184 | {
|
| 185 | 185 | // at urlNames property, |
| 186 | 186 | // we get the key of the version value registered. |
| 187 | - $versionKey = array_search('version',$this->urlNames);
|
|
| 187 | + $versionKey = array_search('version', $this->urlNames);
|
|
| 188 | 188 | |
| 189 | 189 | // if the query array has a version key, |
| 190 | 190 | // and the value does not start with Vnumber, the version will definitely be formatted. |
| 191 | - if(isset($query[$versionKey]) && !preg_match('@V(\d+)@',$query[$versionKey])){
|
|
| 192 | - $query = Arr::overwriteWith($query,[$versionKey=>'V1']); |
|
| 191 | + if (isset($query[$versionKey]) && !preg_match('@V(\d+)@', $query[$versionKey])) {
|
|
| 192 | + $query = Arr::overwriteWith($query, [$versionKey=>'V1']); |
|
| 193 | 193 | } |
| 194 | - else{
|
|
| 194 | + else {
|
|
| 195 | 195 | |
| 196 | - if(!isset($query[$versionKey])){
|
|
| 196 | + if (!isset($query[$versionKey])) {
|
|
| 197 | 197 | $query[$versionKey] = 'V1'; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if(!isset($query[$versionKey+1])){
|
|
| 200 | + if (!isset($query[$versionKey+1])) {
|
|
| 201 | 201 | $query[$versionKey+1] = NULL; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | // if the store directory is available, |
| 31 | 31 | // then the application process continues. |
| 32 | 32 | // if not available, only the core is executed. |
| 33 | - if(file_exists(app()->path()->storeDir())){
|
|
| 34 | - $this->app->register('isAvailableStore',true);
|
|
| 33 | + if (file_exists(app()->path()->storeDir())) {
|
|
| 34 | + $this->app->register('isAvailableStore', true);
|
|
| 35 | 35 | } |
| 36 | - else{
|
|
| 37 | - $this->app->register('isAvailableStore',false);
|
|
| 36 | + else {
|
|
| 37 | + $this->app->register('isAvailableStore', false);
|
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | {
|
| 49 | 49 | //we can use this method to move an instance of the application class with the kernel object |
| 50 | 50 | //and easily resolve an encrypted instance of all the kernel variables in our helper class. |
| 51 | - ClassAliasGroup::setAlias(App::class,'application'); |
|
| 51 | + ClassAliasGroup::setAlias(App::class, 'application'); |
|
| 52 | 52 | |
| 53 | 53 | //set base instances |
| 54 | 54 | $this->setBaseInstances(); |
| 55 | 55 | |
| 56 | 56 | //we define the general application instance object. |
| 57 | - define('appInstance',(base64_encode(serialize($this->app))));
|
|
| 57 | + define('appInstance', (base64_encode(serialize($this->app))));
|
|
| 58 | 58 | |
| 59 | 59 | //main loader for application |
| 60 | 60 | $this->mainLoader(); |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | // this function can be used for defining your own way of handling errors during runtime, |
| 70 | 70 | // for example in applications in which you need to do cleanup of data/files when a critical error happens, |
| 71 | 71 | // or when you need to trigger an error under certain conditions (using trigger_error()). |
| 72 | - if($this->app['isAvailableStore']){
|
|
| 73 | - $this->app->make('exception',function(){
|
|
| 72 | + if ($this->app['isAvailableStore']) {
|
|
| 73 | + $this->app->make('exception', function() {
|
|
| 74 | 74 | return ErrorProvider::class; |
| 75 | 75 | }); |
| 76 | 76 | } |
@@ -85,33 +85,33 @@ discard block |
||
| 85 | 85 | {
|
| 86 | 86 | // for revision records, |
| 87 | 87 | // the master key is assigned as revision. |
| 88 | - $this->app->register('revision',[]);
|
|
| 88 | + $this->app->register('revision', []);
|
|
| 89 | 89 | |
| 90 | 90 | //we're saving the directory where kernel files are running to the kernel object. |
| 91 | - $this->app->register('corePath',str_replace('Foundation','',__DIR__.''));
|
|
| 91 | + $this->app->register('corePath', str_replace('Foundation', '', __DIR__.''));
|
|
| 92 | 92 | |
| 93 | 93 | //For the application, we create the object that the register method, |
| 94 | 94 | // which is the container center, is connected to by the kernel object register method. |
| 95 | - $this->app->register('container',$this->app);
|
|
| 95 | + $this->app->register('container', $this->app);
|
|
| 96 | 96 | |
| 97 | 97 | // We are saving the application class to |
| 98 | 98 | // the container object for the appClass value. |
| 99 | - $this->app->register('appClass',new App());
|
|
| 99 | + $this->app->register('appClass', new App());
|
|
| 100 | 100 | |
| 101 | 101 | //set closure bind instance for application |
| 102 | - $this->app->register('appClosureInstance',ClosureDispatcher::bind(app()));
|
|
| 102 | + $this->app->register('appClosureInstance', ClosureDispatcher::bind(app()));
|
|
| 103 | 103 | |
| 104 | 104 | //set closure bind instance for bootLoader class |
| 105 | - $this->app->register('closureBootLoader',ClosureDispatcher::bind($this->app['bootLoader']));
|
|
| 105 | + $this->app->register('closureBootLoader', ClosureDispatcher::bind($this->app['bootLoader']));
|
|
| 106 | 106 | |
| 107 | 107 | //set register for macro |
| 108 | - $this->app->register('macro',$this->app->resolve(Macro::class));
|
|
| 108 | + $this->app->register('macro', $this->app->resolve(Macro::class));
|
|
| 109 | 109 | |
| 110 | 110 | //set register for macro |
| 111 | - $this->app->register('pipeline',new Pipeline());
|
|
| 111 | + $this->app->register('pipeline', new Pipeline());
|
|
| 112 | 112 | |
| 113 | - $this->app->register('di',function($instance,$method){
|
|
| 114 | - return DIContainerManager::callBind([$instance,$method],$this->app->applicationProviderBinding($this->app)); |
|
| 113 | + $this->app->register('di', function($instance, $method) {
|
|
| 114 | + return DIContainerManager::callBind([$instance, $method], $this->app->applicationProviderBinding($this->app)); |
|
| 115 | 115 | }); |
| 116 | 116 | |
| 117 | 117 | } |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | //register as instance application object |
| 127 | 127 | // and container instance resolve |
| 128 | 128 | //set core instance value |
| 129 | - $this->app->instance('container',$this->app->singleton());
|
|
| 130 | - $this->app->instance('bootLoader',$this->app->resolve(BootLoader::class));
|
|
| 131 | - $this->app->instance('containerInstanceResolve',ContainerInstanceResolver::class);
|
|
| 132 | - $this->app->instance('reflection',ReflectionProcess::class);
|
|
| 129 | + $this->app->instance('container', $this->app->singleton());
|
|
| 130 | + $this->app->instance('bootLoader', $this->app->resolve(BootLoader::class));
|
|
| 131 | + $this->app->instance('containerInstanceResolve', ContainerInstanceResolver::class);
|
|
| 132 | + $this->app->instance('reflection', ReflectionProcess::class);
|
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -138,24 +138,24 @@ discard block |
||
| 138 | 138 | private function setGlobalAccessor() |
| 139 | 139 | {
|
| 140 | 140 | //get response success and status |
| 141 | - $this->app->register('instanceController',null);
|
|
| 142 | - $this->app->register('responseSuccess',true);
|
|
| 143 | - $this->app->register('responseStatus',200);
|
|
| 144 | - $this->app->register('responseType','json');
|
|
| 141 | + $this->app->register('instanceController', null);
|
|
| 142 | + $this->app->register('responseSuccess', true);
|
|
| 143 | + $this->app->register('responseStatus', 200);
|
|
| 144 | + $this->app->register('responseType', 'json');
|
|
| 145 | 145 | |
| 146 | 146 | //we first load the response class as a singleton object to allow you to send output anywhere |
| 147 | - $this->app->register('out',$this->app->resolve(ResponseProvider::class));
|
|
| 147 | + $this->app->register('out', $this->app->resolve(ResponseProvider::class));
|
|
| 148 | 148 | |
| 149 | 149 | $parametersYaml = $this->app()->path()->app().'parameters.yaml'; |
| 150 | - if(file_exists($parametersYaml)){
|
|
| 151 | - $this->app()->register('parametersYaml',(Utils::yaml($parametersYaml))->get());
|
|
| 150 | + if (file_exists($parametersYaml)) {
|
|
| 151 | + $this->app()->register('parametersYaml', (Utils::yaml($parametersYaml))->get());
|
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $requestService = "Store\Services\RequestService"; |
| 155 | 155 | |
| 156 | 156 | //The HttpFoundation component defines an object-oriented layer for the HTTP specification. |
| 157 | 157 | //The HttpFoundation component replaces these default PHP global variables and functions by an object-oriented layer |
| 158 | - if(Utils::isNamespaceExists($requestService)){
|
|
| 158 | + if (Utils::isNamespaceExists($requestService)) {
|
|
| 159 | 159 | |
| 160 | 160 | Request::setFactory(function(array $query = array(), |
| 161 | 161 | array $request = array(), |
@@ -177,16 +177,16 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | //After registering the symfony request method, we also save the get and post methods for user convenience. |
| 180 | - $this->app->register('request',Request::createFromGlobals());
|
|
| 181 | - $this->app->register('get',core()->request->query->all());
|
|
| 182 | - $this->app->register('post',core()->request->request->all());
|
|
| 180 | + $this->app->register('request', Request::createFromGlobals());
|
|
| 181 | + $this->app->register('get', core()->request->query->all());
|
|
| 182 | + $this->app->register('post', core()->request->request->all());
|
|
| 183 | 183 | |
| 184 | 184 | //We determine with the kernel object which HTTP method the requested from the client |
| 185 | - $this->app->register('httpMethod',ucfirst(strtolower(core()->request->getRealMethod())));
|
|
| 185 | + $this->app->register('httpMethod', ucfirst(strtolower(core()->request->getRealMethod())));
|
|
| 186 | 186 | |
| 187 | - define('httpMethod',strtoupper(core()->httpMethod));
|
|
| 187 | + define('httpMethod', strtoupper(core()->httpMethod));
|
|
| 188 | 188 | |
| 189 | - $this->app->register('fileSystem',new FileProcess());
|
|
| 189 | + $this->app->register('fileSystem', new FileProcess());
|
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | } |
| 193 | 193 | \ No newline at end of file |