From 4a1a569832063b138798afa3aa89acabb464c45d Mon Sep 17 00:00:00 2001 From: rafageist Date: Sat, 24 Aug 2019 00:05:14 -0400 Subject: [PATCH] fix rules for default action Run --- CHANGELOG.md | 8 +++++++- README.md | 2 +- composer.json | 2 +- src/ways.php | 17 ++++++++++++----- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bdac8d..af794a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,13 @@ -Aug 23, 2019 +Aug 24, 2019 +------------------- +- `fix`: rules for default action Run +- `release`: version 2.3.4 + +Jul 23, 2019 ------------------- - `fix`: fix flow of the data before bootstrap and invoke - `release`: version 2.3.3 + Jul 23, 2019 ------------------- - `fix`: bug fix in rules diff --git a/README.md b/README.md index 8c3d6c5..82d0950 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Div PHP Ways 2.3.3 +# Div PHP Ways 2.3.4 A "way" is different to a "route". We need a path for found a specific resource, but we need a way for do something. diff --git a/composer.json b/composer.json index 05b4aed..478be24 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "controllers" ], "homepage": "https://divengine.com/ways", - "version": "2.3.3", + "version": "2.3.4", "require": { "php": ">=5.4.0", "ext-json": "*" diff --git a/src/ways.php b/src/ways.php index 8bbfba7..f49d8d8 100644 --- a/src/ways.php +++ b/src/ways.php @@ -21,7 +21,7 @@ * * @package divengine/ways * @author Rafa Rodriguez [@rafageist] - * @version 2.3.3 + * @version 2.3.4 * * @link https://divengine.com * @link https://divengine.com/ways @@ -57,7 +57,7 @@ class ways const PROPERTY_RULES = 'rules'; - private static $__version = '2.3.3'; + private static $__version = '2.3.4'; private static $__way_var; @@ -1091,9 +1091,12 @@ public static function call($controller, $data = [], $args = [], &$output = '', $method = "{$controller}@{$action}"; if (isset($rules[$method])) { $rules = $rules[$method]; - if (is_string($rules)) { - $rules = [$rules]; - } + } elseif (isset($rules[$action])) { + $rules = $rules[$action]; + } + + if (is_string($rules)) { + $rules = [$rules]; } foreach ($rules as $rule) { @@ -1469,9 +1472,13 @@ public static function register($path, $properties = []) if (!is_array($rules)) { $rules = [$rules]; } + foreach ($rules as $rule) { + if (!is_array(self::$__controllers[$prop[self::PROPERTY_ID]]['prop'][self::PROPERTY_RULES])) + self::$__controllers[$prop[self::PROPERTY_ID]]['prop'][self::PROPERTY_RULES] = []; self::$__controllers[$prop[self::PROPERTY_ID]]['prop'][self::PROPERTY_RULES]['Run'][] = $rule; } + }