Skip to content

Commit

Permalink
v2.2.1 Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaratug committed Nov 2, 2018
1 parent 13a7cd9 commit 03e7ce7
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
vendor/
composer.lock
2 changes: 1 addition & 1 deletion App/Listeners/SampleListener.php
Expand Up @@ -11,4 +11,4 @@ public function handle()
Log::info('listener tetiklendi - {SampleListener}');
}

}
}
6 changes: 6 additions & 0 deletions CHANGELOG
@@ -1,3 +1,9 @@
v2.2.1
- [Düzeltme] public_path() fonksiyonuna parametre verilmezse, Public pathini döndürmesi sağlandı.
- [Düzeltme] Image kütüphanesinde, default değerleri resetleyen düzenleme yapıldı.
- [Düzeltme] Event kütüphanesindeki listener, action ve parametre tanımlama ile ilgili methodlar yenilendi.
- [Düzeltme] Routing kütüphanesindeki gruplama hatası giderildi.

v2.2.0
- [Yeni] JWT kütüphanesi eklendi.
- [Yeni] Validation kütüphanesinde, form verilerinin request() methodu ile topluca tanımlanması sağlandı.
Expand Down
2 changes: 1 addition & 1 deletion System/Kernel/Constants.php
Expand Up @@ -42,7 +42,7 @@
define('ENV', 'development');

// Framework Version
define('VERSION', '2.2.0');
define('VERSION', '2.2.1');

// Default Timezone
define('TIMEZONE', 'Europe/Istanbul');
16 changes: 10 additions & 6 deletions System/Kernel/Helpers.php
Expand Up @@ -195,16 +195,20 @@ function get_asset($file, $version = null)
/**
* Get files inside Public directory
*
* @param string $file
* @param string|null $file
* @return string
*/
if (!function_exists('public_path')) {
function public_path($file)
function public_path($file = null)
{
if (file_exists(ROOT_DIR . '/Public/' . $file))
return ROOT_DIR . '/Public/' . $file;
else
throw new System\Libs\Exception\ExceptionHandler('Dosya bulunamadı', '<b>Public : </b> ' . $file);
if ($file !== null) {
if (file_exists(ROOT_DIR . '/Public/' . $file))
return ROOT_DIR . '/Public/' . $file;
else
throw new System\Libs\Exception\ExceptionHandler('Dosya bulunamadı', '<b>Public : </b> ' . $file);
}

return ROOT_DIR . '/Public/';
}
}

Expand Down
66 changes: 56 additions & 10 deletions System/Libs/Event/Event.php
Expand Up @@ -16,29 +16,75 @@

class Event
{
/**
* @var string
*/
private $action = 'handle';

/**
* @var array
*/
private $params = [];

/**
* @var string
*/
private $listeners = null;

/**
* Trigger an event
* Set listener
*
* @param string $event
* @param string $method
* @param array $params
* @return void
* @return $this
*/
public function trigger($event, $method = 'handle', $params = [])
public function listener($event)
{
$listeners = config('services.listeners');

foreach ($listeners[$event] as $listener) {
$this->listeners = $listeners[$event];

return $this;
}

/**
* Set action
*
* @param string $action
* @return $this
*/
public function action($action)
{
$this->action = $action;

return $this;
}

/**
* Set parameters
*
* @param array $params
* @return $this
*/
public function params(array $params)
{
$this->params = $params;

return $this;
}

/**
* Fire event
*/
public function fire()
{
foreach ($this->listeners as $listener) {
if (!class_exists($listener))
throw new ExceptionHandler('Listener sınıfı bulunamadı.', $listener);

if (!method_exists($listener, $method))
throw new ExceptionHandler('Listener sınıfına ait method bulunamadı.', $listener . '::' . $method . '()');

call_user_func_array(array(new $listener, $method), $params);
if (!method_exists($listener, $this->action))
throw new ExceptionHandler('Listener sınıfına ait method bulunamadı.', $listener . '::' . $this->action . '()');

call_user_func_array(array(new $listener, $this->action), $this->params);
}
}

Expand Down
12 changes: 12 additions & 0 deletions System/Libs/Image/Image.php
Expand Up @@ -743,6 +743,8 @@ private function _outputImage($destination = null)
$pathinfo = pathinfo($destination);
$extension = (array_key_exists('extension', $pathinfo)) ? strtolower($pathinfo['extension']) : $this->extension;

$this->_reset();

if ($extension == 'jpg' || $extension == 'jpeg')
imagejpeg($this->image, $destination, $this->quality);
else if ($extension == 'png') {
Expand All @@ -754,6 +756,16 @@ private function _outputImage($destination = null)
}
}

/**
* Reset class variables
*/
private function _reset()
{
foreach (get_class_vars(get_class($this)) as $name => $default) {
$this -> $name = $default;
}
}

/**
* Get error messages
*
Expand Down
11 changes: 5 additions & 6 deletions System/Libs/Router/Router.php
Expand Up @@ -85,16 +85,18 @@ public static function group($callback)
// Call the Callable
call_user_func($callback);

self::$groupped--;

if (self::$groupped > 0) {
self::$baseRoute = self::$groups[self::$groupped-1]['baseRoute'];
self::$middlewares = self::$groups[self::$groupped-1]['middlewares'];
self::$namespace = self::$groups[self::$groupped-1]['namespace'];
self::$domain = self::$groups[self::$groupped-1]['domain'];
self::$ip = self::$groups[self::$groupped-1]['ip'];
self::$ssl = self::$groups[self::$groupped-1]['ssl'];
} else {
}

self::$groupped--;

if (self::$groupped <= 0) {
// Reset Base Route
self::$baseRoute = '/';

Expand All @@ -112,9 +114,6 @@ public static function group($callback)

// Reset SSL
self::$ssl = false;

// Reset Group Counter
self::$groupped = 0;
}
}

Expand Down

0 comments on commit 03e7ce7

Please sign in to comment.