Skip to content

Commit 2c56889

Browse files
Added Appllication->setErrorStatusAndAutoloader callback,edited ApplicationServiceProvider.php,...
1 parent 025bce0 commit 2c56889

9 files changed

+66
-52
lines changed

LICENSE

+4
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
<<<<<<< HEAD
2122
SOFTWARE.
23+
=======
24+
SOFTWARE.
25+
>>>>>>> 025bce09f7a417a8d73791d01effec08298d07ee

config/Engines.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'template' => [
77
'santos' => [
88
'callback' => function(array $argv = [],array $data = [],array $options = []){
9-
return (new Santos())->configs($argv['options'])->view($argv['name'],$data,$options);
9+
return (new Santos())->configs($argv['options'])->view($argv['name'],$data,$options);
1010
}
1111
]
1212
]

src/Application.php

+36-34
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ public function run()
219219
"REAL_BASE_DIR" => $this->rootDir,
220220
"GET_NAMESPACES" => $this->{$this->projectType.'_Namespaces'}(),
221221
"START_BENCHMARK" => microtime(true),
222+
"SSL_STATUS" => (
223+
!is_cli() ? (
224+
( ! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ) || $_SERVER['SERVER_PORT'] == 443
225+
? 'https'
226+
: 'http'
227+
) : null
228+
)
222229
]);
223230

224231
define('GET_DIRS', $this->{$this->projectType.'_Paths'}());
@@ -227,47 +234,15 @@ public function run()
227234
$this->coreAliases();
228235

229236
define('PROJECT_CONFIG',$this->get(Config::class)->get("app"));
230-
if(!is_cli())
231-
{
232-
233-
define('SSL_STATUS',
234-
(
235-
( ! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ) || $_SERVER['SERVER_PORT'] == 443
236-
? 'https'
237-
: 'http'
238-
));
239-
}
240237

241238
# Set a default error and exception
242239
set_error_handler("OceanWebTurk\Framework\Application::errorHandler");
243240
set_exception_handler("OceanWebTurk\Framework\Application::exceptionHandler");
244241

245-
# Small system configuration according to project mode
246-
if (isset(PROJECT_CONFIG['mode']))
247-
{
248-
switch (PROJECT_CONFIG['mode']) {
249-
case 'public':
250-
error_reporting(0);
251-
break;
252-
253-
case 'development':
254-
ini_set("error_reporting",1);error_reporting(E_ALL);
255-
break;
256-
}
257-
}
258-
259-
$loader = new Autoloader();
260-
foreach(GET_NAMESPACES as$key=>$value){
261-
if(GET_DIRS[$key])
262-
{
263-
$loader->addNamespace($value,GET_DIRS[$key]);
264-
}
265-
$loader->addNamespace($value,$key);
266-
}
267-
$loader->load();
242+
$this->setErrorStatusAndAutoloader();
268243

269244
Set::headers([
270-
'alt-svc' => 'h3=":443"; ma=86400','vary' => 'Accept-Encoding',
245+
'vary' => 'Accept-Encoding',
271246
'X-OceanWebTurk-Apps' => implode(',',['Framework',...self::$apps])
272247
]);
273248

@@ -379,6 +354,33 @@ private function packagesForAutoLoad()
379354
}
380355
}
381356
}
357+
358+
private function setErrorStatusAndAutoloader()
359+
{
360+
# Small system configuration according to project mode
361+
if (isset(PROJECT_CONFIG['mode']))
362+
{
363+
switch (PROJECT_CONFIG['mode']) {
364+
case 'public':
365+
error_reporting(0);
366+
break;
367+
368+
case 'development':
369+
ini_set("error_reporting",1);error_reporting(E_ALL);
370+
break;
371+
}
372+
}
373+
374+
$loader = new Autoloader();
375+
foreach(GET_NAMESPACES as$key=>$value){
376+
if(GET_DIRS[$key])
377+
{
378+
$loader->addNamespace($value,GET_DIRS[$key]);
379+
}
380+
$loader->addNamespace($value,$key);
381+
}
382+
$loader->load();
383+
}
382384

383385
/**
384386
* @return array

src/ApplicationServiceProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function boot()
2424
{
2525
$this->app->get(Config::class)->addPath(GET_DIRS['CONFIGS']);
2626

27-
$this->app->get(Config::class)->addPath(GET_DIRS['SYSTEM'].'../etc/','system');
27+
$this->app->get(Config::class)->addPath(GET_DIRS['SYSTEM'].'../config/','system');
2828

2929
Import::setEngines(config('system:engines')['template']);
3030

@@ -43,7 +43,7 @@ public function boot()
4343
# Set a Define Project Crypt Options
4444
Crypt::init(['key' => config("app")['key']]);
4545

46-
Mail::init(config("mail"));
46+
Mail::init(config("system:mail"));
4747

4848
if(@Request::isPost()) new \OceanWebTurk\Framework\Support\Security();
4949
}

src/Config.php

-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ public function get(string $name)
6868
break;
6969
}
7070
}
71-
else
72-
{
73-
$config = [];
74-
}
7571

7672
return $config;
7773

src/Container.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class Container
3434
public function alias($abstract,string $key)
3535
{
3636
$this->aliases[$key] = $abstract;
37-
if(class_exists($abstract)){
37+
38+
if(class_exists($abstract))
39+
{
3840
@class_alias($abstract,$key);
3941
}
4042
}
@@ -44,8 +46,9 @@ public function alias($abstract,string $key)
4446
*/
4547
public static function getInstance()
4648
{
47-
if (is_null(static::$instance)) {
48-
static::$instance = new static;
49+
if (is_null(static::$instance))
50+
{
51+
static::$instance = new static;
4952
}
5053
return static::$instance;
5154
}

src/Dotenv.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ class Dotenv
1616
*/
1717
public static function set($key,mixed $value = null)
1818
{
19-
if(is_array($key)){
20-
foreach ($key as $k => $v) {
19+
if(is_array($key))
20+
{
21+
foreach ($key as $k => $v)
22+
{
2123
$_ENV[$k] = $v;
2224
$_SERVER[$k] = $v;
2325
if(function_exists("putenv"))
2426
putenv($k.'='.$v);
2527
}
26-
}else{
28+
}
29+
else
30+
{
2731
$_ENV[$key] = $value;
2832
$_SERVER[$key] = $value;
2933
if(function_exists("putenv"))

src/Import.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public static function view(string $path,array $data = [],array $options = [])
6363

6464
$options = array_merge($getPath['options'],['view' => $getPath['path']]);
6565

66-
if(!isset($options['cache'])){
66+
if(!isset($options['cache']))
67+
{
6768
$options = array_merge($options,self::$paths['default']['options']);
6869
}
6970

@@ -74,7 +75,8 @@ public static function view(string $path,array $data = [],array $options = [])
7475
$callback = $engine['callback'];
7576
$GLOBALS['_OCEANWEBTURK']['VIEWS'] = compact("argv","data","options");
7677

77-
if(is_callable($callback)){
78+
if(is_callable($callback))
79+
{
7880
echo $callback($argv,$data,$options);
7981
}
8082
}

src/Set.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ public static function define($key,$value = null)
1919
if(is_array($key)){
2020
foreach ($key as $k => $v) {
2121
if(!defined($k)){
22-
define($k,$v);
23-
}
22+
define($k,$v);
23+
}
2424
}
2525
}else{
26-
define($key,$value);
26+
if(!defined($key))
27+
{
28+
define($key,$value);
29+
}
2730
}
2831
}
2932

0 commit comments

Comments
 (0)