Skip to content

Commit

Permalink
Added Appllication->setErrorStatusAndAutoloader callback,edited Appli…
Browse files Browse the repository at this point in the history
…cationServiceProvider.php,...
  • Loading branch information
mehmetalidurusoy committed Aug 26, 2024
1 parent 025bce0 commit 2c56889
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 52 deletions.
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
<<<<<<< HEAD
SOFTWARE.
=======
SOFTWARE.
>>>>>>> 025bce09f7a417a8d73791d01effec08298d07ee
2 changes: 1 addition & 1 deletion config/Engines.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'template' => [
'santos' => [
'callback' => function(array $argv = [],array $data = [],array $options = []){
return (new Santos())->configs($argv['options'])->view($argv['name'],$data,$options);
return (new Santos())->configs($argv['options'])->view($argv['name'],$data,$options);
}
]
]
Expand Down
70 changes: 36 additions & 34 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ public function run()
"REAL_BASE_DIR" => $this->rootDir,
"GET_NAMESPACES" => $this->{$this->projectType.'_Namespaces'}(),
"START_BENCHMARK" => microtime(true),
"SSL_STATUS" => (
!is_cli() ? (
( ! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ) || $_SERVER['SERVER_PORT'] == 443
? 'https'
: 'http'
) : null
)
]);

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

define('PROJECT_CONFIG',$this->get(Config::class)->get("app"));
if(!is_cli())
{

define('SSL_STATUS',
(
( ! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ) || $_SERVER['SERVER_PORT'] == 443
? 'https'
: 'http'
));
}

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

# Small system configuration according to project mode
if (isset(PROJECT_CONFIG['mode']))
{
switch (PROJECT_CONFIG['mode']) {
case 'public':
error_reporting(0);
break;

case 'development':
ini_set("error_reporting",1);error_reporting(E_ALL);
break;
}
}

$loader = new Autoloader();
foreach(GET_NAMESPACES as$key=>$value){
if(GET_DIRS[$key])
{
$loader->addNamespace($value,GET_DIRS[$key]);
}
$loader->addNamespace($value,$key);
}
$loader->load();
$this->setErrorStatusAndAutoloader();

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

Expand Down Expand Up @@ -379,6 +354,33 @@ private function packagesForAutoLoad()
}
}
}

private function setErrorStatusAndAutoloader()
{
# Small system configuration according to project mode
if (isset(PROJECT_CONFIG['mode']))
{
switch (PROJECT_CONFIG['mode']) {
case 'public':
error_reporting(0);
break;

case 'development':
ini_set("error_reporting",1);error_reporting(E_ALL);
break;
}
}

$loader = new Autoloader();
foreach(GET_NAMESPACES as$key=>$value){
if(GET_DIRS[$key])
{
$loader->addNamespace($value,GET_DIRS[$key]);
}
$loader->addNamespace($value,$key);
}
$loader->load();
}

/**
* @return array
Expand Down
4 changes: 2 additions & 2 deletions src/ApplicationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function boot()
{
$this->app->get(Config::class)->addPath(GET_DIRS['CONFIGS']);

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

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

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

Mail::init(config("mail"));
Mail::init(config("system:mail"));

if(@Request::isPost()) new \OceanWebTurk\Framework\Support\Security();
}
Expand Down
4 changes: 0 additions & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public function get(string $name)
break;
}
}
else
{
$config = [];
}

return $config;

Expand Down
9 changes: 6 additions & 3 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Container
public function alias($abstract,string $key)
{
$this->aliases[$key] = $abstract;
if(class_exists($abstract)){

if(class_exists($abstract))
{
@class_alias($abstract,$key);
}
}
Expand All @@ -44,8 +46,9 @@ public function alias($abstract,string $key)
*/
public static function getInstance()
{
if (is_null(static::$instance)) {
static::$instance = new static;
if (is_null(static::$instance))
{
static::$instance = new static;
}
return static::$instance;
}
Expand Down
10 changes: 7 additions & 3 deletions src/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ class Dotenv
*/
public static function set($key,mixed $value = null)
{
if(is_array($key)){
foreach ($key as $k => $v) {
if(is_array($key))
{
foreach ($key as $k => $v)
{
$_ENV[$k] = $v;
$_SERVER[$k] = $v;
if(function_exists("putenv"))
putenv($k.'='.$v);
}
}else{
}
else
{
$_ENV[$key] = $value;
$_SERVER[$key] = $value;
if(function_exists("putenv"))
Expand Down
6 changes: 4 additions & 2 deletions src/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public static function view(string $path,array $data = [],array $options = [])

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

if(!isset($options['cache'])){
if(!isset($options['cache']))
{
$options = array_merge($options,self::$paths['default']['options']);
}

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

if(is_callable($callback)){
if(is_callable($callback))
{
echo $callback($argv,$data,$options);
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ public static function define($key,$value = null)
if(is_array($key)){
foreach ($key as $k => $v) {
if(!defined($k)){
define($k,$v);
}
define($k,$v);
}
}
}else{
define($key,$value);
if(!defined($key))
{
define($key,$value);
}
}
}

Expand Down

0 comments on commit 2c56889

Please sign in to comment.