/** * Detects and returns the first available cache driver. * * @return \Xpl\Cache\DriverInterface */ PHP_METHOD(Xpl_Cache_Cache, getDetectedDriver) { zend_class_entry *_7$$4; HashTable *_2; HashPosition _1; zval *driverClasses = NULL, *classname = NULL, *_0 = NULL, **_3, *_4$$3 = NULL, *_5$$3 = NULL, *_6$$4 = NULL; zephir_fcall_cache_entry *_8 = NULL; int ZEPHIR_LAST_CALL_STATUS; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(driverClasses); zephir_create_array(driverClasses, 3, 0 TSRMLS_CC); ZEPHIR_INIT_VAR(_0); ZVAL_STRING(_0, "Xpl\\Cache\\Driver\\ApcuDriver", 1); zephir_array_fast_append(driverClasses, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Xpl\\Cache\\Driver\\ApcDriver", 1); zephir_array_fast_append(driverClasses, _0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "Xpl\\Cache\\Driver\\XCacheDriver", 1); zephir_array_fast_append(driverClasses, _0); zephir_is_iterable(driverClasses, &_2, &_1, 0, 0, "xpl/cache/cache.zep", 215); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HVALUE(classname, _3); ZEPHIR_INIT_NVAR(_4$$3); ZEPHIR_INIT_LNVAR(_5$$3); ZEPHIR_CONCAT_VS(_5$$3, classname, "::isAvailable"); ZEPHIR_CALL_USER_FUNC(_4$$3, _5$$3); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_4$$3)) { zephir_fetch_safe_class(_6$$4, classname); _7$$4 = zend_fetch_class(Z_STRVAL_P(_6$$4), Z_STRLEN_P(_6$$4), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); object_init_ex(return_value, _7$$4); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", &_8, 0); zephir_check_call_status(); } RETURN_MM(); } } object_init_ex(return_value, xpl_cache_driver_memorydriver_ce); if (zephir_has_constructor(return_value TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); } RETURN_MM(); }
/** * Listens for notifications from the models manager */ PHP_METHOD(Phalcon_Mvc_Collection_Behavior_Timestampable, notify) { HashTable *_2$$12; HashPosition _1$$12; zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *type_param = NULL, *model, *options = NULL, *timestamp = NULL, *singleField = NULL, *field = NULL, *generator = NULL, *format = NULL, *_0 = NULL, **_3$$12; zval *type = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &type_param, &model); if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { zephir_get_strval(type, type_param); } else { ZEPHIR_INIT_VAR(type); ZVAL_EMPTY_STRING(type); } ZEPHIR_CALL_METHOD(&_0, this_ptr, "musttakeaction", NULL, 0, type); zephir_check_call_status(); if (!ZEPHIR_IS_TRUE_IDENTICAL(_0)) { RETURN_MM_NULL(); } ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0, type); zephir_check_call_status(); if (Z_TYPE_P(options) == IS_ARRAY) { ZEPHIR_OBS_VAR(field); if (!(zephir_array_isset_string_fetch(&field, options, SS("field"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'field' is required", "phalcon/mvc/collection/behavior/timestampable.zep", 56); return; } ZEPHIR_INIT_VAR(timestamp); ZVAL_NULL(timestamp); ZEPHIR_OBS_VAR(format); if (zephir_array_isset_string_fetch(&format, options, SS("format"), 0 TSRMLS_CC)) { ZEPHIR_CALL_FUNCTION(×tamp, "date", NULL, 316, format); zephir_check_call_status(); } else { ZEPHIR_OBS_VAR(generator); if (zephir_array_isset_string_fetch(&generator, options, SS("generator"), 0 TSRMLS_CC)) { if (Z_TYPE_P(generator) == IS_OBJECT) { if (zephir_instance_of_ev(generator, zend_ce_closure TSRMLS_CC)) { ZEPHIR_INIT_NVAR(timestamp); ZEPHIR_CALL_USER_FUNC(timestamp, generator); zephir_check_call_status(); } } } } if (Z_TYPE_P(timestamp) == IS_NULL) { ZEPHIR_INIT_NVAR(timestamp); zephir_time(timestamp); } if (Z_TYPE_P(field) == IS_ARRAY) { zephir_is_iterable(field, &_2$$12, &_1$$12, 0, 0, "phalcon/mvc/collection/behavior/timestampable.zep", 94); for ( ; zend_hash_get_current_data_ex(_2$$12, (void**) &_3$$12, &_1$$12) == SUCCESS ; zend_hash_move_forward_ex(_2$$12, &_1$$12) ) { ZEPHIR_GET_HVALUE(singleField, _3$$12); ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_4, 0, singleField, timestamp); zephir_check_call_status(); } } else { ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, field, timestamp); zephir_check_call_status(); } } ZEPHIR_MM_RESTORE(); }
/** * Resolves the service * * @param array parameters * @param \Phalcon\DiInterface dependencyInjector * @return mixed */ PHP_METHOD(Phalcon_Di_Service, resolve) { zend_class_entry *_1$$15; zend_bool found = 0; int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, *dependencyInjector = NULL, *shared = NULL, *definition = NULL, *sharedInstance = NULL, *instance = NULL, *builder = NULL, *_0$$15 = NULL, *_2$$22, *_3$$22, *_4$$22; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &dependencyInjector); if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } if (!dependencyInjector) { dependencyInjector = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(shared); zephir_read_property_this(&shared, this_ptr, SL("_shared"), PH_NOISY_CC); if (zephir_is_true(shared)) { ZEPHIR_OBS_VAR(sharedInstance); zephir_read_property_this(&sharedInstance, this_ptr, SL("_sharedInstance"), PH_NOISY_CC); if (Z_TYPE_P(sharedInstance) != IS_NULL) { RETURN_CCTOR(sharedInstance); } } found = 1; ZEPHIR_INIT_VAR(instance); ZVAL_NULL(instance); ZEPHIR_OBS_VAR(definition); zephir_read_property_this(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(definition) == IS_STRING) { if (zephir_class_exists(definition, 1 TSRMLS_CC)) { if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, definition, parameters TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, definition TSRMLS_CC); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, definition TSRMLS_CC); zephir_check_call_status(); } } else { found = 0; } } else { if (Z_TYPE_P(definition) == IS_OBJECT) { if (zephir_instance_of_ev(definition, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { _1$$15 = zend_fetch_class(SL("Closure"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); ZEPHIR_CALL_CE_STATIC(&_0$$15, _1$$15, "bind", NULL, 0, definition, dependencyInjector); zephir_check_call_status(); ZEPHIR_CPY_WRT(definition, _0$$15); } if (Z_TYPE_P(parameters) == IS_ARRAY) { ZEPHIR_INIT_NVAR(instance); ZEPHIR_CALL_USER_FUNC_ARRAY(instance, definition, parameters); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_CALL_USER_FUNC(instance, definition); zephir_check_call_status(); } } else { ZEPHIR_CPY_WRT(instance, definition); } } else { if (Z_TYPE_P(definition) == IS_ARRAY) { ZEPHIR_INIT_VAR(builder); object_init_ex(builder, phalcon_di_service_builder_ce); if (zephir_has_constructor(builder TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, builder, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&instance, builder, "build", NULL, 181, dependencyInjector, definition, parameters); zephir_check_call_status(); } else { found = 0; } } } if (found == 0) { ZEPHIR_INIT_VAR(_2$$22); object_init_ex(_2$$22, phalcon_di_exception_ce); _3$$22 = zephir_fetch_nproperty_this(this_ptr, SL("_name"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_4$$22); ZEPHIR_CONCAT_SVS(_4$$22, "Service '", _3$$22, "' cannot be resolved"); ZEPHIR_CALL_METHOD(NULL, _2$$22, "__construct", NULL, 9, _4$$22); zephir_check_call_status(); zephir_throw_exception_debug(_2$$22, "phalcon/di/service.zep", 208 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(shared)) { zephir_update_property_this(this_ptr, SL("_sharedInstance"), instance TSRMLS_CC); } if (1) { zephir_update_property_this(this_ptr, SL("_resolved"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_resolved"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } RETURN_CCTOR(instance); }
/** * Dispatches a handle action taking into account the routing parameters * * @return object */ PHP_METHOD(Phalcon_Dispatcher, _dispatch) { HashTable *_53$$39; HashPosition _52$$39; zval *_30$$6 = NULL, *_60$$44 = NULL, *_62$$44 = NULL, *_63$$44 = NULL, *_68$$45 = NULL, *_70$$45 = NULL; zval *value = NULL, *handler = NULL, *dependencyInjector = NULL, *namespaceName = NULL, *handlerName = NULL, *actionName = NULL, *params = NULL, *eventsManager = NULL, *actionSuffix = NULL, *handlerClass = NULL, *status = NULL, *actionMethod = NULL, *reflectionMethod = NULL, *methodParams = NULL, *className = NULL, *paramKey = NULL, *methodParam = NULL, *modelName = NULL, *bindModel = NULL, *e = NULL, *_0, *_1$$3, *_2$$3, *_3$$4 = NULL, *_4$$4, *_5$$7 = NULL, *_6$$7 = NULL, *_10$$8 = NULL, *_11$$8 = NULL, *_13$$8, *_14$$6 = NULL, *_49$$6, *_16$$12 = NULL, *_17$$12 = NULL, *_19$$13, *_22$$16 = NULL, *_23$$16 = NULL, *_25$$17, *_26$$19 = NULL, *_27$$19 = NULL, *_29$$20, *_31$$23 = NULL, *_32$$23 = NULL, *_34$$23, *_35$$22 = NULL, *_36$$22 = NULL, *_38$$26, *_39$$28 = NULL, *_40$$28 = NULL, *_42$$28, *_43$$31 = NULL, *_44$$31, *_45$$36 = NULL, *_46$$36 = NULL, *_48$$36, **_54$$39, *_55$$40 = NULL, *_56$$41 = NULL, *_57$$43 = NULL, _59$$43 = zval_used_for_init, *_61$$44 = NULL, *_64$$44 = NULL, _65$$42 = zval_used_for_init, *_66$$42 = NULL, *_69$$45 = NULL, *_71$$45 = NULL, *_72$$46 = NULL, *_74$$47 = NULL, *_76$$48, *_77$$51 = NULL, *_78$$51 = NULL, *_80$$51, *_82$$54 = NULL, *_83$$54, *_84$$57; zend_bool hasService = 0, wasFresh; zephir_fcall_cache_entry *_7 = NULL, *_8 = NULL, *_9 = NULL, *_12 = NULL, *_15 = NULL, *_18 = NULL, *_20 = NULL, *_21 = NULL, *_24 = NULL, *_28 = NULL, *_33 = NULL, *_37 = NULL, *_41 = NULL, *_47 = NULL, *_50 = NULL, *_51 = NULL, *_58 = NULL, *_67 = NULL, *_73 = NULL, *_75 = NULL, *_79 = NULL, *_81 = NULL; int ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0; ZEPHIR_MM_GROW(); wasFresh = 0; _0 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); ZEPHIR_CPY_WRT(dependencyInjector, _0); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_INIT_VAR(_1$$3); ZVAL_STRING(_1$$3, "A dependency injection container is required to access related dispatching services", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_VAR(_2$$3); ZVAL_LONG(_2$$3, 0); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", NULL, 0, _1$$3, _2$$3); zephir_check_temp_parameter(_1$$3); zephir_check_call_status(); RETURN_MM_BOOL(0); } _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_4$$4); ZVAL_STRING(_4$$4, "dispatch:beforeDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_3$$4, eventsManager, "fire", NULL, 0, _4$$4, this_ptr); zephir_check_temp_parameter(_4$$4); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_3$$4)) { RETURN_MM_BOOL(0); } } ZEPHIR_INIT_VAR(value); ZVAL_NULL(value); ZEPHIR_INIT_VAR(handler); ZVAL_NULL(handler); numberDispatches = 0; ZEPHIR_OBS_VAR(actionSuffix); zephir_read_property_this(&actionSuffix, this_ptr, SL("_actionSuffix"), PH_NOISY_CC); if (0) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } while (1) { _0 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (!(!(zephir_is_true(_0)))) { break; } numberDispatches++; if (numberDispatches == 256) { ZEPHIR_INIT_NVAR(_5$$7); ZVAL_STRING(_5$$7, "Dispatcher has detected a cyclic routing causing stability problems", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_6$$7); ZVAL_LONG(_6$$7, 1); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_throwdispatchexception", &_7, 0, _5$$7, _6$$7); zephir_check_temp_parameter(_5$$7); zephir_check_call_status(); break; } if (1) { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("_finished"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resolveemptyproperties", &_8, 0); zephir_check_call_status(); ZEPHIR_OBS_NVAR(namespaceName); zephir_read_property_this(&namespaceName, this_ptr, SL("_namespaceName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(handlerName); zephir_read_property_this(&handlerName, this_ptr, SL("_handlerName"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(actionName); zephir_read_property_this(&actionName, this_ptr, SL("_actionName"), PH_NOISY_CC); ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_9, 0); zephir_check_call_status(); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_11$$8); ZVAL_STRING(_11$$8, "dispatch:beforeDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_10$$8, eventsManager, "fire", &_12, 0, _11$$8, this_ptr); zephir_check_temp_parameter(_11$$8); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_10$$8)) { continue; } _13$$8 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$8)) { continue; } } ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "has", &_15, 0, handlerClass); zephir_check_call_status(); hasService = zephir_get_boolval(_14$$6); if (!(hasService)) { hasService = zephir_class_exists(handlerClass, 1 TSRMLS_CC); } if (!(hasService)) { ZEPHIR_INIT_LNVAR(_16$$12); ZEPHIR_CONCAT_VS(_16$$12, handlerClass, " handler class cannot be loaded"); ZEPHIR_INIT_NVAR(_17$$12); ZVAL_LONG(_17$$12, 2); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_18, 0, _16$$12, _17$$12); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _19$$13 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_19$$13)) { continue; } } break; } ZEPHIR_CALL_METHOD(&handler, dependencyInjector, "getshared", &_20, 0, handlerClass); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_14$$6, dependencyInjector, "wasfreshinstance", &_21, 0); zephir_check_call_status(); if (ZEPHIR_IS_TRUE_IDENTICAL(_14$$6)) { wasFresh = 1; } if (Z_TYPE_P(handler) != IS_OBJECT) { ZEPHIR_INIT_NVAR(_22$$16); ZVAL_STRING(_22$$16, "Invalid handler returned from the services container", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_23$$16); ZVAL_LONG(_23$$16, 3); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_24, 0, _22$$16, _23$$16); zephir_check_temp_parameter(_22$$16); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _25$$17 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_25$$17)) { continue; } } break; } zephir_update_property_this(this_ptr, SL("_activeHandler"), handler TSRMLS_CC); ZEPHIR_OBS_NVAR(params); zephir_read_property_this(¶ms, this_ptr, SL("_params"), PH_NOISY_CC); if (Z_TYPE_P(params) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_26$$19); ZVAL_STRING(_26$$19, "Action parameters must be an Array", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_INIT_NVAR(_27$$19); ZVAL_LONG(_27$$19, 4); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_28, 0, _26$$19, _27$$19); zephir_check_temp_parameter(_26$$19); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _29$$20 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_29$$20)) { continue; } } break; } ZEPHIR_INIT_NVAR(actionMethod); ZEPHIR_CONCAT_VV(actionMethod, actionName, actionSuffix); ZEPHIR_INIT_NVAR(_30$$6); zephir_create_array(_30$$6, 2, 0 TSRMLS_CC); zephir_array_fast_append(_30$$6, handler); zephir_array_fast_append(_30$$6, actionMethod); if (!(zephir_is_callable(_30$$6 TSRMLS_CC))) { if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_32$$23); ZVAL_STRING(_32$$23, "dispatch:beforeNotFoundAction", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_31$$23, eventsManager, "fire", &_33, 0, _32$$23, this_ptr); zephir_check_temp_parameter(_32$$23); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_31$$23)) { continue; } _34$$23 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_34$$23)) { continue; } } ZEPHIR_INIT_LNVAR(_35$$22); ZEPHIR_CONCAT_SVSVS(_35$$22, "Action '", actionName, "' was not found on handler '", handlerName, "'"); ZEPHIR_INIT_NVAR(_36$$22); ZVAL_LONG(_36$$22, 5); ZEPHIR_CALL_METHOD(&status, this_ptr, "_throwdispatchexception", &_37, 0, _35$$22, _36$$22); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(status)) { _38$$26 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_38$$26)) { continue; } } break; } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_40$$28); ZVAL_STRING(_40$$28, "dispatch:beforeExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_39$$28, eventsManager, "fire", &_41, 0, _40$$28, this_ptr); zephir_check_temp_parameter(_40$$28); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_39$$28)) { continue; } _42$$28 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_42$$28)) { continue; } } if ((zephir_method_exists_ex(handler, SS("beforeexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_43$$31, handler, "beforeexecuteroute", NULL, 0, this_ptr); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_43$$31)) { continue; } _44$$31 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_44$$31)) { continue; } } if (wasFresh == 1) { if ((zephir_method_exists_ex(handler, SS("initialize") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, handler, "initialize", NULL, 0); zephir_check_call_status(); } if (zephir_is_true(eventsManager)) { ZEPHIR_INIT_NVAR(_46$$36); ZVAL_STRING(_46$$36, "dispatch:afterInitialize", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_45$$36, eventsManager, "fire", &_47, 0, _46$$36, this_ptr); zephir_check_temp_parameter(_46$$36); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_45$$36)) { continue; } _48$$36 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_48$$36)) { continue; } } } _49$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_modelBinding"), PH_NOISY_CC); if (ZEPHIR_IS_TRUE_IDENTICAL(_49$$6)) { ZEPHIR_INIT_NVAR(reflectionMethod); object_init_ex(reflectionMethod, zephir_get_internal_ce(SS("reflectionmethod") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflectionMethod, "__construct", &_50, 69, handlerClass, actionMethod); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&methodParams, reflectionMethod, "getparameters", &_51, 70); zephir_check_call_status(); zephir_is_iterable(methodParams, &_53$$39, &_52$$39, 0, 0, "phalcon/dispatcher.zep", 582); for ( ; zephir_hash_get_current_data_ex(_53$$39, (void**) &_54$$39, &_52$$39) == SUCCESS ; zephir_hash_move_forward_ex(_53$$39, &_52$$39) ) { ZEPHIR_GET_HMKEY(paramKey, _53$$39, _52$$39); ZEPHIR_GET_HVALUE(methodParam, _54$$39); ZEPHIR_CALL_METHOD(&_55$$40, methodParam, "getclass", NULL, 0); zephir_check_call_status(); if (zephir_is_true(_55$$40)) { ZEPHIR_CALL_METHOD(&_56$$41, methodParam, "getclass", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&className, _56$$41, "getname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(className) == IS_STRING) { if (ZEPHIR_IS_STRING(className, "Phalcon\\Mvc\\Model")) { ZEPHIR_CALL_FUNCTION(&_57$$43, "class_implements", &_58, 71, handlerClass); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_59$$43); ZVAL_STRING(&_59$$43, "Phalcon\\Mvc\\Controller\\BindModelInterface", 0); if (zephir_fast_in_array(&_59$$43, _57$$43 TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_60$$44); zephir_create_array(_60$$44, 2, 0 TSRMLS_CC); zephir_array_fast_append(_60$$44, handlerClass); ZEPHIR_INIT_NVAR(_61$$44); ZVAL_STRING(_61$$44, "getModelName", 1); zephir_array_fast_append(_60$$44, _61$$44); ZEPHIR_INIT_NVAR(modelName); ZEPHIR_CALL_USER_FUNC(modelName, _60$$44); zephir_check_call_status(); ZEPHIR_INIT_NVAR(_62$$44); zephir_create_array(_62$$44, 2, 0 TSRMLS_CC); zephir_array_fast_append(_62$$44, modelName); ZEPHIR_INIT_NVAR(_61$$44); ZVAL_STRING(_61$$44, "findFirst", 1); zephir_array_fast_append(_62$$44, _61$$44); ZEPHIR_INIT_NVAR(_63$$44); zephir_create_array(_63$$44, 1, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_64$$44); zephir_array_fetch(&_64$$44, params, paramKey, PH_NOISY, "phalcon/dispatcher.zep", 567 TSRMLS_CC); zephir_array_fast_append(_63$$44, _64$$44); ZEPHIR_INIT_NVAR(bindModel); ZEPHIR_CALL_USER_FUNC_ARRAY(bindModel, _62$$44, _63$$44); zephir_check_call_status(); zephir_array_update_zval(¶ms, paramKey, &bindModel, PH_COPY | PH_SEPARATE); break; } } ZEPHIR_SINIT_NVAR(_65$$42); ZVAL_STRING(&_65$$42, "Phalcon\\Mvc\\Model", 0); ZEPHIR_CALL_FUNCTION(&_66$$42, "is_subclass_of", &_67, 72, className, &_65$$42); zephir_check_call_status(); if (zephir_is_true(_66$$42)) { ZEPHIR_INIT_NVAR(_68$$45); zephir_create_array(_68$$45, 2, 0 TSRMLS_CC); zephir_array_fast_append(_68$$45, className); ZEPHIR_INIT_NVAR(_69$$45); ZVAL_STRING(_69$$45, "findFirst", 1); zephir_array_fast_append(_68$$45, _69$$45); ZEPHIR_INIT_NVAR(_70$$45); zephir_create_array(_70$$45, 1, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_71$$45); zephir_array_fetch(&_71$$45, params, paramKey, PH_NOISY, "phalcon/dispatcher.zep", 575 TSRMLS_CC); zephir_array_fast_append(_70$$45, _71$$45); ZEPHIR_INIT_NVAR(bindModel); ZEPHIR_CALL_USER_FUNC_ARRAY(bindModel, _68$$45, _70$$45); zephir_check_call_status(); zephir_array_update_zval(¶ms, paramKey, &bindModel, PH_COPY | PH_SEPARATE); break; } } } } } zephir_update_property_this(this_ptr, SL("_lastHandler"), handler TSRMLS_CC); /* try_start_1: */ ZEPHIR_CALL_METHOD(&_72$$46, this_ptr, "callactionmethod", &_73, 0, handler, actionMethod, params); zephir_check_call_status_or_jump(try_end_1); zephir_update_property_this(this_ptr, SL("_returnedValue"), _72$$46 TSRMLS_CC); try_end_1: if (EG(exception)) { ZEPHIR_CPY_WRT(e, EG(exception)); if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) { zend_clear_exception(TSRMLS_C); ZEPHIR_CALL_METHOD(&_74$$47, this_ptr, "_handleexception", &_75, 0, e); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_74$$47)) { _76$$48 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_76$$48)) { continue; } } else { zephir_throw_exception_debug(e, "phalcon/dispatcher.zep", 595 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_NVAR(_78$$51); ZVAL_STRING(_78$$51, "dispatch:afterExecuteRoute", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_77$$51, eventsManager, "fire", &_79, 0, _78$$51, this_ptr, value); zephir_check_temp_parameter(_78$$51); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_77$$51)) { continue; } _80$$51 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_80$$51)) { continue; } ZEPHIR_INIT_NVAR(_78$$51); ZVAL_STRING(_78$$51, "dispatch:afterDispatch", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_81, 0, _78$$51, this_ptr); zephir_check_temp_parameter(_78$$51); zephir_check_call_status(); } if ((zephir_method_exists_ex(handler, SS("afterexecuteroute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&_82$$54, handler, "afterexecuteroute", NULL, 0, this_ptr, value); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_82$$54)) { continue; } _83$$54 = zephir_fetch_nproperty_this(this_ptr, SL("_finished"), PH_NOISY_CC); if (ZEPHIR_IS_FALSE_IDENTICAL(_83$$54)) { continue; } } } if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_84$$57); ZVAL_STRING(_84$$57, "dispatch:afterDispatchLoop", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _84$$57, this_ptr); zephir_check_temp_parameter(_84$$57); zephir_check_call_status(); } RETURN_CCTOR(handler); }
/** * Check whether a role is allowed to access an action from a resource * * <code> * //Does andres have access to the customers resource to create? * $acl->isAllowed("andres", "Products", "create"); * * //Do guests have access to any resource to edit? * $acl->isAllowed("guests", "*", "edit"); * </code> */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, isAllowed) { zend_bool _15$$31, _20$$33, _22$$33, _24$$33, _26$$33, _40$$40, _42$$39, _44$$41; HashTable *_5$$13, *_8$$19, *_11$$25, *_18$$30; HashPosition _4$$13, _7$$19, _10$$25, _17$$30; zephir_fcall_cache_entry *_34 = NULL, *_38 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL; zval *access = NULL; zval *roleName = NULL, *resourceName = NULL, *access_param = NULL, *parameters_param = NULL, *eventsManager = NULL, *accessList = NULL, *accessKey = NULL, *haveAccess = NULL, *roleInherits = NULL, *inheritedRole = NULL, *rolesNames = NULL, *inheritedRoles = NULL, *funcAccess = NULL, *resourceObject = NULL, *roleObject = NULL, *funcList = NULL, *reflectionFunction = NULL, *reflectionParameters = NULL, *parameterNumber = NULL, *parametersForFunction = NULL, *numberOfRequiredParameters = NULL, *userParametersSizeShouldBe = NULL, *reflectionClass = NULL, *parameterToCheck = NULL, *reflectionParameter = NULL, *_0, *_1$$7 = NULL, *_2$$7, *_3$$9, **_6$$13, **_9$$19, **_12$$25, *_13$$28, *_14$$29, *_16$$31, **_19$$30, *_46$$30, *_47$$30, *_21$$33 = NULL, *_23$$33 = NULL, *_25$$33 = NULL, *_27$$33 = NULL, *_28$$33, *_29$$36 = NULL, *_30$$36 = NULL, *_31$$36, *_32$$36 = NULL, *_33$$36 = NULL, *_35$$37, *_36$$38, _37$$38, *_39$$40, *_41$$40, *_43$$39, *_45$$41; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 1, &roleName, &resourceName, &access_param, ¶meters_param); ZEPHIR_SEPARATE_PARAM(roleName); ZEPHIR_SEPARATE_PARAM(resourceName); zephir_get_strval(access, access_param); if (!parameters_param) { ZEPHIR_INIT_VAR(parameters); array_init(parameters); } else { zephir_get_arrval(parameters, parameters_param); } ZEPHIR_INIT_VAR(haveAccess); ZVAL_NULL(haveAccess); ZEPHIR_INIT_VAR(funcAccess); ZVAL_NULL(funcAccess); ZEPHIR_INIT_VAR(resourceObject); ZVAL_NULL(resourceObject); ZEPHIR_INIT_VAR(roleObject); ZVAL_NULL(roleObject); if (Z_TYPE_P(roleName) == IS_OBJECT) { if (!(zephir_instance_of_ev(roleName, phalcon_acl_roleaware_ce TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_acl_exception_ce, "Object passed as roleName must implement RoleAware", "phalcon/acl/adapter/memory.zep", 545); return; } ZEPHIR_CPY_WRT(roleObject, roleName); ZEPHIR_CALL_METHOD(&roleName, roleObject, "getrolename", NULL, 0); zephir_check_call_status(); } if (Z_TYPE_P(resourceName) == IS_OBJECT) { if (!(zephir_instance_of_ev(resourceName, phalcon_acl_resourceaware_ce TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_acl_exception_ce, "Object passed as resourceName must implement ResourceAware", "phalcon/acl/adapter/memory.zep", 553); return; } ZEPHIR_CPY_WRT(resourceObject, resourceName); ZEPHIR_CALL_METHOD(&resourceName, resourceObject, "getresourcename", NULL, 0); zephir_check_call_status(); } zephir_update_property_this(this_ptr, SL("_activeRole"), roleName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_activeResource"), resourceName TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_activeAccess"), access TSRMLS_CC); ZEPHIR_OBS_VAR(accessList); zephir_read_property_this(&accessList, this_ptr, SL("_access"), PH_NOISY_CC); _0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC); ZEPHIR_CPY_WRT(eventsManager, _0); ZEPHIR_OBS_VAR(funcList); zephir_read_property_this(&funcList, this_ptr, SL("_func"), PH_NOISY_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_2$$7); ZVAL_STRING(_2$$7, "acl:beforeCheckAccess", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&_1$$7, eventsManager, "fire", NULL, 0, _2$$7, this_ptr); zephir_check_temp_parameter(_2$$7); zephir_check_call_status(); if (ZEPHIR_IS_FALSE_IDENTICAL(_1$$7)) { RETURN_MM_BOOL(0); } } ZEPHIR_OBS_VAR(rolesNames); zephir_read_property_this(&rolesNames, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (!(zephir_array_isset(rolesNames, roleName))) { _3$$9 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAccess"), PH_NOISY_CC); RETURN_MM_BOOL((ZEPHIR_IS_LONG(_3$$9, 1))); } ZEPHIR_INIT_VAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, roleName, "!", resourceName, "!", access); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 586 TSRMLS_CC); } ZEPHIR_OBS_NVAR(funcAccess); zephir_array_isset_fetch(&funcAccess, funcList, accessKey, 0 TSRMLS_CC); if (Z_TYPE_P(haveAccess) == IS_NULL) { ZEPHIR_OBS_VAR(roleInherits); zephir_read_property_this(&roleInherits, this_ptr, SL("_roleInherits"), PH_NOISY_CC); ZEPHIR_OBS_VAR(inheritedRoles); if (zephir_array_isset_fetch(&inheritedRoles, roleInherits, roleName, 0 TSRMLS_CC)) { if (Z_TYPE_P(inheritedRoles) == IS_ARRAY) { zephir_is_iterable(inheritedRoles, &_5$$13, &_4$$13, 0, 0, "phalcon/acl/adapter/memory.zep", 610); for ( ; zephir_hash_get_current_data_ex(_5$$13, (void**) &_6$$13, &_4$$13) == SUCCESS ; zephir_hash_move_forward_ex(_5$$13, &_4$$13) ) { ZEPHIR_GET_HVALUE(inheritedRole, _6$$13); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVSV(accessKey, inheritedRole, "!", resourceName, "!", access); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 606 TSRMLS_CC); } ZEPHIR_OBS_NVAR(funcAccess); zephir_array_isset_fetch(&funcAccess, funcList, accessKey, 0 TSRMLS_CC); } } } } if (Z_TYPE_P(haveAccess) == IS_NULL) { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVS(accessKey, roleName, "!", resourceName, "!*"); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 625 TSRMLS_CC); ZEPHIR_OBS_NVAR(funcAccess); zephir_array_isset_fetch(&funcAccess, funcList, accessKey, 0 TSRMLS_CC); } else { if (Z_TYPE_P(inheritedRoles) == IS_ARRAY) { zephir_is_iterable(inheritedRoles, &_8$$19, &_7$$19, 0, 0, "phalcon/acl/adapter/memory.zep", 641); for ( ; zephir_hash_get_current_data_ex(_8$$19, (void**) &_9$$19, &_7$$19) == SUCCESS ; zephir_hash_move_forward_ex(_8$$19, &_7$$19) ) { ZEPHIR_GET_HVALUE(inheritedRole, _9$$19); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VSVS(accessKey, inheritedRole, "!", resourceName, "!*"); ZEPHIR_OBS_NVAR(funcAccess); zephir_array_isset_fetch(&funcAccess, funcList, accessKey, 0 TSRMLS_CC); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 637 TSRMLS_CC); break; } } } } } if (Z_TYPE_P(haveAccess) == IS_NULL) { ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VS(accessKey, roleName, "!*!*"); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 656 TSRMLS_CC); ZEPHIR_OBS_NVAR(funcAccess); zephir_array_isset_fetch(&funcAccess, funcList, accessKey, 0 TSRMLS_CC); } else { if (Z_TYPE_P(inheritedRoles) == IS_ARRAY) { zephir_is_iterable(inheritedRoles, &_11$$25, &_10$$25, 0, 0, "phalcon/acl/adapter/memory.zep", 672); for ( ; zephir_hash_get_current_data_ex(_11$$25, (void**) &_12$$25, &_10$$25) == SUCCESS ; zephir_hash_move_forward_ex(_11$$25, &_10$$25) ) { ZEPHIR_GET_HVALUE(inheritedRole, _12$$25); ZEPHIR_INIT_NVAR(accessKey); ZEPHIR_CONCAT_VS(accessKey, inheritedRole, "!*!*"); ZEPHIR_OBS_NVAR(funcAccess); zephir_array_isset_fetch(&funcAccess, funcList, accessKey, 0 TSRMLS_CC); if (zephir_array_isset(accessList, accessKey)) { ZEPHIR_OBS_NVAR(haveAccess); zephir_array_fetch(&haveAccess, accessList, accessKey, PH_NOISY, "phalcon/acl/adapter/memory.zep", 668 TSRMLS_CC); break; } } } } } zephir_update_property_this(this_ptr, SL("_accessGranted"), haveAccess TSRMLS_CC); if (Z_TYPE_P(eventsManager) == IS_OBJECT) { ZEPHIR_INIT_VAR(_13$$28); ZVAL_STRING(_13$$28, "acl:afterCheckAccess", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _13$$28, this_ptr); zephir_check_temp_parameter(_13$$28); zephir_check_call_status(); } if (Z_TYPE_P(haveAccess) == IS_NULL) { _14$$29 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAccess"), PH_NOISY_CC); RETURN_MM_BOOL(ZEPHIR_IS_LONG(_14$$29, 1)); } if (Z_TYPE_P(funcAccess) != IS_NULL) { ZEPHIR_INIT_VAR(reflectionFunction); object_init_ex(reflectionFunction, zephir_get_internal_ce(SS("reflectionfunction") TSRMLS_CC)); ZEPHIR_CALL_METHOD(NULL, reflectionFunction, "__construct", NULL, 85, funcAccess); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&reflectionParameters, reflectionFunction, "getparameters", NULL, 86); zephir_check_call_status(); ZEPHIR_INIT_VAR(parameterNumber); ZVAL_LONG(parameterNumber, zephir_fast_count_int(reflectionParameters TSRMLS_CC)); if (ZEPHIR_IS_LONG_IDENTICAL(parameterNumber, 0)) { _15$$31 = ZEPHIR_IS_LONG(haveAccess, 1); if (_15$$31) { ZEPHIR_INIT_VAR(_16$$31); ZEPHIR_CALL_USER_FUNC(_16$$31, funcAccess); zephir_check_call_status(); _15$$31 = zephir_is_true(_16$$31); } RETURN_MM_BOOL(_15$$31); } ZEPHIR_INIT_VAR(parametersForFunction); array_init(parametersForFunction); ZEPHIR_CALL_METHOD(&numberOfRequiredParameters, reflectionFunction, "getnumberofrequiredparameters", NULL, 87); zephir_check_call_status(); ZEPHIR_CPY_WRT(userParametersSizeShouldBe, parameterNumber); zephir_is_iterable(reflectionParameters, &_18$$30, &_17$$30, 0, 0, "phalcon/acl/adapter/memory.zep", 737); for ( ; zephir_hash_get_current_data_ex(_18$$30, (void**) &_19$$30, &_17$$30) == SUCCESS ; zephir_hash_move_forward_ex(_18$$30, &_17$$30) ) { ZEPHIR_GET_HVALUE(reflectionParameter, _19$$30); ZEPHIR_CALL_METHOD(&reflectionClass, reflectionParameter, "getclass", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(¶meterToCheck, reflectionParameter, "getname", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(reflectionClass) != IS_NULL) { _20$$33 = Z_TYPE_P(roleObject) != IS_NULL; if (_20$$33) { ZEPHIR_CALL_METHOD(&_21$$33, reflectionClass, "isinstance", NULL, 0, roleObject); zephir_check_call_status(); _20$$33 = zephir_is_true(_21$$33); } if (_20$$33) { zephir_array_append(¶metersForFunction, roleObject, PH_SEPARATE, "phalcon/acl/adapter/memory.zep", 709); ZEPHIR_SEPARATE(userParametersSizeShouldBe); zephir_decrement(userParametersSizeShouldBe); continue; } _22$$33 = Z_TYPE_P(resourceObject) != IS_NULL; if (_22$$33) { ZEPHIR_CALL_METHOD(&_23$$33, reflectionClass, "isinstance", NULL, 0, resourceObject); zephir_check_call_status(); _22$$33 = zephir_is_true(_23$$33); } if (_22$$33) { zephir_array_append(¶metersForFunction, resourceObject, PH_SEPARATE, "phalcon/acl/adapter/memory.zep", 717); ZEPHIR_SEPARATE(userParametersSizeShouldBe); zephir_decrement(userParametersSizeShouldBe); continue; } _24$$33 = zephir_array_isset(parameters, parameterToCheck); if (_24$$33) { ZEPHIR_OBS_NVAR(_25$$33); zephir_array_fetch(&_25$$33, parameters, parameterToCheck, PH_NOISY, "phalcon/acl/adapter/memory.zep", 724 TSRMLS_CC); _24$$33 = Z_TYPE_P(_25$$33) == IS_OBJECT; } _26$$33 = _24$$33; if (_26$$33) { zephir_array_fetch(&_28$$33, parameters, parameterToCheck, PH_NOISY | PH_READONLY, "phalcon/acl/adapter/memory.zep", 724 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_27$$33, reflectionClass, "isinstance", NULL, 0, _28$$33); zephir_check_call_status(); _26$$33 = !zephir_is_true(_27$$33); } if (_26$$33) { ZEPHIR_INIT_NVAR(_29$$36); object_init_ex(_29$$36, phalcon_acl_exception_ce); ZEPHIR_INIT_NVAR(_30$$36); zephir_array_fetch(&_31$$36, parameters, parameterToCheck, PH_NOISY | PH_READONLY, "phalcon/acl/adapter/memory.zep", 726 TSRMLS_CC); zephir_get_class(_30$$36, _31$$36, 0 TSRMLS_CC); ZEPHIR_CALL_METHOD(&_32$$36, reflectionClass, "getname", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_LNVAR(_33$$36); ZEPHIR_CONCAT_SVSVSVSVSVS(_33$$36, "Your passed parameter doesn't have the same class as the parameter in defined function when check ", roleName, " can ", access, " ", resourceName, ". Class passed: ", _30$$36, " , Class in defined function: ", _32$$36, "."); ZEPHIR_CALL_METHOD(NULL, _29$$36, "__construct", &_34, 9, _33$$36); zephir_check_call_status(); zephir_throw_exception_debug(_29$$36, "phalcon/acl/adapter/memory.zep", 727 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } } if (zephir_array_isset(parameters, parameterToCheck)) { zephir_array_fetch(&_35$$37, parameters, parameterToCheck, PH_NOISY | PH_READONLY, "phalcon/acl/adapter/memory.zep", 733 TSRMLS_CC); zephir_array_append(¶metersForFunction, _35$$37, PH_SEPARATE, "phalcon/acl/adapter/memory.zep", 733); } } if (ZEPHIR_LT_LONG(userParametersSizeShouldBe, zephir_fast_count_int(parameters TSRMLS_CC))) { ZEPHIR_INIT_VAR(_36$$38); ZEPHIR_CONCAT_SVSVSVS(_36$$38, "Number of parameters in array is higher than the number of parameters in defined function when check ", roleName, " can ", access, " ", resourceName, ". Remember that more parameters than defined in function will be ignored."); ZEPHIR_SINIT_VAR(_37$$38); ZVAL_LONG(&_37$$38, 512); ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", &_38, 2, _36$$38, &_37$$38); zephir_check_call_status(); } if (zephir_fast_count_int(parametersForFunction TSRMLS_CC) == 0) { if (ZEPHIR_GT_LONG(numberOfRequiredParameters, 0)) { ZEPHIR_INIT_VAR(_39$$40); ZEPHIR_CONCAT_SVSVSVS(_39$$40, "You didn't provide any parameters when check ", roleName, " can ", access, " ", resourceName, ". We will use default action when no arguments."); ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", &_38, 2, _39$$40); zephir_check_call_status(); _40$$40 = ZEPHIR_IS_LONG(haveAccess, 1); if (_40$$40) { _41$$40 = zephir_fetch_nproperty_this(this_ptr, SL("_noArgumentsDefaultAction"), PH_NOISY_CC); _40$$40 = ZEPHIR_IS_LONG(_41$$40, 1); } RETURN_MM_BOOL(_40$$40); } _42$$39 = ZEPHIR_IS_LONG(haveAccess, 1); if (_42$$39) { ZEPHIR_INIT_VAR(_43$$39); ZEPHIR_CALL_USER_FUNC(_43$$39, funcAccess); zephir_check_call_status(); _42$$39 = zephir_is_true(_43$$39); } RETURN_MM_BOOL(_42$$39); } if (ZEPHIR_LE_LONG(numberOfRequiredParameters, zephir_fast_count_int(parametersForFunction TSRMLS_CC))) { _44$$41 = ZEPHIR_IS_LONG(haveAccess, 1); if (_44$$41) { ZEPHIR_INIT_VAR(_45$$41); ZEPHIR_CALL_USER_FUNC_ARRAY(_45$$41, funcAccess, parametersForFunction); zephir_check_call_status(); _44$$41 = zephir_is_true(_45$$41); } RETURN_MM_BOOL(_44$$41); } ZEPHIR_INIT_VAR(_46$$30); object_init_ex(_46$$30, phalcon_acl_exception_ce); ZEPHIR_INIT_VAR(_47$$30); ZEPHIR_CONCAT_SVSVSV(_47$$30, "You didn't provide all necessary parameters for defined function when check ", roleName, " can ", access, " ", resourceName); ZEPHIR_CALL_METHOD(NULL, _46$$30, "__construct", &_34, 9, _47$$30); zephir_check_call_status(); zephir_throw_exception_debug(_46$$30, "phalcon/acl/adapter/memory.zep", 766 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } RETURN_MM_BOOL(ZEPHIR_IS_LONG(haveAccess, 1)); }
/** * Resolves the service * * @param array parameters * @return mixed */ PHP_METHOD(Phalcon_Di_Service, resolve) { zend_class_entry *_1$$15; zend_bool found = 0; zend_long ZEPHIR_LAST_CALL_STATUS; zval *parameters = NULL, parameters_sub, *dependencyInjector = NULL, dependencyInjector_sub, __$true, __$false, __$null, shared, definition, sharedInstance, instance, builder, _0$$15, _2$$22; zval *this_ptr = getThis(); ZVAL_UNDEF(¶meters_sub); ZVAL_UNDEF(&dependencyInjector_sub); ZVAL_BOOL(&__$true, 1); ZVAL_BOOL(&__$false, 0); ZVAL_NULL(&__$null); ZVAL_UNDEF(&shared); ZVAL_UNDEF(&definition); ZVAL_UNDEF(&sharedInstance); ZVAL_UNDEF(&instance); ZVAL_UNDEF(&builder); ZVAL_UNDEF(&_0$$15); ZVAL_UNDEF(&_2$$22); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 2, ¶meters, &dependencyInjector); if (!parameters) { parameters = ¶meters_sub; parameters = &__$null; } if (!dependencyInjector) { dependencyInjector = &dependencyInjector_sub; dependencyInjector = &__$null; } ZEPHIR_OBS_VAR(&shared); zephir_read_property(&shared, this_ptr, SL("_shared"), PH_NOISY_CC); if (zephir_is_true(&shared)) { ZEPHIR_OBS_VAR(&sharedInstance); zephir_read_property(&sharedInstance, this_ptr, SL("_sharedInstance"), PH_NOISY_CC); if (Z_TYPE_P(&sharedInstance) != IS_NULL) { RETURN_CCTOR(&sharedInstance); } } found = 1; ZEPHIR_INIT_VAR(&instance); ZVAL_NULL(&instance); ZEPHIR_OBS_VAR(&definition); zephir_read_property(&definition, this_ptr, SL("_definition"), PH_NOISY_CC); if (Z_TYPE_P(&definition) == IS_STRING) { if (zephir_class_exists(&definition, 1 TSRMLS_CC)) { if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &definition, parameters TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &definition TSRMLS_CC); zephir_check_call_status(); } } else { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &definition TSRMLS_CC); zephir_check_call_status(); } } else { found = 0; } } else { if (Z_TYPE_P(&definition) == IS_OBJECT) { if (zephir_instance_of_ev(&definition, zend_ce_closure TSRMLS_CC)) { if (Z_TYPE_P(dependencyInjector) == IS_OBJECT) { _1$$15 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); ZEPHIR_CALL_CE_STATIC(&_0$$15, _1$$15, "bind", NULL, 0, &definition, dependencyInjector); zephir_check_call_status(); ZEPHIR_CPY_WRT(&definition, &_0$$15); } if (Z_TYPE_P(parameters) == IS_ARRAY) { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_CALL_USER_FUNC_ARRAY(&instance, &definition, parameters); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(&instance); ZEPHIR_CALL_USER_FUNC(&instance, &definition); zephir_check_call_status(); } } else { ZEPHIR_CPY_WRT(&instance, &definition); } } else { if (Z_TYPE_P(&definition) == IS_ARRAY) { ZEPHIR_INIT_VAR(&builder); object_init_ex(&builder, phalcon_di_service_builder_ce); if (zephir_has_constructor(&builder TSRMLS_CC)) { ZEPHIR_CALL_METHOD(NULL, &builder, "__construct", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&instance, &builder, "build", NULL, 171, dependencyInjector, &definition, parameters); zephir_check_call_status(); } else { found = 0; } } } if (found == 0) { ZEPHIR_INIT_VAR(&_2$$22); object_init_ex(&_2$$22, phalcon_di_exception_serviceresolutionexception_ce); ZEPHIR_CALL_METHOD(NULL, &_2$$22, "__construct", NULL, 4); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$22, "phalcon/di/service.zep", 186 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_is_true(&shared)) { zephir_update_property_zval(this_ptr, SL("_sharedInstance"), &instance); } if (1) { zephir_update_property_zval(this_ptr, SL("_resolved"), &__$true); } else { zephir_update_property_zval(this_ptr, SL("_resolved"), &__$false); } RETURN_CCTOR(&instance); }
/** * Builds a service using a complex service definition * * @param \Phalcon\DiInterface dependencyInjector * @param array definition * @param array parameters * @return mixed */ PHP_METHOD(Phalcon_Di_Service_Builder, build) { HashTable *_3, *_9; HashPosition _2, _8; zephir_fcall_cache_entry *_1 = NULL, *_7 = NULL, *_12 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *definition = NULL; zval *dependencyInjector, *definition_param = NULL, *parameters = NULL, *className, *arguments = NULL, *paramCalls = NULL, *methodPosition = NULL, *method = NULL, *methodName = NULL, *methodCall = NULL, *instance = NULL, *propertyPosition = NULL, *property = NULL, *propertyName = NULL, *propertyValue = NULL, *_0 = NULL, **_4, *_5 = NULL, *_6 = NULL, **_10, *_11 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &dependencyInjector, &definition_param, ¶meters); definition = definition_param; if (!parameters) { parameters = ZEPHIR_GLOBAL(global_null); } ZEPHIR_OBS_VAR(className); if (!(zephir_array_isset_string_fetch(&className, definition, SS("className"), 0 TSRMLS_CC))) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Invalid service definition. Missing 'className' parameter", "phalcon/di/service/builder.zep", 140); return; } if (Z_TYPE_P(parameters) == IS_ARRAY) { if (zephir_fast_count_int(parameters TSRMLS_CC)) { ZEPHIR_INIT_VAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, className, parameters TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, className TSRMLS_CC); zephir_check_call_status(); } } else { ZEPHIR_OBS_VAR(arguments); if (zephir_array_isset_string_fetch(&arguments, definition, SS("arguments"), 0 TSRMLS_CC)) { ZEPHIR_CALL_METHOD(&_0, this_ptr, "_buildparameters", &_1, 178, dependencyInjector, arguments); zephir_check_call_status(); ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(instance, className, _0 TSRMLS_CC); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(instance); ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(instance, className TSRMLS_CC); zephir_check_call_status(); } } ZEPHIR_OBS_VAR(paramCalls); if (zephir_array_isset_string_fetch(¶mCalls, definition, SS("calls"), 0 TSRMLS_CC)) { if (Z_TYPE_P(instance) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has setter injection parameters but the constructor didn't return an instance", "phalcon/di/service/builder.zep", 177); return; } if (Z_TYPE_P(paramCalls) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/di/service/builder.zep", 181); return; } zephir_is_iterable(paramCalls, &_3, &_2, 0, 0, "phalcon/di/service/builder.zep", 233); for ( ; zephir_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS ; zephir_hash_move_forward_ex(_3, &_2) ) { ZEPHIR_GET_HMKEY(methodPosition, _3, _2); ZEPHIR_GET_HVALUE(method, _4); if (Z_TYPE_P(method) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "Method call must be an array on position ", methodPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 193 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(methodName); if (!(zephir_array_isset_string_fetch(&methodName, method, SS("method"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "The method name is required on position ", methodPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 200 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_NVAR(methodCall); zephir_create_array(methodCall, 2, 0 TSRMLS_CC); zephir_array_fast_append(methodCall, instance); zephir_array_fast_append(methodCall, methodName); ZEPHIR_OBS_NVAR(arguments); if (zephir_array_isset_string_fetch(&arguments, method, SS("arguments"), 0 TSRMLS_CC)) { if (Z_TYPE_P(arguments) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "Call arguments must be an array ", methodPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 211 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } if (zephir_fast_count_int(arguments TSRMLS_CC)) { ZEPHIR_INIT_NVAR(_5); ZEPHIR_CALL_METHOD(&_0, this_ptr, "_buildparameters", &_1, 178, dependencyInjector, arguments); zephir_check_call_status(); ZEPHIR_CALL_USER_FUNC_ARRAY(_5, methodCall, _0); zephir_check_call_status(); continue; } } ZEPHIR_INIT_NVAR(_5); ZEPHIR_CALL_USER_FUNC(_5, methodCall); zephir_check_call_status(); } } ZEPHIR_OBS_NVAR(paramCalls); if (zephir_array_isset_string_fetch(¶mCalls, definition, SS("properties"), 0 TSRMLS_CC)) { if (Z_TYPE_P(instance) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has properties injection parameters but the constructor didn't return an instance", "phalcon/di/service/builder.zep", 241); return; } if (Z_TYPE_P(paramCalls) != IS_ARRAY) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/di/service/builder.zep", 245); return; } zephir_is_iterable(paramCalls, &_9, &_8, 0, 0, "phalcon/di/service/builder.zep", 279); for ( ; zephir_hash_get_current_data_ex(_9, (void**) &_10, &_8) == SUCCESS ; zephir_hash_move_forward_ex(_9, &_8) ) { ZEPHIR_GET_HMKEY(propertyPosition, _9, _8); ZEPHIR_GET_HVALUE(property, _10); if (Z_TYPE_P(property) != IS_ARRAY) { ZEPHIR_INIT_NVAR(_11); object_init_ex(_11, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "Property must be an array on position ", propertyPosition); ZEPHIR_CALL_METHOD(NULL, _11, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_11, "phalcon/di/service/builder.zep", 257 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(propertyName); if (!(zephir_array_isset_string_fetch(&propertyName, property, SS("name"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "The property name is required on position ", propertyPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 264 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_OBS_NVAR(propertyValue); if (!(zephir_array_isset_string_fetch(&propertyValue, property, SS("value"), 0 TSRMLS_CC))) { ZEPHIR_INIT_NVAR(_5); object_init_ex(_5, phalcon_di_exception_ce); ZEPHIR_INIT_LNVAR(_6); ZEPHIR_CONCAT_SV(_6, "The property value is required on position ", propertyPosition); ZEPHIR_CALL_METHOD(NULL, _5, "__construct", &_7, 9, _6); zephir_check_call_status(); zephir_throw_exception_debug(_5, "phalcon/di/service/builder.zep", 271 TSRMLS_CC); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&_0, this_ptr, "_buildparameter", &_12, 177, dependencyInjector, propertyPosition, propertyValue); zephir_check_call_status(); zephir_update_property_zval_zval(instance, propertyName, _0 TSRMLS_CC); } } RETURN_CCTOR(instance); }