src/classes/App.php
private function pushRequestsInDefinition($alias_namespace, $requests_directory, &$default_definitions)
    {
        $request_files = get_files($requests_directory);
        if (!empty($request_files))
        {
            $requests = array_map(function($request) use($requests_directory) {
                $new_request = str_replace("{$requests_directory}/", "", $request);
                return basename(str_replace("/", "\\", $new_request), ".php");
            }, $request_files);

            $errors = [];

            foreach ($requests as $request) {
                if ($alias_namespace === "\\")
                {
                    $request_definition = get_app_namespace() . "Requests\\{$request}";
                }
                else
                {
                    $module_name = str_replace("App\\", "", $alias_namespace);

                    $request_sub_namespace = str_replace(app_path() . "/{$module_name}/Requests", "", $requests_directory);
                    $request_sub_namespace = str_replace("/", "\\", $request_sub_namespace);

                    $request_definition = "{$alias_namespace}Requests\\{$request}";
                }

                if (!array_key_exists("{$request_definition}", $default_definitions))
                {
                    $default_definitions["{$request_definition}"] = function(ContainerInterface $c) use ($request_definition)
                    {
                        return new $request_definition($c->get('request'));
                    };
                }
                else
                {
                    $errors[] = "{$request} is already exist inside of definitions.";
                }
            }

            if (!empty($errors))
            {
                exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
            }
        }
        else
        {
            exit("Error: No request found in {$requests_directory} path.");
        }
    }
private function pushRequestsInDefinition($alias_namespace, $requests_directory, &$default_definitions)
    {
        $request_files = get_files($requests_directory);
        if (!empty($request_files))
        {
            $requests = array_map(function($request) use($requests_directory) {
                $new_request = str_replace("{$requests_directory}/", "", $request);
                return basename(str_replace("/", "\\", $new_request), ".php");
            }, $request_files);

            $errors = [];

            foreach ($requests as $request) {
                if ($alias_namespace === "\\")
                {
                    $request_definition = get_app_namespace() . "Requests\\{$request}";
                }
                else
                {
                    $module_name = str_replace("App\\", "", $alias_namespace);

                    $request_sub_namespace = str_replace(app_path() . "/{$module_name}/Requests", "", $requests_directory);
                    $request_sub_namespace = str_replace("/", "\\", $request_sub_namespace);

                    $request_definition = "{$alias_namespace}Requests\\{$request}";
                }

                if (!array_key_exists("{$request_definition}", $default_definitions))
                {
                    $default_definitions["{$request_definition}"] = function(ContainerInterface $c) use ($request_definition)
                    {
                        return new $request_definition($c->get('request'));
                    };
                }
                else
                {
                    $errors[] = "{$request} is already exist inside of definitions.";
                }
            }

            if (!empty($errors))
            {
                exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
            }
        }
        else
        {
            exit("Error: No request found in {$requests_directory} path.");
        }
    }
private function pushRequestsInDefinition ( $ alias_namespace , $ requests_directory , & $ default_definitions ) { $ request_files = get_files ( $ requests_directory ) ; if ( ! empty ( $ request_files ) ) { $ requests = array_map ( function ( $ request ) use ( $ requests_directory ) { $ new_request = str_replace ( "{$requests_directory}/" , "" , $ request ) ; return basename ( str_replace ( "/" , "\\" , $ new_request ) , ".php" ) ; } , $ request_files ) ; $ errors = [ ] ; foreach ( $ requests as $ request ) { if ( $ alias_namespace === "\\" ) { $ request_definition = get_app_namespace ( ) . "Requests\\{$request}" ; } else { $ module_name = str_replace ( "App\\" , "" , $ alias_namespace ) ; $ request_sub_namespace = str_replace ( app_path ( ) . "/{$module_name}/Requests" , "" , $ requests_directory ) ; $ request_sub_namespace = str_replace ( "/" , "\\" , $ request_sub_namespace ) ; $ request_definition = "{$alias_namespace}Requests\\{$request}" ; } if ( ! array_key_exists ( "{$request_definition}" , $ default_definitions ) ) { $ default_definitions [ "{$request_definition}" ] = function ( ContainerInterface $ c ) use ( $ request_definition ) { return new $ request_definition ( $ c -> get ( 'request' ) ) ; } ; } else { $ errors [ ] = "{$request} is already exist inside of definitions." ; } } if ( ! empty ( $ errors ) ) { exit ( "Error: Please fix the ff. before run the application: <li>" . implode ( "</li><li>" , $ errors ) ) ; } } else { exit ( "Error: No request found in {$requests_directory} path." ) ; } }
Push requests in default definition

@param  string $alias_namespace
@param  string $requests_directory
@param  array &$default_definitions
@return void
Push requests in default definition