/** * Reads parsed annotations from files * * @param string $key * @return array */ PHP_METHOD(Phalcon_Annotations_Adapter_Files, read){ zval *key, *annotations_dir, *separator, *virtual_key; zval *path, *data; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &key) == 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"); if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(data); if (phalcon_require_ret(data, path TSRMLS_CC) == FAILURE) { return; } RETURN_CCTOR(data); } RETURN_MM_NULL(); }
/** * Reads meta-data from files * * @param string $key * @return array */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, read){ zval **key, *meta_data_dir, *virtual_key; zval *path, *data = NULL; phalcon_fetch_params_ex(1, 0, &key); PHALCON_ENSURE_IS_STRING(key); PHALCON_MM_GROW(); meta_data_dir = phalcon_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(virtual_key); phalcon_prepare_virtual_path_ex(virtual_key, Z_STRVAL_PP(key), Z_STRLEN_PP(key), '_' TSRMLS_CC); PHALCON_INIT_VAR(path); PHALCON_CONCAT_VVS(path, meta_data_dir, virtual_key, ".php"); if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) { RETURN_MM_ON_FAILURE(phalcon_require_ret(&data, Z_STRVAL_P(path) TSRMLS_CC)); RETVAL_ZVAL(data, 1, 1); } PHALCON_MM_RESTORE(); }
/** * Load config file * * @param string $filePath */ PHP_METHOD(Phalcon_Config_Adapter_Php, read){ zval *file_path, *absolute_path = NULL, config_dir_path = {}, *base_path, config = {}; phalcon_fetch_params(0, 1, 1, &file_path, &absolute_path); PHALCON_ENSURE_IS_STRING(file_path); if (absolute_path == NULL) { absolute_path = &PHALCON_GLOBAL(z_false); } if (zend_is_true(absolute_path)) { PHALCON_CPY_WRT(&config_dir_path, file_path); } else { base_path = phalcon_read_static_property_ce(phalcon_config_adapter_ce, SL("_basePath")); PHALCON_CONCAT_VV(&config_dir_path, base_path, file_path); } if (phalcon_require_ret(&config, Z_STRVAL(config_dir_path)) == FAILURE) { zend_throw_exception_ex(phalcon_config_exception_ce, 0, "Configuration file '%s' cannot be read", Z_STRVAL(config_dir_path)); PHALCON_PTR_DTOR(&config_dir_path); return; } PHALCON_PTR_DTOR(&config_dir_path); if (Z_TYPE(config) == IS_ARRAY) { PHALCON_CALL_METHODW(NULL, getThis(), "val", &config); } PHALCON_PTR_DTOR(&config); RETURN_THISW(); }
/** * Reads parsed annotations from files * * @param string $key * @return Phalcon\Annotations\Reflection */ PHP_METHOD(Phalcon_Annotations_Adapter_Files, read){ zval *key, *annotations_dir, *separator, *virtual_key; zval *path, *data; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &key); 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"); if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) { PHALCON_INIT_VAR(data); if (phalcon_require_ret(data, path TSRMLS_CC) == FAILURE) { return; } RETURN_CCTOR(data); } RETURN_MM_NULL(); }
/** * Reads parsed annotations from files * * @param string $key * @return Phalcon\Annotations\Reflection */ PHP_METHOD(Phalcon_Annotations_Adapter_Files, read){ zval *key, annotations_dir = {}, virtual_key = {}, path = {}; phalcon_fetch_params(0, 1, 0, &key); PHALCON_ENSURE_IS_STRING(key); phalcon_return_property(&annotations_dir, getThis(), SL("_annotationsDir")); /** * Paths must be normalized before be used as keys */ phalcon_prepare_virtual_path_ex(&virtual_key, Z_STRVAL_P(key), Z_STRLEN_P(key), '_'); PHALCON_CONCAT_VVS(&path, &annotations_dir, &virtual_key, ".php"); if (phalcon_file_exists(&path) == SUCCESS) { RETURN_ON_FAILURE(phalcon_require_ret(return_value, Z_STRVAL(path))); return; } }