/** * Adds access to resources * * @param string $resourceName * @param mixed $accessList */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResourceAccess){ zval *resource_name, *access_list, *resources_names; zval *exception_message, *exists, *internal_access_list; zval *access_name = NULL, *access_key = NULL; HashTable *ah0; HashPosition hp0; zval **hd; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &resource_name, &access_list); PHALCON_OBS_VAR(resources_names); phalcon_read_property_this(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!phalcon_array_isset(resources_names, resource_name)) { PHALCON_INIT_VAR(exception_message); PHALCON_CONCAT_SVS(exception_message, "Resource '", resource_name, "' does not exist in ACL"); PHALCON_THROW_EXCEPTION_ZVAL(phalcon_acl_exception_ce, exception_message); return; } PHALCON_INIT_VAR(exists); ZVAL_BOOL(exists, 1); PHALCON_OBS_VAR(internal_access_list); phalcon_read_property_this(&internal_access_list, this_ptr, SL("_accessList"), PH_NOISY_CC); if (Z_TYPE_P(access_list) == IS_ARRAY) { phalcon_is_iterable(access_list, &ah0, &hp0, 0, 0); while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) { PHALCON_GET_HVALUE(access_name); PHALCON_INIT_NVAR(access_key); PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_name); if (!phalcon_array_isset(internal_access_list, access_key)) { phalcon_update_property_array(this_ptr, SL("_accessList"), access_key, exists TSRMLS_CC); } zend_hash_move_forward_ex(ah0, &hp0); } } else { if (Z_TYPE_P(access_list) == IS_STRING) { PHALCON_INIT_NVAR(access_key); PHALCON_CONCAT_VSV(access_key, resource_name, "!", access_list); if (!phalcon_array_isset(internal_access_list, access_key)) { phalcon_update_property_array(this_ptr, SL("_accessList"), access_key, exists TSRMLS_CC); } } } RETURN_MM_TRUE; }
/** * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role * * Example: * <code> * $acl->addRole(new Phalcon\Acl\Role('administrator'), 'consultant'); * $acl->addRole('administrator', 'consultant'); * </code> * * @param Phalcon\Acl\RoleInterface $role * @param array|string $accessInherits * @return boolean */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addRole){ zval *role, *access_inherits = NULL, *role_name = NULL, *object = NULL; zval *roles_names, *exists, *default_access; zval *key, *success; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &role, &access_inherits); if (!access_inherits) { PHALCON_INIT_VAR(access_inherits); } if (Z_TYPE_P(role) == IS_OBJECT) { PHALCON_INIT_VAR(role_name); phalcon_call_method(role_name, role, "getname"); PHALCON_CPY_WRT(object, role); } else { PHALCON_CPY_WRT(role_name, role); PHALCON_INIT_NVAR(object); object_init_ex(object, phalcon_acl_role_ce); phalcon_call_method_p1_noret(object, "__construct", role); } PHALCON_OBS_VAR(roles_names); phalcon_read_property_this(&roles_names, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (phalcon_array_isset(roles_names, role_name)) { RETURN_MM_FALSE; } PHALCON_INIT_VAR(exists); ZVAL_BOOL(exists, 1); phalcon_update_property_array_append(this_ptr, SL("_roles"), object TSRMLS_CC); phalcon_update_property_array(this_ptr, SL("_rolesNames"), role_name, exists TSRMLS_CC); PHALCON_OBS_VAR(default_access); phalcon_read_property_this(&default_access, this_ptr, SL("_defaultAccess"), PH_NOISY_CC); PHALCON_INIT_VAR(key); PHALCON_CONCAT_VS(key, role_name, "!*!*"); phalcon_update_property_array(this_ptr, SL("_access"), key, default_access TSRMLS_CC); if (Z_TYPE_P(access_inherits) != IS_NULL) { PHALCON_INIT_VAR(success); phalcon_call_method_p2(success, this_ptr, "addinherit", role_name, access_inherits); RETURN_CCTOR(success); } RETURN_MM_TRUE; }
/** * Stores cached content into the backend and stops the frontend * * @param string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */ PHP_METHOD(Phalcon_Cache_Backend_Memory, save){ zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL; zval *cached_content = NULL, *prepared_content = NULL, *is_buffering = NULL; zval *last_key, *frontend; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer); if (!key_name || Z_TYPE_P(key_name) == IS_NULL) { last_key = phalcon_fetch_nproperty_this(this_ptr, SL("_lastKey"), PH_NOISY TSRMLS_CC); } else { zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(last_key); PHALCON_CONCAT_VV(last_key, prefix, key_name); } if (!zend_is_true(last_key)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first"); return; } frontend = phalcon_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY TSRMLS_CC); if (!content || Z_TYPE_P(content) == IS_NULL) { PHALCON_CALL_METHOD(&cached_content, frontend, "getcontent"); } else { cached_content = content; } if (phalcon_is_numeric(cached_content)) { phalcon_update_property_array(this_ptr, SL("_data"), last_key, cached_content TSRMLS_CC); } else { PHALCON_CALL_METHOD(&prepared_content, frontend, "beforestore", cached_content); phalcon_update_property_array(this_ptr, SL("_data"), last_key, prepared_content TSRMLS_CC); } PHALCON_CALL_METHOD(&is_buffering, frontend, "isbuffering"); if (!stop_buffer || PHALCON_IS_TRUE(stop_buffer)) { PHALCON_CALL_METHOD(NULL, frontend, "stop"); } if (PHALCON_IS_TRUE(is_buffering)) { zend_print_zval(cached_content, 0); } phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Adds a resource to the ACL list * * Access names can be a particular action, by example * search, update, delete, etc or a list of them * * Example: * <code> * //Add a resource to the the list allowing access to an action * $acl->addResource(new Phalcon\Acl\Resource('customers'), 'search'); * $acl->addResource('customers', 'search'); * * //Add a resource with an access list * $acl->addResource(new Phalcon\Acl\Resource('customers'), array('create', 'search')); * $acl->addResource('customers', array('create', 'search')); * </code> * * @param Phalcon\Acl\Resource $resource * @param array $accessList * @return boolean */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResource){ zval *resource, *access_list = NULL, *resource_name = NULL; zval *object = NULL, *resources_names, *empty_arr, *status; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &resource, &access_list) == FAILURE) { RETURN_MM_NULL(); } if (!access_list) { PHALCON_INIT_VAR(access_list); } if (Z_TYPE_P(resource) == IS_OBJECT) { PHALCON_INIT_VAR(resource_name); PHALCON_CALL_METHOD(resource_name, resource, "getname"); PHALCON_CPY_WRT(object, resource); } else { PHALCON_CPY_WRT(resource_name, resource); PHALCON_INIT_VAR(object); object_init_ex(object, phalcon_acl_resource_ce); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(object, "__construct", resource_name); } PHALCON_OBS_VAR(resources_names); phalcon_read_property(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY_CC); if (!phalcon_array_isset(resources_names, resource_name)) { phalcon_update_property_array_append(this_ptr, SL("_resources"), object TSRMLS_CC); PHALCON_INIT_VAR(empty_arr); array_init(empty_arr); phalcon_update_property_array(this_ptr, SL("_accessList"), resource_name, empty_arr TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_BOOL(t0, 1); phalcon_update_property_array(this_ptr, SL("_resourcesNames"), resource_name, t0 TSRMLS_CC); } PHALCON_INIT_VAR(status); PHALCON_CALL_METHOD_PARAMS_2(status, this_ptr, "addresourceaccess", resource_name, access_list); RETURN_CCTOR(status); }
/** * Creates a form registering it in the forms manager * * @param string $name * @param object $entity * @return Phalcon\Forms\Form */ PHP_METHOD(Phalcon_Forms_Manager, create){ zval *name = NULL, *entity = NULL, form = {}; phalcon_fetch_params(0, 0, 2, &name, &entity); if (!name) { name = &PHALCON_GLOBAL(z_null); } if (!entity) { entity = &PHALCON_GLOBAL(z_null); } if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STRW(phalcon_forms_exception_ce, "The form name must be string"); return; } object_init_ex(&form, phalcon_forms_form_ce); PHALCON_CALL_METHODW(NULL, &form, "__construct", entity); phalcon_update_property_array(getThis(), SL("_forms"), name, &form); RETURN_CTORW(&form); }
/** * Adds a resource by its type * *<code> * $assets->addResourceByType('css', new Phalcon\Assets\Resource\Css('css/style.css')); *</code> * * @param string $type * @param Phalcon\Assets\Resource $resource * @return Phalcon\Assets\Manager */ PHP_METHOD(Phalcon_Assets_Manager, addResourceByType){ zval *type, *resource, *collections, *collection = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &type, &resource); PHALCON_OBS_VAR(collections); phalcon_read_property_this(&collections, this_ptr, SL("_collections"), PH_NOISY TSRMLS_CC); if (phalcon_array_isset(collections, type)) { PHALCON_OBS_VAR(collection); phalcon_array_fetch(&collection, collections, type, PH_NOISY); } else { PHALCON_INIT_NVAR(collection); object_init_ex(collection, phalcon_assets_collection_ce); phalcon_update_property_array(this_ptr, SL("_collections"), type, collection TSRMLS_CC); } /** * Add the resource to the collection */ PHALCON_CALL_METHOD(NULL, collection, "add", resource); RETURN_THIS(); }
/** * @brief void Phalcon\Registry::offsetSet(mixed $offset, mixed $value) */ PHP_METHOD(Phalcon_Registry, offsetSet){ zval *property, *callback; phalcon_fetch_params(0, 2, 0, &property, &callback); phalcon_update_property_array(getThis(), SL("_data"), property, callback); }
static void phalcon_mvc_micro_generic_add(INTERNAL_FUNCTION_PARAMETERS, const char *method) { zval *route_pattern, *handler, *router = NULL, *route_id = NULL; phalcon_fetch_params(0, 2, 0, &route_pattern, &handler); PHALCON_MM_GROW(); /** * We create a router even if there is no one in the DI */ PHALCON_CALL_METHOD(&router, getThis(), "getrouter"); /** * Routes are added to the router */ PHALCON_RETURN_CALL_METHOD(router, method, route_pattern); /** * Using the id produced by the router we store the handler */ PHALCON_CALL_METHOD(&route_id, return_value, "getrouteid"); phalcon_update_property_array(getThis(), SL("_handlers"), route_id, handler); /** * The route is returned, the developer can add more things on it */ PHALCON_MM_RESTORE(); }
/** * Registers a service in the services container * * @param string $name * @param mixed $definition * @param boolean $shared * @return Phalcon\DI\ServiceInterface */ PHP_METHOD(Phalcon_DI, set){ zval *name, *definition, *shared = NULL, *service; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 1, &name, &definition, &shared); if (!shared) { PHALCON_INIT_VAR(shared); ZVAL_BOOL(shared, 0); } if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_di_exception_ce, "The service name must be a string"); return; } PHALCON_INIT_VAR(service); object_init_ex(service, phalcon_di_service_ce); PHALCON_CALL_METHOD_PARAMS_3_NORETURN(service, "__construct", name, definition, shared); phalcon_update_property_array(this_ptr, SL("_services"), name, service TSRMLS_CC); RETURN_CTOR(service); }
/** * Resolves a service, the resolved service is stored in the DI, subsequent requests for this service will return the same instance * * @param string $name * @param array $parameters * @return mixed */ PHP_METHOD(Phalcon_DI, getShared){ zval *name, *parameters = NULL, *noerror = NULL, instance = {}; phalcon_fetch_params(0, 1, 2, &name, ¶meters, &noerror); PHALCON_ENSURE_IS_STRING(name); if (!parameters) { parameters = &PHALCON_GLOBAL(z_null); } if (!noerror) { noerror = &PHALCON_GLOBAL(z_null); } if (phalcon_isset_property_array(getThis(), SL("_sharedInstances"), name)) { phalcon_return_property_array(&instance, getThis(), SL("_sharedInstances"), name); phalcon_update_property_bool(getThis(), SL("_freshInstance"), 0); } else { PHALCON_CALL_SELFW(&instance, "get", name, parameters, noerror); if (zend_is_true(&instance)) { phalcon_update_property_bool(getThis(), SL("_freshInstance"), 1); phalcon_update_property_array(getThis(), SL("_sharedInstances"), name, &instance); } } RETURN_CTORW(&instance); }
/** * Sets a value in the session bag * *<code> * $user->set('name', 'Kimbra'); *</code> * * @param string $property * @param string $value */ PHP_METHOD(Phalcon_Session_Bag, set){ zval *property, *value, *initalized, *name, *data; zval *session; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &property, &value) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(initalized); phalcon_read_property(&initalized, this_ptr, SL("_initalized"), PH_NOISY_CC); if (PHALCON_IS_FALSE(initalized)) { PHALCON_CALL_METHOD_NORETURN(this_ptr, "initialize"); } phalcon_update_property_array(this_ptr, SL("_data"), property, value TSRMLS_CC); PHALCON_OBS_VAR(name); phalcon_read_property(&name, this_ptr, SL("_name"), PH_NOISY_CC); PHALCON_OBS_VAR(data); phalcon_read_property(&data, this_ptr, SL("_data"), PH_NOISY_CC); PHALCON_OBS_VAR(session); phalcon_read_property(&session, this_ptr, SL("_session"), PH_NOISY_CC); PHALCON_CALL_METHOD_PARAMS_2_NORETURN(session, "set", name, data); PHALCON_MM_RESTORE(); }
/** * Attempts to register a service in the services container * Only is successful if a service hasn't been registered previously * with the same name * * @param string $name * @param mixed $definition * @param boolean $shared * @return Phalcon\DI\ServiceInterface */ PHP_METHOD(Phalcon_DI, attempt){ zval *name, *definition, *shared = NULL, *services, *service; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 1, &name, &definition, &shared); if (!shared) { PHALCON_INIT_VAR(shared); ZVAL_BOOL(shared, 0); } if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_di_exception_ce, "The service name must be a string"); return; } PHALCON_OBS_VAR(services); phalcon_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC); if (!phalcon_array_isset(services, name)) { PHALCON_INIT_VAR(service); object_init_ex(service, phalcon_di_service_ce); phalcon_call_method_p3_noret(service, "__construct", name, definition, shared); phalcon_update_property_array(this_ptr, SL("_services"), name, service TSRMLS_CC); RETURN_CTOR(service); } RETURN_MM_NULL(); }
/** * Adds a resource by its type * *<code> * $assets->addResourceByType('css', new Phalcon\Assets\Resource\Css('css/style.css')); *</code> * * @param string $type * @param Phalcon\Assets\Resource $resource * @return Phalcon\Assets\Manager */ PHP_METHOD(Phalcon_Assets_Manager, addResourceByType){ zval *type, *resource, *collections, *collection = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &type, &resource) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(collections); phalcon_read_property_this(&collections, this_ptr, SL("_collections"), PH_NOISY_CC); if (phalcon_array_isset(collections, type)) { PHALCON_OBS_VAR(collection); phalcon_array_fetch(&collection, collections, type, PH_NOISY_CC); } else { PHALCON_INIT_NVAR(collection); object_init_ex(collection, phalcon_assets_collection_ce); phalcon_update_property_array(this_ptr, SL("_collections"), type, collection TSRMLS_CC); } /** * Add the resource to the collection */ PHALCON_CALL_METHOD_PARAMS_1_NORETURN(collection, "add", resource); RETURN_THIS(); }
/** * Adds a resource to the ACL list * * Access names can be a particular action, by example * search, update, delete, etc or a list of them * * Example: * <code> * //Add a resource to the the list allowing access to an action * $acl->addResource(new Phalcon\Acl\Resource('customers'), 'search'); * $acl->addResource('customers', 'search'); * * //Add a resource with an access list * $acl->addResource(new Phalcon\Acl\Resource('customers'), array('create', 'search')); * $acl->addResource('customers', array('create', 'search')); * </code> * * @param Phalcon\Acl\Resource|string $resource * @param array $accessList * @return boolean */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addResource){ zval *resource, *access_list = NULL, *resource_name = NULL; zval *object = NULL, *resources_names; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &resource, &access_list); if (!access_list) { access_list = PHALCON_GLOBAL(z_null); } if (Z_TYPE_P(resource) == IS_OBJECT) { PHALCON_CALL_METHOD(&resource_name, resource, "getname"); PHALCON_CPY_WRT(object, resource); } else { PHALCON_CPY_WRT(resource_name, resource); PHALCON_INIT_NVAR(object); object_init_ex(object, phalcon_acl_resource_ce); PHALCON_CALL_METHOD(NULL, object, "__construct", resource_name); } PHALCON_OBS_VAR(resources_names); phalcon_read_property_this(&resources_names, this_ptr, SL("_resourcesNames"), PH_NOISY TSRMLS_CC); if (!phalcon_array_isset(resources_names, resource_name)) { phalcon_update_property_array_append(this_ptr, SL("_resources"), object TSRMLS_CC); phalcon_update_property_array(this_ptr, SL("_resourcesNames"), resource_name, PHALCON_GLOBAL(z_true) TSRMLS_CC); } PHALCON_RETURN_CALL_METHOD(this_ptr, "addresourceaccess", resource_name, access_list); RETURN_MM(); }
/** * Sets a value in the session bag * *<code> * $user->set('name', 'Kimbra'); *</code> * * @param string $property * @param string $value */ PHP_METHOD(Phalcon_Session_Bag, set){ zval *property, *value, *initalized, *name, *data; zval *session; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &property, &value); PHALCON_OBS_VAR(initalized); phalcon_read_property_this(&initalized, this_ptr, SL("_initalized"), PH_NOISY_CC); if (PHALCON_IS_FALSE(initalized)) { phalcon_call_method_noret(this_ptr, "initialize"); } phalcon_update_property_array(this_ptr, SL("_data"), property, value TSRMLS_CC); PHALCON_OBS_VAR(name); phalcon_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC); PHALCON_OBS_VAR(data); phalcon_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); PHALCON_OBS_VAR(session); phalcon_read_property_this(&session, this_ptr, SL("_session"), PH_NOISY_CC); phalcon_call_method_p2_noret(session, "set", name, data); PHALCON_MM_RESTORE(); }
/** * Maps a route to a handler that only matches if the HTTP method is HEAD * * @param string $routePattern * @param callable $handler * @return Phalcon\Mvc\Router\RouteInterface */ PHP_METHOD(Phalcon_Mvc_Micro, head){ zval *route_pattern, *handler, *router, *route; zval *route_id; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &route_pattern, &handler); /** * We create a router even if there is no one in the DI */ PHALCON_INIT_VAR(router); phalcon_call_method(router, this_ptr, "getrouter"); /** * Routes are added to the router restricting to HEAD */ PHALCON_INIT_VAR(route); phalcon_call_method_p1(route, router, "addhead", route_pattern); /** * Using the id produced by the router we store the handler */ PHALCON_INIT_VAR(route_id); phalcon_call_method(route_id, route, "getrouteid"); phalcon_update_property_array(this_ptr, SL("_handlers"), route_id, handler TSRMLS_CC); /** * The route is returned, the developer can add more things on it */ RETURN_CCTOR(route); }
/** * Creates a form registering it in the forms manager * * @param string $name * @param object $entity * @return Phalcon\Forms\Form */ PHP_METHOD(Phalcon_Forms_Manager, create){ zval *name = NULL, *entity = NULL, *form; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 2, &name, &entity); if (!name) { PHALCON_INIT_VAR(name); } if (!entity) { PHALCON_INIT_VAR(entity); } if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_forms_exception_ce, "The form name must be string"); return; } PHALCON_INIT_VAR(form); object_init_ex(form, phalcon_forms_form_ce); phalcon_call_method_p1_noret(form, "__construct", entity); phalcon_update_property_array(this_ptr, SL("_forms"), name, form TSRMLS_CC); RETURN_CTOR(form); }
/** * Adds an element to the form * * @param Phalcon\Forms\ElementInterface $element * @return Phalcon\Forms\Form */ PHP_METHOD(Phalcon_Forms_Form, add){ zval *element, *name; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &element) == FAILURE) { RETURN_MM_NULL(); } if (Z_TYPE_P(element) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_forms_exception_ce, "The element is not valid"); return; } /** * Gets the element's name */ PHALCON_INIT_VAR(name); PHALCON_CALL_METHOD(name, element, "getname"); /** * Link the element to the form */ PHALCON_CALL_METHOD_PARAMS_1_NORETURN(element, "setform", this_ptr); /** * Append the element by its name */ phalcon_update_property_array(this_ptr, SL("_elements"), name, element TSRMLS_CC); RETURN_THIS(); }
/** * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role * * Example: * <code> * $acl->addRole(new Phalcon\Acl\Role('administrator'), 'consultant'); * $acl->addRole('administrator', 'consultant'); * </code> * * @param Phalcon\Acl\RoleInterface|string $role * @param array|string $accessInherits * @return boolean */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addRole){ zval *role, *access_inherits = NULL, *role_name = NULL, *object = NULL; zval *roles_names, *default_access; zval *key; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &role, &access_inherits); if (!access_inherits) { access_inherits = PHALCON_GLOBAL(z_null); } if (Z_TYPE_P(role) == IS_OBJECT) { PHALCON_CALL_METHOD(&role_name, role, "getname"); PHALCON_CPY_WRT(object, role); } else { PHALCON_CPY_WRT(role_name, role); PHALCON_INIT_NVAR(object); object_init_ex(object, phalcon_acl_role_ce); PHALCON_CALL_METHOD(NULL, object, "__construct", role); } roles_names = phalcon_fetch_nproperty_this(this_ptr, SL("_rolesNames"), PH_NOISY TSRMLS_CC); if (phalcon_array_isset(roles_names, role_name)) { RETURN_MM_FALSE; } phalcon_update_property_array_append(this_ptr, SL("_roles"), object TSRMLS_CC); phalcon_update_property_array(this_ptr, SL("_rolesNames"), role_name, PHALCON_GLOBAL(z_true) TSRMLS_CC); default_access = phalcon_fetch_nproperty_this(this_ptr, SL("_defaultAccess"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(key); PHALCON_CONCAT_VS(key, role_name, "!*!*"); phalcon_update_property_array(this_ptr, SL("_access"), key, default_access TSRMLS_CC); if (Z_TYPE_P(access_inherits) != IS_NULL) { PHALCON_RETURN_CALL_METHOD(this_ptr, "addinherit", role_name, access_inherits); RETURN_MM(); } RETURN_MM_TRUE; }
/** * Magic __set method * * @param string $key */ PHP_METHOD(Phalcon_Http_Uri, __set){ zval *key, *value; phalcon_fetch_params(0, 2, 0, &key, &value); phalcon_update_property_array(getThis(), SL("_parts"), key, value); }
/** * Sets a header to be sent at the end of the request * * @param string $name * @param string $value */ PHP_METHOD(Phalcon_Http_Response_Headers, set){ zval *name, *value; phalcon_fetch_params(0, 2, 0, &name, &value); phalcon_update_property_array(this_ptr, SL("_headers"), name, value TSRMLS_CC); }
/** * Sets a default attribute for the element * * @param string $attribute * @param mixed $value * @return Phalcon\Forms\ElementInterface */ PHP_METHOD(Phalcon_Forms_Element, setAttribute){ zval *attribute, *value; phalcon_fetch_params(0, 2, 0, &attribute, &value); phalcon_update_property_array(this_ptr, SL("_attributes"), attribute, value TSRMLS_CC); RETURN_THISW(); }
/** * Magic method to pass variables to the views * *<code> * $this->view->products = $products; *</code> * * @param string $key * @param mixed $value */ PHP_METHOD(Phalcon_Mvc_View_Simple, __set){ zval *key, *value; phalcon_fetch_params(0, 2, 0, &key, &value); phalcon_update_property_array(this_ptr, SL("_viewParams"), key, value TSRMLS_CC); }
/** * Adds a converter to perform an additional transformation for certain parameter * * @param string $name * @param callable $converter * @return Phalcon\Mvc\Router\Group */ PHP_METHOD(Phalcon_Mvc_Router_Group, convert){ zval *name, *converter; phalcon_fetch_params(0, 2, 0, &name, &converter); phalcon_update_property_array(getThis(), SL("_converters"), name, converter); RETURN_THISW(); }
/** * Adds a converter to perform an additional transformation for certain parameter * * @param string $name * @param callable $converter * @return Phalcon\Mvc\Router\Route */ PHP_METHOD(Phalcon_Mvc_Router_Route, convert){ zval *name, *converter; phalcon_fetch_params(0, 2, 0, &name, &converter); phalcon_update_property_array(this_ptr, SL("_converters"), name, converter TSRMLS_CC); RETURN_THISW(); }
PHP_METHOD(Phalcon_Http_Client_Header, set){ zval *name, *value; phalcon_fetch_params(0, 2, 0, &name, &value); phalcon_update_property_array(this_ptr, SL("_fields"), name, value TSRMLS_CC); }
/** * Adds filters to the field * * @param string $attribute * @param array|string $attribute * @return Phalcon\Validation */ PHP_METHOD(Phalcon_Validation, setFilters){ zval *attribute, *filters; phalcon_fetch_params(0, 2, 0, &attribute, &filters); phalcon_update_property_array(this_ptr, SL("_filters"), attribute, filters TSRMLS_CC); RETURN_THISW(); }
/** * Sets an option for the element * * @param string $option * @param mixed $value * @return Phalcon\Forms\ElementInterface */ PHP_METHOD(Phalcon_Forms_Element, setUserOption){ zval *option, *value; phalcon_fetch_params(0, 2, 0, &option, &value); phalcon_update_property_array(this_ptr, SL("_options"), option, value TSRMLS_CC); RETURN_THISW(); }
/** * Adds a role to the ACL list. Second parameter allows inheriting access data from other existing role * * Example: * <code> * $acl->addRole(new Phalcon\Acl\Role('administrator'), 'consultant'); * $acl->addRole('administrator', 'consultant'); * </code> * * @param Phalcon\Acl\RoleInterface $role * @param array|string $accessInherits * @return boolean */ PHP_METHOD(Phalcon_Acl_Adapter_Memory, addRole){ zval *role, *access_inherits = NULL, *role_name = NULL, *object = NULL; zval *roles_names, *default_access, *_access; zval *success; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &role, &access_inherits) == FAILURE) { RETURN_MM_NULL(); } if (!access_inherits) { PHALCON_INIT_VAR(access_inherits); } if (Z_TYPE_P(role) == IS_OBJECT) { PHALCON_INIT_VAR(role_name); PHALCON_CALL_METHOD(role_name, role, "getname"); PHALCON_CPY_WRT(object, role); } else { PHALCON_CPY_WRT(role_name, role); PHALCON_INIT_VAR(object); object_init_ex(object, phalcon_acl_role_ce); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(object, "__construct", role); } PHALCON_OBS_VAR(roles_names); phalcon_read_property(&roles_names, this_ptr, SL("_rolesNames"), PH_NOISY_CC); if (phalcon_array_isset(roles_names, role_name)) { RETURN_MM_FALSE; } phalcon_update_property_array_append(this_ptr, SL("_roles"), object TSRMLS_CC); PHALCON_INIT_VAR(t0); ZVAL_BOOL(t0, 1); phalcon_update_property_array(this_ptr, SL("_rolesNames"), role_name, t0 TSRMLS_CC); PHALCON_OBS_VAR(default_access); phalcon_read_property(&default_access, this_ptr, SL("_defaultAccess"), PH_NOISY_CC); PHALCON_OBS_VAR(_access); phalcon_read_property(&_access, this_ptr, SL("_access"), PH_NOISY_CC); phalcon_array_update_zval_string_string_multi_3(&_access, role_name, SL("*"), SL("*"), &default_access, 0 TSRMLS_CC); if (Z_TYPE_P(access_inherits) != IS_NULL) { PHALCON_INIT_VAR(success); PHALCON_CALL_METHOD_PARAMS_2(success, this_ptr, "addinherit", role_name, access_inherits); RETURN_CCTOR(success); } RETURN_MM_TRUE; }
/** * Sets a service using a raw Phalcon\DI\Service definition * * @param string|Phalcon\DI\ServiceInterface $raw_definition_or_name * @param Phalcon\DI\ServiceInterface $rawDefinition * @return Phalcon\DI\ServiceInterface */ PHP_METHOD(Phalcon_DI, setService) { zval *name, *raw_definition; phalcon_fetch_params(0, 1, 1, &name, &raw_definition); phalcon_update_property_array(getThis(), SL("_services"), name, raw_definition); RETURN_CTORW(raw_definition); }