/** * Check whether the DI contains a service by a name * * @param string $name * @return boolean */ PHP_METHOD(Phalcon_DI, has){ zval *name, *services, *is_set_service = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &name); PHALCON_OBS_VAR(services); phalcon_read_property_this(&services, this_ptr, SL("_services"), PH_NOISY_CC); PHALCON_INIT_VAR(r0); ZVAL_BOOL(r0, phalcon_array_isset(services, name)); PHALCON_CPY_WRT(is_set_service, r0); RETURN_NCTOR(is_set_service); }
/** * Returns the cache instance used to cache * * @return Phalcon\Cache\BackendInterface */ PHP_METHOD(Phalcon_Mvc_View_Simple, getCache){ zval *cache = NULL; PHALCON_MM_GROW(); PHALCON_OBS_VAR(cache); phalcon_read_property_this(&cache, this_ptr, SL("_cache"), PH_NOISY TSRMLS_CC); if (zend_is_true(cache)) { if (Z_TYPE_P(cache) != IS_OBJECT) { PHALCON_CALL_METHOD(&cache, this_ptr, "_createcache"); phalcon_update_property_this(this_ptr, SL("_cache"), cache TSRMLS_CC); } } RETURN_CCTOR(cache); }
/** * Check whether is defined a translation key in the internal array * * @param string $index * @return bool */ PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, exists){ zval *index, *translate, *exists = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &index); PHALCON_OBS_VAR(translate); phalcon_read_property_this(&translate, this_ptr, SL("_translate"), PH_NOISY_CC); PHALCON_INIT_VAR(r0); ZVAL_BOOL(r0, phalcon_array_isset(translate, index)); PHALCON_CPY_WRT(exists, r0); RETURN_NCTOR(exists); }
/** * Returns the javascript sources * * @return string */ PHP_METHOD(Phalcon_Debug, getJsSources){ zval *uri, *sources; PHALCON_MM_GROW(); PHALCON_OBS_VAR(uri); phalcon_read_property_this(&uri, this_ptr, SL("_uri"), PH_NOISY_CC); PHALCON_INIT_VAR(sources); PHALCON_CONCAT_SVS(sources, "<script type=\"text/javascript\" src=\"", uri, "jquery/jquery.js\"></script>"); PHALCON_SCONCAT_SVS(sources, "<script type=\"text/javascript\" src=\"", uri, "jquery/jquery-ui.js\"></script>"); PHALCON_SCONCAT_SVS(sources, "<script type=\"text/javascript\" src=\"", uri, "jquery/jquery.scrollTo.js\"></script>"); PHALCON_SCONCAT_SVS(sources, "<script type=\"text/javascript\" src=\"", uri, "prettify/prettify.js\"></script>"); PHALCON_SCONCAT_SVS(sources, "<script type=\"text/javascript\" src=\"", uri, "pretty.js\"></script>"); RETURN_CTOR(sources); }
/** * Check whether a option has been defined in the validator options * * @param string $option * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Validator, isSetOption){ zval *option, *options, *is_set = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &option); PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); PHALCON_INIT_VAR(r0); ZVAL_BOOL(r0, phalcon_array_isset(options, option)); PHALCON_CPY_WRT(is_set, r0); RETURN_NCTOR(is_set); }
/** * Generates a pseudo random token value to be used as input's value in a CSRF check * * @param int $numberBytes * @return string */ PHP_METHOD(Phalcon_Security, getToken){ zval *number_bytes = NULL, *random_bytes, *token, *dependency_injector; zval *service, *session, *key; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 1, &number_bytes); if (!number_bytes) { PHALCON_INIT_VAR(number_bytes); ZVAL_LONG(number_bytes, 12); } if (phalcon_function_exists_ex(SS("openssl_random_pseudo_bytes") TSRMLS_CC) == FAILURE) { PHALCON_THROW_EXCEPTION_STR(phalcon_security_exception_ce, "Openssl extension must be loaded"); return; } PHALCON_INIT_VAR(random_bytes); phalcon_call_func_p1(random_bytes, "openssl_random_pseudo_bytes", number_bytes); PHALCON_INIT_VAR(token); phalcon_md5(token, random_bytes); PHALCON_OBS_VAR(dependency_injector); phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC); if (Z_TYPE_P(dependency_injector) != IS_OBJECT) { PHALCON_THROW_EXCEPTION_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service"); return; } PHALCON_INIT_VAR(service); ZVAL_STRING(service, "session", 1); PHALCON_INIT_VAR(session); phalcon_call_method_p1(session, dependency_injector, "getshared", service); PHALCON_VERIFY_INTERFACE(session, phalcon_session_adapterinterface_ce); PHALCON_INIT_VAR(key); ZVAL_STRING(key, "$PHALCON/CSRF$", 1); phalcon_call_method_p2_noret(session, "set", key, token); RETURN_CTOR(token); }
/** * Checks whether the behavior must take action on certain event * * @param string $eventName */ PHP_METHOD(Phalcon_Mvc_Model_Behavior, mustTakeAction){ zval *event_name, *options; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &event_name) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (phalcon_array_isset(options, event_name)) { RETURN_MM_TRUE; } RETURN_MM_FALSE; }
/** * Gets a header value from the internal bag * * @param string $name * @return string */ PHP_METHOD(Phalcon_Http_Response_Headers, get){ zval *name, *headers, *header_value; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &name); PHALCON_OBS_VAR(headers); phalcon_read_property_this(&headers, this_ptr, SL("_headers"), PH_NOISY_CC); if (phalcon_array_isset(headers, name)) { PHALCON_OBS_VAR(header_value); phalcon_array_fetch(&header_value, headers, name, PH_NOISY); RETURN_CCTOR(header_value); } RETURN_MM_FALSE; }
/** * Magic method to retrieve a variable passed to the view * *<code> * echo $this->view->products; *</code> * * @param string $key * @return mixed */ PHP_METHOD(Phalcon_Mvc_View_Simple, __get){ zval *key, *params, *value; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &key); PHALCON_OBS_VAR(params); phalcon_read_property_this(¶ms, this_ptr, SL("_viewParams"), PH_NOISY_CC); if (phalcon_array_isset(params, key)) { PHALCON_OBS_VAR(value); phalcon_array_fetch(&value, params, key, PH_NOISY); RETURN_CCTOR(value); } RETURN_MM_NULL(); }
/** * Check if records in belongs-to/has-many are implicitly cached during the current request * * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Relation, isReusable){ zval *options, *reusable; PHALCON_MM_GROW(); PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (phalcon_array_isset_string(options, SS("reusable"))) { PHALCON_OBS_VAR(reusable); phalcon_array_fetch_string(&reusable, options, SL("reusable"), PH_NOISY_CC); RETURN_CCTOR(reusable); } } RETURN_MM_FALSE; }
/** * Sets a prefix for all the URIs to be generated * *<code> * $url->setBaseUri('/invo/'); * $url->setBaseUri('/invo/index.php/'); *</code> * * @param string $baseUri * @return Phalcon\Mvc\Url */ PHP_METHOD(Phalcon_Mvc_Url, setBaseUri){ zval *base_uri, *static_base_uri; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &base_uri); phalcon_update_property_this(this_ptr, SL("_baseUri"), base_uri TSRMLS_CC); PHALCON_OBS_VAR(static_base_uri); phalcon_read_property_this(&static_base_uri, this_ptr, SL("_staticBaseUri"), PH_NOISY TSRMLS_CC); if (Z_TYPE_P(static_base_uri) == IS_NULL) { phalcon_update_property_this(this_ptr, SL("_staticBaseUri"), base_uri TSRMLS_CC); } RETURN_THIS(); }
/** * Check whether certain type of event has listeners * * @param string $type * @return boolean */ PHP_METHOD(Phalcon_Events_Manager, hasListeners){ zval *type, *events; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &type); PHALCON_OBS_VAR(events); phalcon_read_property_this(&events, this_ptr, SL("_events"), PH_NOISY_CC); if (Z_TYPE_P(events) == IS_ARRAY) { if (phalcon_array_isset(events, type)) { RETURN_MM_TRUE; } } RETURN_MM_FALSE; }
/** * Returns the 'through' relation if any * * @return string */ PHP_METHOD(Phalcon_Mvc_Model_Relation, getThrough){ zval *options, *through; PHALCON_MM_GROW(); PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (phalcon_array_isset_string(options, SS("through"))) { PHALCON_OBS_VAR(through); phalcon_array_fetch_string(&through, options, SL("through"), PH_NOISY_CC); RETURN_CCTOR(through); } } RETURN_MM_FALSE; }
/** * Writes the meta-data to $_SESSION * * @param string $key * @param array $data */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, write){ zval *key, *data, *prefix, *prefix_key, *_SESSION; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &key, &data); PHALCON_OBS_VAR(prefix); phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); PHALCON_INIT_VAR(prefix_key); PHALCON_CONCAT_SV(prefix_key, "$PMM$", prefix); phalcon_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC); phalcon_array_update_multi_2(&_SESSION, prefix_key, key, &data, 0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Returns an option * * @param string $option * @return mixed */ PHP_METHOD(Phalcon_Mvc_Model_Validator, getOption){ zval *option, *options, *value; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &option); PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); if (phalcon_array_isset(options, option)) { PHALCON_OBS_VAR(value); phalcon_array_fetch(&value, options, option, PH_NOISY); RETURN_CCTOR(value); } RETURN_MM_EMPTY_STRING(); }
/** * Returns the internal formatter * * @return Phalcon\Logger\Formatter\Line */ PHP_METHOD(Phalcon_Logger_Adapter_File, getFormatter){ zval *formatter = NULL; PHALCON_MM_GROW(); PHALCON_OBS_VAR(formatter); phalcon_read_property_this(&formatter, this_ptr, SL("_formatter"), PH_NOISY_CC); if (Z_TYPE_P(formatter) != IS_OBJECT) { PHALCON_INIT_NVAR(formatter); object_init_ex(formatter, phalcon_logger_formatter_line_ce); phalcon_call_method_noret(formatter, "__construct"); phalcon_update_property_this(this_ptr, SL("_formatter"), formatter TSRMLS_CC); } RETURN_CCTOR(formatter); }
/** * 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, *shared_instances, *instance = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 1, &name, ¶meters); if (!parameters) { PHALCON_INIT_VAR(parameters); } if (Z_TYPE_P(name) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_di_exception_ce, "The service alias must be a string"); return; } /** * This method provides a first level to shared instances allowing to use * non-shared services as shared */ PHALCON_OBS_VAR(shared_instances); phalcon_read_property_this(&shared_instances, this_ptr, SL("_sharedInstances"), PH_NOISY_CC); if (phalcon_array_isset(shared_instances, name)) { PHALCON_OBS_VAR(instance); phalcon_array_fetch(&instance, shared_instances, name, PH_NOISY_CC); phalcon_update_property_bool(this_ptr, SL("_freshInstance"), 0 TSRMLS_CC); } else { /** * Resolve the instance normally */ PHALCON_INIT_NVAR(instance); PHALCON_CALL_METHOD_PARAMS_2(instance, this_ptr, "get", name, parameters); /** * Save the instance in the first level shared */ phalcon_update_property_array(this_ptr, SL("_sharedInstances"), name, instance TSRMLS_CC); phalcon_update_property_bool(this_ptr, SL("_freshInstance"), 1 TSRMLS_CC); } RETURN_CCTOR(instance); }
/** * Writes parsed annotations to files * * @param string $key * @param Phalcon\Annotations\Reflection $data */ PHP_METHOD(Phalcon_Annotations_Adapter_Files, write){ zval *key, *data, *annotations_dir, *separator; zval *virtual_key, *path, *to_string, *export, *php_export; zval *status; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &key, &data); PHALCON_OBS_VAR(annotations_dir); phalcon_read_property_this(&annotations_dir, this_ptr, SL("_annotationsDir"), PH_NOISY_CC); PHALCON_INIT_VAR(separator); ZVAL_STRING(separator, "_", 1); /** * Paths must be normalized before be used as keys */ PHALCON_INIT_VAR(virtual_key); phalcon_prepare_virtual_path(virtual_key, key, separator TSRMLS_CC); PHALCON_INIT_VAR(path); PHALCON_CONCAT_VVS(path, annotations_dir, virtual_key, ".php"); PHALCON_INIT_VAR(to_string); ZVAL_BOOL(to_string, 1); PHALCON_INIT_VAR(export); phalcon_call_func_p2(export, "var_export", data, to_string); PHALCON_INIT_VAR(php_export); PHALCON_CONCAT_SVS(php_export, "<?php return ", export, "; "); PHALCON_INIT_VAR(status); phalcon_file_put_contents(status, path, php_export TSRMLS_CC); if (PHALCON_IS_FALSE(status)) { PHALCON_THROW_EXCEPTION_STR(phalcon_annotations_exception_ce, "Annotations directory cannot be written"); return; } PHALCON_MM_RESTORE(); }
/** * Generates a local path * * @param string $path * @return string */ PHP_METHOD(Phalcon_Mvc_Url, path){ zval *path = NULL, *base_path, *final_path; PHALCON_MM_GROW(); phalcon_fetch_params(1, 0, 1, &path); if (!path) { PHALCON_INIT_VAR(path); } PHALCON_OBS_VAR(base_path); phalcon_read_property_this(&base_path, this_ptr, SL("_basePath"), PH_NOISY_CC); PHALCON_INIT_VAR(final_path); PHALCON_CONCAT_VV(final_path, base_path, path); RETURN_CTOR(final_path); }
/** * Create internal connection to memcached */ PHP_METHOD(Phalcon_Cache_Backend_Memcache, _connect){ zval *options, *memcache, *host, *port, *persistent; zval *success; zend_class_entry *ce0; PHALCON_MM_GROW(); PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC); ce0 = zend_fetch_class(SL("Memcache"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); PHALCON_INIT_VAR(memcache); object_init_ex(memcache, ce0); if (phalcon_has_constructor(memcache TSRMLS_CC)) { phalcon_call_method_noret(memcache, "__construct"); } PHALCON_OBS_VAR(host); phalcon_array_fetch_string(&host, options, SL("host"), PH_NOISY); PHALCON_OBS_VAR(port); phalcon_array_fetch_string(&port, options, SL("port"), PH_NOISY); PHALCON_OBS_VAR(persistent); phalcon_array_fetch_string(&persistent, options, SL("persistent"), PH_NOISY); PHALCON_INIT_VAR(success); if (zend_is_true(persistent)) { phalcon_call_method_p2(success, memcache, "pconnect", host, port); } else { phalcon_call_method_p2(success, memcache, "connect", host, port); } if (!zend_is_true(success)) { PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Cannot connect to Memcached server"); return; } phalcon_update_property_this(this_ptr, SL("_memcache"), memcache TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** * Checks whether there are messages attached to the element * * @return boolean */ PHP_METHOD(Phalcon_Forms_Element, hasMessages){ zval *messages; PHALCON_MM_GROW(); /** * Get the related form */ PHALCON_OBS_VAR(messages); phalcon_read_property_this(&messages, this_ptr, SL("_messages"), PH_NOISY_CC); if (Z_TYPE_P(messages) == IS_OBJECT) { if (phalcon_fast_count_ev(messages TSRMLS_CC)) { RETURN_MM_TRUE; } } RETURN_MM_FALSE; }
/** * Returns the cache lifetime * * @return integer */ PHP_METHOD(Phalcon_Cache_Frontend_Base64, getLifetime){ zval *options, *lifetime; PHALCON_MM_GROW(); PHALCON_OBS_VAR(options); phalcon_read_property_this(&options, this_ptr, SL("_frontendOptions"), PH_NOISY_CC); if (Z_TYPE_P(options) == IS_ARRAY) { if (phalcon_array_isset_string(options, SS("lifetime"))) { PHALCON_OBS_VAR(lifetime); phalcon_array_fetch_string(&lifetime, options, SL("lifetime"), PH_NOISY); RETURN_CCTOR(lifetime); } } PHALCON_MM_RESTORE(); RETURN_LONG(1); }
/** * Writes the metadata to XCache * * @param string $key * @param array $data */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, write){ zval *key, *data, *prefix, *xc_key, *ttl; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &key, &data); prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(xc_key); PHALCON_CONCAT_SVV(xc_key, "$PMM$", prefix, key); PHALCON_OBS_VAR(ttl); phalcon_read_property_this(&ttl, this_ptr, SL("_ttl"), PH_NOISY TSRMLS_CC); PHALCON_CALL_FUNCTION(NULL, "xcache_set", xc_key, data, ttl); PHALCON_MM_RESTORE(); }
/** * Returns the messages produced by a failed operation * * @return Phalcon\Mvc\Model\MessageInterface[] */ PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getMessages){ zval *model, *messages, *empty_arr; PHALCON_MM_GROW(); PHALCON_OBS_VAR(model); phalcon_read_property_this(&model, this_ptr, SL("_model"), PH_NOISY_CC); if (Z_TYPE_P(model) == IS_OBJECT) { PHALCON_INIT_VAR(messages); phalcon_call_method(messages, model, "getmessages"); RETURN_CCTOR(messages); } PHALCON_INIT_VAR(empty_arr); array_init(empty_arr); RETURN_CTOR(empty_arr); }
/** * Gets row in a specific position of the resultset * * @param int $index * @return Phalcon\Mvc\ModelInterface */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetGet){ zval *index, *count, *pointer, *valid; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &index); PHALCON_INIT_VAR(count); phalcon_call_method(count, this_ptr, "count"); if (PHALCON_LT(index, count)) { /** * Check if the last record returned is the current requested */ PHALCON_OBS_VAR(pointer); phalcon_read_property_this(&pointer, this_ptr, SL("_pointer"), PH_NOISY_CC); if (PHALCON_IS_EQUAL(pointer, index)) { phalcon_call_method(return_value, this_ptr, "current"); RETURN_MM(); } /** * Move the cursor to the specific position */ phalcon_call_method_p1_noret(this_ptr, "seek", index); /** * Check if the last record returned is the requested */ PHALCON_INIT_VAR(valid); phalcon_call_method(valid, this_ptr, "valid"); if (PHALCON_IS_NOT_FALSE(valid)) { phalcon_call_method(return_value, this_ptr, "current"); RETURN_MM(); } RETURN_MM_FALSE; } PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the cursor"); return; }
/** * Writes parsed annotations to files * * @param string $key * @param array $data */ PHP_METHOD(Phalcon_Annotations_Adapter_Files, write){ zval *key, *data, *annotations_dir, *separator; zval *virtual_key, *path, *to_string, *export, *php_export; zval *status; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &key, &data) == FAILURE) { RETURN_MM_NULL(); } PHALCON_OBS_VAR(annotations_dir); phalcon_read_property_this(&annotations_dir, this_ptr, SL("_annotationsDir"), PH_NOISY_CC); PHALCON_INIT_VAR(separator); ZVAL_STRING(separator, "_", 1); PHALCON_INIT_VAR(virtual_key); phalcon_prepare_virtual_path(virtual_key, key, separator TSRMLS_CC); PHALCON_INIT_VAR(path); PHALCON_CONCAT_VVS(path, annotations_dir, virtual_key, ".php"); PHALCON_INIT_VAR(to_string); ZVAL_BOOL(to_string, 1); PHALCON_INIT_VAR(export); PHALCON_CALL_FUNC_PARAMS_2(export, "var_export", data, to_string); PHALCON_INIT_VAR(php_export); PHALCON_CONCAT_SVS(php_export, "<?php return ", export, "; "); PHALCON_INIT_VAR(status); PHALCON_CALL_FUNC_PARAMS_2(status, "file_put_contents", path, php_export); if (PHALCON_IS_FALSE(status)) { PHALCON_THROW_EXCEPTION_STR(phalcon_annotations_exception_ce, "Annotations directory cannot be written"); return; } PHALCON_MM_RESTORE(); }
/** * Returns headers set by the user * * @return Phalcon\Http\Response\HeadersInterface */ PHP_METHOD(Phalcon_Http_Response, getHeaders){ zval *headers = NULL; PHALCON_MM_GROW(); PHALCON_OBS_VAR(headers); phalcon_read_property_this(&headers, this_ptr, SL("_headers"), PH_NOISY_CC); if (Z_TYPE_P(headers) == IS_NULL) { /** * A Phalcon\Http\Response\Headers bag is temporary used to manage the headers * before sent them to the client */ PHALCON_INIT_NVAR(headers); object_init_ex(headers, phalcon_http_response_headers_ce); phalcon_update_property_this(this_ptr, SL("_headers"), headers TSRMLS_CC); } RETURN_CCTOR(headers); }
/** * Returns all the attached listeners of a certain type * * @param string $type * @return array */ PHP_METHOD(Phalcon_Events_Manager, getListeners){ zval *type, *events, *fire_events; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &type); PHALCON_OBS_VAR(events); phalcon_read_property_this(&events, this_ptr, SL("_events"), PH_NOISY_CC); if (Z_TYPE_P(events) == IS_ARRAY) { if (phalcon_array_isset(events, type)) { PHALCON_OBS_VAR(fire_events); phalcon_array_fetch(&fire_events, events, type, PH_NOISY); RETURN_CCTOR(fire_events); } } RETURN_MM_EMPTY_ARRAY(); }
/** * Check whether a model is already initialized * * @param string $modelName * @return bool */ PHP_METHOD(Phalcon_Mvc_Collection_Manager, isInitialized){ zval *model_name, *initialized, *lowercased; zval *is_intitialized = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &model_name); PHALCON_OBS_VAR(initialized); phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); PHALCON_INIT_VAR(lowercased); phalcon_fast_strtolower(lowercased, model_name); PHALCON_INIT_VAR(r0); ZVAL_BOOL(r0, phalcon_array_isset(initialized, lowercased)); PHALCON_CPY_WRT(is_intitialized, r0); RETURN_NCTOR(is_intitialized); }
/** * Executes a find using the parameters built with the criteria * * @return Phalcon\Mvc\Model\ResultsetInterface */ PHP_METHOD(Phalcon_Mvc_Model_Criteria, execute){ zval *model, *params, *resultset; PHALCON_MM_GROW(); PHALCON_OBS_VAR(model); phalcon_read_property_this(&model, this_ptr, SL("_model"), PH_NOISY_CC); if (Z_TYPE_P(model) != IS_STRING) { PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Model name must be string"); return; } PHALCON_INIT_VAR(params); phalcon_call_method(params, this_ptr, "getparams"); PHALCON_INIT_VAR(resultset); phalcon_call_zval_str_static_p1(resultset, model, "find", params); RETURN_CCTOR(resultset); }