From f029a61ccb75683dc6b0565c59eef66bc4eebd05 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Sun, 30 Jun 2019 18:43:41 -0400 Subject: [PATCH] [#14213] - Moved Container to its own folder; Renamed abstract firewall classes --- ext/phalcon/firewall/adapter.zep.c | 563 ------------------ ext/phalcon/firewall/adapter.zep.h | 190 ------ ext/phalcon/firewall/adapterinterface.zep.c | 70 --- ext/phalcon/firewall/adapterinterface.zep.h | 65 -- phalcon/{ => Container}/Container.zep | 2 +- .../AbstractAdapter.zep} | 5 +- phalcon/Firewall/Adapter/Acl.zep | 4 +- .../{ => Adapter}/AdapterInterface.zep | 2 +- phalcon/Firewall/Adapter/Annotations.zep | 4 +- phalcon/Firewall/Adapter/Micro/Acl.zep | 4 +- 10 files changed, 11 insertions(+), 898 deletions(-) delete mode 100644 ext/phalcon/firewall/adapter.zep.c delete mode 100644 ext/phalcon/firewall/adapter.zep.h delete mode 100644 ext/phalcon/firewall/adapterinterface.zep.c delete mode 100644 ext/phalcon/firewall/adapterinterface.zep.h rename phalcon/{ => Container}/Container.zep (97%) rename phalcon/Firewall/{Adapter.zep => Adapter/AbstractAdapter.zep} (97%) rename phalcon/Firewall/{ => Adapter}/AdapterInterface.zep (97%) diff --git a/ext/phalcon/firewall/adapter.zep.c b/ext/phalcon/firewall/adapter.zep.c deleted file mode 100644 index 4eb2cbf8fa0..00000000000 --- a/ext/phalcon/firewall/adapter.zep.c +++ /dev/null @@ -1,563 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../ext_config.h" -#endif - -#include -#include "../../php_ext.h" -#include "../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/object.h" -#include "kernel/operators.h" -#include "kernel/memory.h" -#include "kernel/fcall.h" -#include "kernel/exception.h" -#include "kernel/array.h" -#include "ext/spl/spl_exceptions.h" -#include "kernel/string.h" -#include "kernel/concat.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Firewall\Adapter - * - * Adapter for Phalcon\Firewall adapters - */ -ZEPHIR_INIT_CLASS(Phalcon_Firewall_Adapter) { - - ZEPHIR_REGISTER_CLASS(Phalcon\\Firewall, Adapter, phalcon, firewall_adapter, phalcon_firewall_adapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - /** - * Storing active identity object implementing Phalcon/Acl/RoleAware - */ - zend_declare_property_null(phalcon_firewall_adapter_ce, SL("activeIdentity"), ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * Storing active user role - */ - zend_declare_property_null(phalcon_firewall_adapter_ce, SL("activeRole"), ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * Should role always be resolved using role callback or just once? - * @var bool - */ - zend_declare_property_bool(phalcon_firewall_adapter_ce, SL("alwaysResolvingRole"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * Cache for caching access - * @var - */ - zend_declare_property_null(phalcon_firewall_adapter_ce, SL("cache"), ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * Default access - * @var int - */ - zend_declare_property_long(phalcon_firewall_adapter_ce, SL("defaultAccess"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * Events manager - * @var mixed - */ - zend_declare_property_null(phalcon_firewall_adapter_ce, SL("eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * Internal cache for caching access during request time - * @var mixed - */ - zend_declare_property_null(phalcon_firewall_adapter_ce, SL("internalCache"), ZEND_ACC_PROTECTED TSRMLS_CC); - - /** - * Anonymous function for getting user identity - this function must - * return string, array or object implementing Phalcon\Acl\RoleAware - * @var mixed - */ - zend_declare_property_null(phalcon_firewall_adapter_ce, SL("roleCallback"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_class_implements(phalcon_firewall_adapter_ce TSRMLS_CC, 1, phalcon_firewall_adapterinterface_ce); - zend_class_implements(phalcon_firewall_adapter_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); - return SUCCESS; - -} - -/** - * Storing active identity object implementing Phalcon/Acl/RoleAware - */ -PHP_METHOD(Phalcon_Firewall_Adapter, getActiveIdentity) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "activeIdentity"); - -} - -/** - * Storing active user role - */ -PHP_METHOD(Phalcon_Firewall_Adapter, getActiveRole) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "activeRole"); - -} - -/** - * Should role always be resolved using role callback or just once? - */ -PHP_METHOD(Phalcon_Firewall_Adapter, setAlwaysResolvingRole) { - - zval *alwaysResolvingRole_param = NULL, __$true, __$false; - zend_bool alwaysResolvingRole; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - - zephir_fetch_params(0, 1, 0, &alwaysResolvingRole_param); - - alwaysResolvingRole = zephir_get_boolval(alwaysResolvingRole_param); - - - if (alwaysResolvingRole) { - zephir_update_property_zval(this_ptr, SL("alwaysResolvingRole"), &__$true); - } else { - zephir_update_property_zval(this_ptr, SL("alwaysResolvingRole"), &__$false); - } - RETURN_THISW(); - -} - -/** - * Default access - */ -PHP_METHOD(Phalcon_Firewall_Adapter, getDefaultAccess) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "defaultAccess"); - -} - -/** - * Returns the internal event manager - */ -PHP_METHOD(Phalcon_Firewall_Adapter, getEventsManager) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "eventsManager"); - -} - -/** - * Gets role callback to fetch role name - */ -PHP_METHOD(Phalcon_Firewall_Adapter, getRoleCallback) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "roleCallback"); - -} - -/** - * Gets always resolving role option - */ -PHP_METHOD(Phalcon_Firewall_Adapter, isAlwaysResolvingRole) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "alwaysResolvingRole"); - -} - -/** - * Sets the cache adapter - */ -PHP_METHOD(Phalcon_Firewall_Adapter, setCache) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cache, cache_sub, _0, _1$$3, _2$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&cache_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &cache); - - - - zephir_update_property_zval(this_ptr, SL("cache"), cache); - zephir_read_property(&_0, this_ptr, SL("internalCache"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "_PHF_"); - ZEPHIR_CALL_METHOD(&_1$$3, cache, "get", NULL, 0, &_2$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("internalCache"), &_1$$3); - } - RETURN_THIS(); - -} - -/** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - */ -PHP_METHOD(Phalcon_Firewall_Adapter, setDefaultAccess) { - - zval *defaultAccess_param = NULL, _0; - zend_long defaultAccess; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - - zephir_fetch_params(0, 1, 0, &defaultAccess_param); - - defaultAccess = zephir_get_intval(defaultAccess_param); - - - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, defaultAccess); - zephir_update_property_zval(this_ptr, SL("defaultAccess"), &_0); - RETURN_THISW(); - -} - -/** - * Sets the events manager - */ -PHP_METHOD(Phalcon_Firewall_Adapter, setEventsManager) { - - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventsManager_sub); - - zephir_fetch_params(0, 1, 0, &eventsManager); - - - - zephir_update_property_zval(this_ptr, SL("eventsManager"), eventsManager); - RETURN_THISW(); - -} - -/** - * Sets role callback to fetch role name - */ -PHP_METHOD(Phalcon_Firewall_Adapter, setRoleCallback) { - - zval *callback, callback_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&callback_sub); - - zephir_fetch_params(0, 1, 0, &callback); - - - - if (!(zephir_is_callable(callback TSRMLS_CC))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_firewall_exception_ce, "Role callback must be function.", "phalcon/Firewall/Adapter.zep", 139); - return; - } - zephir_update_property_zval(this_ptr, SL("roleCallback"), callback); - RETURN_THISW(); - -} - -PHP_METHOD(Phalcon_Firewall_Adapter, callRoleCallback) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *container, container_sub, roleCallback, identity, _0, _1$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&roleCallback); - ZVAL_UNDEF(&identity); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &container); - - - - zephir_read_property(&_0, this_ptr, SL("roleCallback"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&roleCallback, &_0); - ZEPHIR_CALL_ZVAL_FUNCTION(&identity, &roleCallback, NULL, 0, container); - zephir_check_call_status(); - if (ZEPHIR_IS_EMPTY(&identity)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_firewall_exception_ce, "Function defined as roleCallback must return something.", "phalcon/Firewall/Adapter.zep", 154); - return; - } - if (Z_TYPE_P(&identity) == IS_OBJECT) { - if (!(zephir_instance_of_ev(&identity, phalcon_acl_roleaware_ce TSRMLS_CC))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_firewall_exception_ce, "Role passed as object must implement 'Phalcon\\Acl\\RoleAware'", "phalcon/Firewall/Adapter.zep", 159); - return; - } - zephir_update_property_zval(this_ptr, SL("activeIdentity"), &identity); - ZEPHIR_CALL_METHOD(&_1$$4, &identity, "getrolename", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("activeRole"), &_1$$4); - } else { - zephir_update_property_zval(this_ptr, SL("activeRole"), &identity); - } - ZEPHIR_MM_RESTORE(); - -} - -/** - * Gets access from cache - */ -PHP_METHOD(Phalcon_Firewall_Adapter, getAccessFromCache) { - - zval originalValues; - zval *key_param = NULL, *originalValues_param = NULL, *roleCacheKey_param = NULL, access, _0; - zval key, roleCacheKey; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&roleCacheKey); - ZVAL_UNDEF(&access); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&originalValues); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &key_param, &originalValues_param, &roleCacheKey_param); - - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - ZVAL_EMPTY_STRING(&key); - } - if (!originalValues_param) { - ZEPHIR_INIT_VAR(&originalValues); - array_init(&originalValues); - } else { - zephir_get_arrval(&originalValues, originalValues_param); - } - if (!roleCacheKey_param) { - ZEPHIR_INIT_VAR(&roleCacheKey); - ZVAL_STRING(&roleCacheKey, ""); - } else { - zephir_get_strval(&roleCacheKey, roleCacheKey_param); - } - - - zephir_read_property(&_0, this_ptr, SL("internalCache"), PH_NOISY_CC | PH_READONLY); - zephir_array_isset_fetch(&access, &_0, &key, 1 TSRMLS_CC); - RETURN_CTOR(&access); - -} - -/** - * Handles a user exception - */ -PHP_METHOD(Phalcon_Firewall_Adapter, handleException) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *exception, exception_sub, eventsManager, _0, _1$$3, _2$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&exception_sub); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &exception); - - - - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "firewall:beforeException"); - ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr, exception); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_BOOL(0); - } - } - ZEPHIR_MM_RESTORE(); - -} - -/** - * Fires event or throwing exception - */ -PHP_METHOD(Phalcon_Firewall_Adapter, fireEventOrThrowException) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool access; - zval actionName, controllerName; - zval *role, role_sub, *actionName_param = NULL, *controllerName_param = NULL, *access_param = NULL, eventsManager, roleName, _0, _1$$4, _2$$5, _3$$5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&role_sub); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&roleName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&controllerName); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 0, &role, &actionName_param, &controllerName_param, &access_param); - - zephir_get_strval(&actionName, actionName_param); - zephir_get_strval(&controllerName, controllerName_param); - access = zephir_get_boolval(access_param); - - - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (access) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, "firewall:afterCheck"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_1$$4, this_ptr); - zephir_check_call_status(); - } - } else { - if (Z_TYPE_P(role) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&roleName); - zephir_fast_join_str(&roleName, SL(", "), role TSRMLS_CC); - } else { - ZEPHIR_CPY_WRT(&roleName, role); - } - ZEPHIR_INIT_VAR(&_2$$5); - ZEPHIR_CONCAT_SVSVSV(&_2$$5, "Role name ", &roleName, " doesn't have access to action ", &actionName, " in controller ", &controllerName); - ZVAL_LONG(&_3$$5, 403); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "throwfirewallexception", NULL, 0, &_2$$5, &_3$$5); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_MM_RESTORE(); - -} - -/** - * Saves access in cache and internal cache - */ -PHP_METHOD(Phalcon_Firewall_Adapter, saveAccessInCache) { - - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool access; - zval *key_param = NULL, *access_param = NULL, cache, _0, _1, _2$$3, _3$$3; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &key_param, &access_param); - - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - ZVAL_EMPTY_STRING(&key); - } - access = zephir_get_boolval(access_param); - - - ZEPHIR_INIT_VAR(&_0); - ZVAL_BOOL(&_0, access); - zephir_update_property_array(this_ptr, SL("internalCache"), &key, &_0); - zephir_read_property(&_1, this_ptr, SL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_1); - if (Z_TYPE_P(&cache) != IS_NULL) { - zephir_read_property(&_2$$3, this_ptr, SL("internalCache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "_PHF_"); - ZEPHIR_CALL_METHOD(NULL, &cache, "set", NULL, 0, &_3$$3, &_2$$3); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); - -} - -/** - * Throws an internal exception - */ -PHP_METHOD(Phalcon_Firewall_Adapter, throwFirewallException) { - - zend_long exceptionCode, ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, *exceptionCode_param = NULL, exception, _0, _1; - zval message; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&exception); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); - - zephir_get_strval(&message, message_param); - if (!exceptionCode_param) { - exceptionCode = 0; - } else { - exceptionCode = zephir_get_intval(exceptionCode_param); - } - - - ZEPHIR_INIT_VAR(&exception); - object_init_ex(&exception, phalcon_firewall_exception_ce); - ZVAL_LONG(&_0, exceptionCode); - ZEPHIR_CALL_METHOD(NULL, &exception, "__construct", NULL, 1, &message, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "handleexception", NULL, 0, &exception); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1)) { - RETURN_MM_BOOL(0); - } - zephir_throw_exception_debug(&exception, "phalcon/Firewall/Adapter.zep", 258 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - return; - -} - diff --git a/ext/phalcon/firewall/adapter.zep.h b/ext/phalcon/firewall/adapter.zep.h deleted file mode 100644 index d81b12f756b..00000000000 --- a/ext/phalcon/firewall/adapter.zep.h +++ /dev/null @@ -1,190 +0,0 @@ - -extern zend_class_entry *phalcon_firewall_adapter_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Firewall_Adapter); - -PHP_METHOD(Phalcon_Firewall_Adapter, getActiveIdentity); -PHP_METHOD(Phalcon_Firewall_Adapter, getActiveRole); -PHP_METHOD(Phalcon_Firewall_Adapter, setAlwaysResolvingRole); -PHP_METHOD(Phalcon_Firewall_Adapter, getDefaultAccess); -PHP_METHOD(Phalcon_Firewall_Adapter, getEventsManager); -PHP_METHOD(Phalcon_Firewall_Adapter, getRoleCallback); -PHP_METHOD(Phalcon_Firewall_Adapter, isAlwaysResolvingRole); -PHP_METHOD(Phalcon_Firewall_Adapter, setCache); -PHP_METHOD(Phalcon_Firewall_Adapter, setDefaultAccess); -PHP_METHOD(Phalcon_Firewall_Adapter, setEventsManager); -PHP_METHOD(Phalcon_Firewall_Adapter, setRoleCallback); -PHP_METHOD(Phalcon_Firewall_Adapter, callRoleCallback); -PHP_METHOD(Phalcon_Firewall_Adapter, getAccessFromCache); -PHP_METHOD(Phalcon_Firewall_Adapter, handleException); -PHP_METHOD(Phalcon_Firewall_Adapter, fireEventOrThrowException); -PHP_METHOD(Phalcon_Firewall_Adapter, saveAccessInCache); -PHP_METHOD(Phalcon_Firewall_Adapter, throwFirewallException); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_firewall_adapter_setalwaysresolvingrole, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, alwaysResolvingRole, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, alwaysResolvingRole) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_getdefaultaccess, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_getdefaultaccess, 0, 0, IS_LONG, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapter_geteventsmanager, 0, 0, Phalcon\\Events\\ManagerInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_geteventsmanager, 0, 0, IS_OBJECT, "Phalcon\\Events\\ManagerInterface", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapter_getrolecallback, 0, 0, Closure, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_getrolecallback, 0, 0, IS_OBJECT, "Closure", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_isalwaysresolvingrole, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_isalwaysresolvingrole, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapter_setcache, 0, 1, Phalcon\\Firewall\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_setcache, 0, 1, IS_OBJECT, "Phalcon\\Firewall\\AdapterInterface", 0) -#endif - ZEND_ARG_OBJ_INFO(0, cache, Phalcon\\Cache\\Adapter\\AdapterInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapter_setdefaultaccess, 0, 1, Phalcon\\Firewall\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_setdefaultaccess, 0, 1, IS_OBJECT, "Phalcon\\Firewall\\AdapterInterface", 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, defaultAccess, IS_LONG, 0) -#else - ZEND_ARG_INFO(0, defaultAccess) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapter_seteventsmanager, 0, 1, Phalcon\\Firewall\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_seteventsmanager, 0, 1, IS_OBJECT, "Phalcon\\Firewall\\AdapterInterface", 0) -#endif - ZEND_ARG_OBJ_INFO(0, eventsManager, Phalcon\\Events\\ManagerInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapter_setrolecallback, 0, 1, Phalcon\\Firewall\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_setrolecallback, 0, 1, IS_OBJECT, "Phalcon\\Firewall\\AdapterInterface", 0) -#endif - ZEND_ARG_INFO(0, callback) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_firewall_adapter_callrolecallback, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, container, Phalcon\\DiInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_getaccessfromcache, 0, 1, _IS_BOOL, 1) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_getaccessfromcache, 0, 1, _IS_BOOL, NULL, 1) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, key) -#endif - ZEND_ARG_ARRAY_INFO(0, originalValues, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, roleCacheKey, IS_STRING, 1) -#else - ZEND_ARG_INFO(0, roleCacheKey) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_firewall_adapter_handleexception, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, exception, Exception, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_firewall_adapter_fireeventorthrowexception, 0, 0, 4) - ZEND_ARG_INFO(0, role) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, actionName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, actionName) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, controllerName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, controllerName) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, access, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, access) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_firewall_adapter_saveaccessincache, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, key) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, access, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, access) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_throwfirewallexception, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapter_throwfirewallexception, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, message) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, exceptionCode, IS_LONG, 0) -#else - ZEND_ARG_INFO(0, exceptionCode) -#endif -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_firewall_adapter_method_entry) { - PHP_ME(Phalcon_Firewall_Adapter, getActiveIdentity, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, getActiveRole, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, setAlwaysResolvingRole, arginfo_phalcon_firewall_adapter_setalwaysresolvingrole, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, getDefaultAccess, arginfo_phalcon_firewall_adapter_getdefaultaccess, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, getEventsManager, arginfo_phalcon_firewall_adapter_geteventsmanager, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, getRoleCallback, arginfo_phalcon_firewall_adapter_getrolecallback, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, isAlwaysResolvingRole, arginfo_phalcon_firewall_adapter_isalwaysresolvingrole, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, setCache, arginfo_phalcon_firewall_adapter_setcache, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, setDefaultAccess, arginfo_phalcon_firewall_adapter_setdefaultaccess, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, setEventsManager, arginfo_phalcon_firewall_adapter_seteventsmanager, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, setRoleCallback, arginfo_phalcon_firewall_adapter_setrolecallback, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Firewall_Adapter, callRoleCallback, arginfo_phalcon_firewall_adapter_callrolecallback, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Firewall_Adapter, getAccessFromCache, arginfo_phalcon_firewall_adapter_getaccessfromcache, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Firewall_Adapter, handleException, arginfo_phalcon_firewall_adapter_handleexception, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Firewall_Adapter, fireEventOrThrowException, arginfo_phalcon_firewall_adapter_fireeventorthrowexception, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Firewall_Adapter, saveAccessInCache, arginfo_phalcon_firewall_adapter_saveaccessincache, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Firewall_Adapter, throwFirewallException, arginfo_phalcon_firewall_adapter_throwfirewallexception, ZEND_ACC_PROTECTED) - PHP_FE_END -}; diff --git a/ext/phalcon/firewall/adapterinterface.zep.c b/ext/phalcon/firewall/adapterinterface.zep.c deleted file mode 100644 index cc733988727..00000000000 --- a/ext/phalcon/firewall/adapterinterface.zep.c +++ /dev/null @@ -1,70 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../ext_config.h" -#endif - -#include -#include "../../php_ext.h" -#include "../../ext.h" - -#include - -#include "kernel/main.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Dispatcher\Firewall\AdapterInterface - * - * Interface for Phalcon\Mvc\Dispatcher\Firewall adapters - */ -ZEPHIR_INIT_CLASS(Phalcon_Firewall_AdapterInterface) { - - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Firewall, AdapterInterface, phalcon, firewall_adapterinterface, phalcon_firewall_adapterinterface_method_entry); - - return SUCCESS; - -} - -/** - * Returns the default ACL access level - */ -ZEPHIR_DOC_METHOD(Phalcon_Firewall_AdapterInterface, getDefaultAccess); - -/** - * Gets role callback to fetch role name - */ -ZEPHIR_DOC_METHOD(Phalcon_Firewall_AdapterInterface, getRoleCallback); - -/** - * Gets always resolving role option - */ -ZEPHIR_DOC_METHOD(Phalcon_Firewall_AdapterInterface, isAlwaysResolvingRole); - -/** - * Sets always resolving role option - */ -ZEPHIR_DOC_METHOD(Phalcon_Firewall_AdapterInterface, setAlwaysResolvingRole); - -/** - * Sets cache backend - */ -ZEPHIR_DOC_METHOD(Phalcon_Firewall_AdapterInterface, setCache); - -/** - * Sets the default access level (Phalcon\Acl::ALLOW or Phalcon\Acl::DENY) - */ -ZEPHIR_DOC_METHOD(Phalcon_Firewall_AdapterInterface, setDefaultAccess); - -/** - * Sets role callback to fetch role name - */ -ZEPHIR_DOC_METHOD(Phalcon_Firewall_AdapterInterface, setRoleCallback); - diff --git a/ext/phalcon/firewall/adapterinterface.zep.h b/ext/phalcon/firewall/adapterinterface.zep.h deleted file mode 100644 index 6d141571552..00000000000 --- a/ext/phalcon/firewall/adapterinterface.zep.h +++ /dev/null @@ -1,65 +0,0 @@ - -extern zend_class_entry *phalcon_firewall_adapterinterface_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Firewall_AdapterInterface); - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapterinterface_getdefaultaccess, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapterinterface_getdefaultaccess, 0, 0, IS_LONG, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapterinterface_isalwaysresolvingrole, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapterinterface_isalwaysresolvingrole, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_firewall_adapterinterface_setalwaysresolvingrole, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, alwaysResolvingRole, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, alwaysResolvingRole) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapterinterface_setcache, 0, 1, Phalcon\\Firewall\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapterinterface_setcache, 0, 1, IS_OBJECT, "Phalcon\\Firewall\\AdapterInterface", 0) -#endif - ZEND_ARG_OBJ_INFO(0, cache, Phalcon\\Cache\\Adapter\\AdapterInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapterinterface_setdefaultaccess, 0, 1, Phalcon\\Firewall\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapterinterface_setdefaultaccess, 0, 1, IS_OBJECT, "Phalcon\\Firewall\\AdapterInterface", 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, defaultAccess, IS_LONG, 0) -#else - ZEND_ARG_INFO(0, defaultAccess) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_firewall_adapterinterface_setrolecallback, 0, 1, Phalcon\\Firewall\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_firewall_adapterinterface_setrolecallback, 0, 1, IS_OBJECT, "Phalcon\\Firewall\\AdapterInterface", 0) -#endif - ZEND_ARG_INFO(0, callback) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_firewall_adapterinterface_method_entry) { - PHP_ABSTRACT_ME(Phalcon_Firewall_AdapterInterface, getDefaultAccess, arginfo_phalcon_firewall_adapterinterface_getdefaultaccess) - PHP_ABSTRACT_ME(Phalcon_Firewall_AdapterInterface, getRoleCallback, NULL) - PHP_ABSTRACT_ME(Phalcon_Firewall_AdapterInterface, isAlwaysResolvingRole, arginfo_phalcon_firewall_adapterinterface_isalwaysresolvingrole) - PHP_ABSTRACT_ME(Phalcon_Firewall_AdapterInterface, setAlwaysResolvingRole, arginfo_phalcon_firewall_adapterinterface_setalwaysresolvingrole) - PHP_ABSTRACT_ME(Phalcon_Firewall_AdapterInterface, setCache, arginfo_phalcon_firewall_adapterinterface_setcache) - PHP_ABSTRACT_ME(Phalcon_Firewall_AdapterInterface, setDefaultAccess, arginfo_phalcon_firewall_adapterinterface_setdefaultaccess) - PHP_ABSTRACT_ME(Phalcon_Firewall_AdapterInterface, setRoleCallback, arginfo_phalcon_firewall_adapterinterface_setrolecallback) - PHP_FE_END -}; diff --git a/phalcon/Container.zep b/phalcon/Container/Container.zep similarity index 97% rename from phalcon/Container.zep rename to phalcon/Container/Container.zep index bef09f1921d..6247d31ace9 100644 --- a/phalcon/Container.zep +++ b/phalcon/Container/Container.zep @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Phalcon; +namespace Phalcon\Container; use Psr\Container\ContainerInterface; use Phalcon\DiInterface; diff --git a/phalcon/Firewall/Adapter.zep b/phalcon/Firewall/Adapter/AbstractAdapter.zep similarity index 97% rename from phalcon/Firewall/Adapter.zep rename to phalcon/Firewall/Adapter/AbstractAdapter.zep index 842a07a00bd..e6e4ae78fe1 100644 --- a/phalcon/Firewall/Adapter.zep +++ b/phalcon/Firewall/Adapter/AbstractAdapter.zep @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Phalcon\Firewall; +namespace Phalcon\Firewall\Adapter; use Closure; use Phalcon\Acl; @@ -17,12 +17,13 @@ use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; use Phalcon\DiInterface; use Phalcon\Events\EventsAwareInterface; use Phalcon\Events\ManagerInterface; +use Phalcon\Firewall\Exception; use Phalcon\Mvc\Dispatcher; /** * Adapter for Phalcon\Firewall adapters */ -abstract class Adapter implements AdapterInterface, EventsAwareInterface +abstract class AbstractAdapter implements AdapterInterface, EventsAwareInterface { /** * Storing active identity object implementing Phalcon/Acl/RoleAware diff --git a/phalcon/Firewall/Adapter/Acl.zep b/phalcon/Firewall/Adapter/Acl.zep index 11476733879..2694764d15f 100644 --- a/phalcon/Firewall/Adapter/Acl.zep +++ b/phalcon/Firewall/Adapter/Acl.zep @@ -14,14 +14,14 @@ use Phalcon\Di; use Phalcon\Cache\Adapter\AdapterInterface; use Phalcon\Events\Event; use Phalcon\Events\ManagerInterface; -use Phalcon\Firewall\Adapter; +use Phalcon\Firewall\Adapter\AbstractAdapter; use Phalcon\Firewall\Exception; use Phalcon\Mvc\DispatcherInterface; /** * FirewallZ for Phalcon\Application which depends on acl and dispatcher */ -class Acl extends Adapter +class Acl extends AbstractAdapter { /** * Acl service name diff --git a/phalcon/Firewall/AdapterInterface.zep b/phalcon/Firewall/Adapter/AdapterInterface.zep similarity index 97% rename from phalcon/Firewall/AdapterInterface.zep rename to phalcon/Firewall/Adapter/AdapterInterface.zep index 09519d99a3d..654ed5feb8f 100644 --- a/phalcon/Firewall/AdapterInterface.zep +++ b/phalcon/Firewall/Adapter/AdapterInterface.zep @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Phalcon\Firewall; +namespace Phalcon\Firewall\Adapter; use Phalcon\Mvc\DispatcherInterface; use Phalcon\Cache\Adapter\AdapterInterface as CacheAdapterInterface; diff --git a/phalcon/Firewall/Adapter/Annotations.zep b/phalcon/Firewall/Adapter/Annotations.zep index 10f7497493b..bba011c19a9 100644 --- a/phalcon/Firewall/Adapter/Annotations.zep +++ b/phalcon/Firewall/Adapter/Annotations.zep @@ -13,7 +13,7 @@ namespace Phalcon\Firewall\Adapter; use Phalcon\Annotations\Adapter\AdapterInterface; use Phalcon\Events\Event; use Phalcon\Events\ManagerInterface; -use Phalcon\Firewall\Adapter; +use Phalcon\Firewall\Adapter\AbstractAdapter; use Phalcon\Firewall\Exception; use Phalcon\Mvc\DispatcherInterface; use ReflectionClass; @@ -21,7 +21,7 @@ use ReflectionClass; /** * Firewall which depends on annotations and dispatcher */ -class Annotations extends Adapter +class Annotations extends AbstractAdapter { /** * Number of active active arguments in active annotation diff --git a/phalcon/Firewall/Adapter/Micro/Acl.zep b/phalcon/Firewall/Adapter/Micro/Acl.zep index e371beff22c..ed27a45d749 100644 --- a/phalcon/Firewall/Adapter/Micro/Acl.zep +++ b/phalcon/Firewall/Adapter/Micro/Acl.zep @@ -15,7 +15,7 @@ use Phalcon\Cache\Adapter\AdapterInterface; use Phalcon\DiInterface; use Phalcon\Events\Event; use Phalcon\Events\ManagerInterface; -use Phalcon\Firewall\Adapter; +use Phalcon\Firewall\Adapter\AbstractAdapter; use Phalcon\Firewall\Exception; use Phalcon\Mvc\Micro; use Phalcon\Mvc\Model\BinderInterface; @@ -24,7 +24,7 @@ use Phalcon\Mvc\Router; /** * Firewall for Phalcon\Mvc\Micro which depends on ACL */ -class Acl extends Adapter +class Acl extends AbstractAdapter { /** * Acl service name