diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index 8e48c80f37b..26eb87ead6c 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -25,6 +25,7 @@ ## Removed - Removed `Phalcon\Plugin` - duplicate of `Phalcon\DI\Injectable` [#14359](https://github.com/phalcon/cphalcon/issues/14359) +- Removed `Phalcon\Mvc\Collection` and all related references. 4.0 will not support mongo as it is being re-implemented to take advantage of the latest Mongo driver (see [#13697](https://github.com/phalcon/cphalcon/issues/13697)) [#14361](https://github.com/phalcon/cphalcon/pull/14361) # [4.0.0-beta.2](https://github.com/phalcon/cphalcon/releases/tag/v4.0.0-beta.2) (2019-08-18) diff --git a/ext/phalcon/mvc/collection.zep.c b/ext/phalcon/mvc/collection.zep.c deleted file mode 100644 index 328bcbbf5f1..00000000000 --- a/ext/phalcon/mvc/collection.zep.c +++ /dev/null @@ -1,2933 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../ext_config.h" -#endif - -#include -#include "../../php_ext.h" -#include "../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/fcall.h" -#include "kernel/exception.h" -#include "kernel/memory.h" -#include "kernel/object.h" -#include "kernel/operators.h" -#include "ext/spl/spl_exceptions.h" -#include "kernel/array.h" -#include "kernel/string.h" -#include "kernel/concat.h" -#include "kernel/iterator.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection - * - * This component implements a high level abstraction for NoSQL databases which - * works with documents - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection) { - - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc, Collection, phalcon, mvc_collection, phalcon_mvc_collection_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("_id"), ZEND_ACC_PUBLIC TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("connection"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("container"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_long(phalcon_mvc_collection_ce, SL("dirtyState"), 1, ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("disableEvents"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("errorMessages"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("modelsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_long(phalcon_mvc_collection_ce, SL("operationMade"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("reserved"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); - - zend_declare_property_bool(phalcon_mvc_collection_ce, SL("skipped"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_ce, SL("source"), ZEND_ACC_PROTECTED TSRMLS_CC); - - phalcon_mvc_collection_ce->create_object = zephir_init_properties_Phalcon_Mvc_Collection; - zephir_declare_class_constant_long(phalcon_mvc_collection_ce, SL("DIRTY_STATE_DETACHED"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_collection_ce, SL("DIRTY_STATE_PERSISTENT"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_collection_ce, SL("DIRTY_STATE_TRANSIENT"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_CREATE"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_DELETE"), 3); - - zephir_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_NONE"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_collection_ce, SL("OP_UPDATE"), 2); - - zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, phalcon_mvc_entityinterface_ce); - zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, phalcon_mvc_collectioninterface_ce); - zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); - zend_class_implements(phalcon_mvc_collection_ce TSRMLS_CC, 1, zend_ce_serializable); - return SUCCESS; - -} - -/** - * Phalcon\Mvc\Collection constructor - */ -PHP_METHOD(Phalcon_Mvc_Collection, __construct) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL, *_3 = NULL; - zval *container = NULL, container_sub, *modelsManager = NULL, modelsManager_sub, __$null, _1$$4, _2$$4, _4$$4, _5$$5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&modelsManager_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, &container, &modelsManager); - - if (!container) { - container = &container_sub; - ZEPHIR_CPY_WRT(container, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(container); - } - if (!modelsManager) { - modelsManager = &modelsManager_sub; - ZEPHIR_CPY_WRT(modelsManager, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(modelsManager); - } - - - if (Z_TYPE_P(container) != IS_OBJECT) { - ZEPHIR_CALL_CE_STATIC(container, phalcon_di_ce, "getdefault", &_0, 0); - zephir_check_call_status(); - } - if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_1$$4); - object_init_ex(&_1$$4, phalcon_mvc_collection_exception_ce); - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, "the services related to the ODM"); - ZEPHIR_CALL_CE_STATIC(&_2$$4, phalcon_mvc_collection_exception_ce, "containerservicenotfound", &_3, 0, &_4$$4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 5, &_2$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Collection.zep", 84 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval(this_ptr, SL("container"), container); - if (Z_TYPE_P(modelsManager) != IS_OBJECT) { - ZEPHIR_INIT_VAR(&_5$$5); - ZVAL_STRING(&_5$$5, "collectionManager"); - ZEPHIR_CALL_METHOD(modelsManager, container, "getshared", NULL, 0, &_5$$5); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(modelsManager) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The injected service 'modelsManager' is not valid", "phalcon/Mvc/Collection.zep", 97); - return; - } - } - zephir_update_property_zval(this_ptr, SL("modelsManager"), modelsManager); - ZEPHIR_CALL_METHOD(NULL, modelsManager, "initialize", NULL, 0, this_ptr); - zephir_check_call_status(); - if ((zephir_method_exists_ex(this_ptr, SL("onconstruct") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); - -} - -/** - * Sets up a behavior in a collection - */ -PHP_METHOD(Phalcon_Mvc_Collection, addBehavior) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *behavior, behavior_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&behavior_sub); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &behavior); - - - - zephir_read_property(&_0, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "addbehavior", NULL, 0, this_ptr, behavior); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Perform an aggregation using the Mongo aggregation framework - */ -PHP_METHOD(Phalcon_Mvc_Collection, aggregate) { - - zend_class_entry *_1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters_param = NULL, *options_param = NULL, className, model, connection, source, _0, _2; - zval parameters, options; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶meters); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 2, ¶meters_param, &options_param); - - if (!parameters_param) { - ZEPHIR_INIT_VAR(¶meters); - array_init(¶meters); - } else { - zephir_get_arrval(¶meters, parameters_param); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - - - ZEPHIR_INIT_VAR(&className); - zephir_get_called_class(&className TSRMLS_CC); - ZEPHIR_INIT_VAR(&model); - zephir_fetch_safe_class(&_0, &className); - _1 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0), Z_STRLEN_P(&_0), ZEND_FETCH_CLASS_AUTO); - if(!_1) { - RETURN_MM_NULL(); - } - object_init_ex(&model, _1); - if (zephir_has_constructor(&model TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &model, "__construct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&connection, &model, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&source))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/Mvc/Collection.zep", 143); - return; - } - ZEPHIR_CALL_METHOD(&_2, &connection, "selectcollection", NULL, 0, &source); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_2, "aggregate", NULL, 0, ¶meters, &options); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Appends a customized message on the validation process - * - *```php - * use \Phalcon\Messages\Message as Message; - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); - * - * $this->appendMessage(message); - * } - * } - * } - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, appendMessage) { - - zval *message, message_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message_sub); - - zephir_fetch_params_without_memory_grow(1, 0, &message); - - - - zephir_update_property_array_append(this_ptr, SL("errorMessages"), message); - -} - -/** - * Returns a cloned collection - */ -PHP_METHOD(Phalcon_Mvc_Collection, cloneResult) { - - zend_string *_3; - zend_ulong _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval document; - zval *collection, collection_sub, *document_param = NULL, clonedCollection, key, value, *_0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&collection_sub); - ZVAL_UNDEF(&clonedCollection); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&document); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &collection, &document_param); - - ZEPHIR_OBS_COPY_OR_DUP(&document, document_param); - - - ZEPHIR_INIT_VAR(&clonedCollection); - if (zephir_clone(&clonedCollection, collection TSRMLS_CC) == FAILURE) { - RETURN_MM(); - } - zephir_is_iterable(&document, 0, "phalcon/Mvc/Collection.zep", 190); - if (Z_TYPE_P(&document) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&document), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZEPHIR_CALL_METHOD(NULL, &clonedCollection, "writeattribute", &_4, 0, &key, &value); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &document, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &document, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &document, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &document, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &clonedCollection, "writeattribute", &_5, 0, &key, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &document, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - if ((zephir_method_exists_ex(&clonedCollection, SL("afterfetch") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, &clonedCollection, "afterfetch", NULL, 0); - zephir_check_call_status(); - } - RETURN_CCTOR(&clonedCollection); - -} - -/** - * Creates a collection based on the values in the attributes - */ -PHP_METHOD(Phalcon_Mvc_Collection, create) { - - zval _5; - zend_bool success = 0, exists = 0, _6; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, data, status, id, ok, collection, _0, _1, _2, _3, _4, _8, _9, _10, _7$$4; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&id); - ZVAL_UNDEF(&ok); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_5); - - ZEPHIR_MM_GROW(); - - ZEPHIR_CALL_METHOD(&collection, this_ptr, "preparecu", NULL, 0); - zephir_check_call_status(); - exists = 0; - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, 1); - zephir_update_property_zval(this_ptr, SL("operationMade"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, SL("errorMessages"), &_1); - zephir_read_property(&_0, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); - zephir_read_static_property_ce(&_3, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - if (exists) { - ZVAL_BOOL(&_4, 1); - } else { - ZVAL_BOOL(&_4, 0); - } - ZEPHIR_CALL_METHOD(&_2, this_ptr, "presave", NULL, 423, &_0, &_3, &_4); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - success = 0; - ZEPHIR_INIT_VAR(&_5); - zephir_create_array(&_5, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_5, SL("w"), &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&status, &collection, "insert", NULL, 0, &data, &_5); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&ok); - _6 = zephir_array_isset_string_fetch(&ok, &status, SL("ok"), 0); - if (_6) { - _6 = zephir_is_true(&ok); - } - if (_6) { - success = 1; - ZEPHIR_OBS_VAR(&id); - if (zephir_array_isset_string_fetch(&id, &data, SL("_id"), 0)) { - zephir_update_property_zval(this_ptr, SL("_id"), &id); - } - ZEPHIR_INIT_ZVAL_NREF(_7$$4); - ZVAL_LONG(&_7$$4, 0); - zephir_update_property_zval(this_ptr, SL("dirtyState"), &_7$$4); - } - zephir_read_static_property_ce(&_8, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - if (success) { - ZVAL_BOOL(&_9, 1); - } else { - ZVAL_BOOL(&_9, 0); - } - if (exists) { - ZVAL_BOOL(&_10, 1); - } else { - ZVAL_BOOL(&_10, 0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "postsave", NULL, 424, &_8, &_9, &_10); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Creates a document based on the values in the attributes, if not found by - * criteria. Preferred way to avoid duplication is to create index o - * attribute - * - * ```php - * $robot = new Robot(); - * - * $robot->name = "MyRobot"; - * $robot->type = "Droid"; - * - * // Create only if robot with same name and type does not exist - * $robot->createIfNotExist( - * [ - * "name", - * "type", - * ] - * ); - * ``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, createIfNotExist) { - - zend_bool exists = 0, success = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *criteria_param = NULL, __$false, __$true, data, keys, query, status, doc, collection, _0, _1, _2, _3, _4, _5, _8, _13, _14, _9$$7, _10$$7, _11$$8, _12$$8; - zval criteria, _6, _7; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&criteria); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_BOOL(&__$false, 0); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&keys); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&doc); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$8); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &criteria_param); - - ZEPHIR_OBS_COPY_OR_DUP(&criteria, criteria_param); - - - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&criteria))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Criteria parameter must be array with one or more attributes of the model", "phalcon/Mvc/Collection.zep", 288); - return; - } - ZEPHIR_CALL_METHOD(&collection, this_ptr, "preparecu", NULL, 0); - zephir_check_call_status(); - exists = 0; - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, 0); - zephir_update_property_zval(this_ptr, SL("operationMade"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, SL("errorMessages"), &_1); - zephir_read_property(&_0, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); - zephir_read_static_property_ce(&_3, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - if (exists) { - ZVAL_BOOL(&_4, 1); - } else { - ZVAL_BOOL(&_4, 0); - } - ZEPHIR_CALL_METHOD(&_2, this_ptr, "presave", NULL, 423, &_0, &_3, &_4); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_FUNCTION(&keys, "array_flip", NULL, 162, &criteria); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_5, "array_diff_key", NULL, 425, &keys, &data); - zephir_check_call_status(); - if (UNEXPECTED(zephir_is_true(&_5))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Criteria parameter must be array with one or more attributes of the model", "phalcon/Mvc/Collection.zep", 326); - return; - } - ZEPHIR_CALL_FUNCTION(&query, "array_intersect_key", NULL, 8, &data, &keys); - zephir_check_call_status(); - success = 0; - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_6, SL("$setOnInsert"), &data, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_7); - zephir_create_array(&_7, 2, 0 TSRMLS_CC); - zephir_array_update_string(&_7, SL("new"), &__$false, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_7, SL("upsert"), &__$true, PH_COPY | PH_SEPARATE); - ZVAL_NULL(&_8); - ZEPHIR_CALL_METHOD(&status, &collection, "findandmodify", NULL, 0, &query, &_6, &_8, &_7); - zephir_check_call_status(); - if (Z_TYPE_P(&status) == IS_NULL) { - ZEPHIR_CALL_METHOD(&doc, &collection, "findone", NULL, 0, &query); - zephir_check_call_status(); - if (Z_TYPE_P(&doc) == IS_ARRAY) { - success = 1; - ZEPHIR_INIT_ZVAL_NREF(_9$$7); - ZVAL_LONG(&_9$$7, 1); - zephir_update_property_zval(this_ptr, SL("operationMade"), &_9$$7); - zephir_array_fetch_string(&_10$$7, &doc, SL("_id"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Collection.zep", 355 TSRMLS_CC); - zephir_update_property_zval(this_ptr, SL("_id"), &_10$$7); - } - } else { - ZEPHIR_INIT_VAR(&_11$$8); - object_init_ex(&_11$$8, phalcon_messages_message_ce); - ZEPHIR_INIT_VAR(&_12$$8); - ZVAL_STRING(&_12$$8, "Document already exists"); - ZEPHIR_CALL_METHOD(NULL, &_11$$8, "__construct", NULL, 4, &_12$$8); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", NULL, 0, &_11$$8); - zephir_check_call_status(); - } - zephir_read_static_property_ce(&_8, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - if (success) { - ZVAL_BOOL(&_13, 1); - } else { - ZVAL_BOOL(&_13, 0); - } - if (exists) { - ZVAL_BOOL(&_14, 1); - } else { - ZVAL_BOOL(&_14, 0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "postsave", NULL, 424, &_8, &_13, &_14); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Perform a count over a collection - * - *```php - * echo "There are ", Robots::count(), " robots"; - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, count) { - - zend_class_entry *_1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters_param = NULL, className, collection, connection, _0; - zval parameters; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶meters); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, ¶meters_param); - - if (!parameters_param) { - ZEPHIR_INIT_VAR(¶meters); - array_init(¶meters); - } else { - zephir_get_arrval(¶meters, parameters_param); - } - - - ZEPHIR_INIT_VAR(&className); - zephir_get_called_class(&className TSRMLS_CC); - ZEPHIR_INIT_VAR(&collection); - zephir_fetch_safe_class(&_0, &className); - _1 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0), Z_STRLEN_P(&_0), ZEND_FETCH_CLASS_AUTO); - if(!_1) { - RETURN_MM_NULL(); - } - object_init_ex(&collection, _1); - if (zephir_has_constructor(&collection TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &collection, "__construct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&connection, &collection, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_SELF("getgroupresultset", NULL, 0, ¶meters, &collection, &connection); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Deletes a model instance. Returning true on success or false otherwise. - * - * ```php - * $robot = Robots::findFirst(); - * - * $robot->delete(); - * - * $robots = Robots::find(); - * - * foreach ($robots as $robot) { - * $robot->delete(); - * } - * ``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, delete) { - - zval _5, _6; - zend_bool success = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, disableEvents, status, id, connection, source, collection, mongoId, ok, _0, _1$$4, _2$$4, _3$$9, _4$$9, _7$$15, _8$$14; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&disableEvents); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&id); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&mongoId); - ZVAL_UNDEF(&ok); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$9); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_7$$15); - ZVAL_UNDEF(&_8$$14); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - - ZEPHIR_MM_GROW(); - - ZEPHIR_OBS_VAR(&id); - if (UNEXPECTED(!(zephir_fetch_property(&id, this_ptr, SL("_id"), PH_SILENT_CC)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The document cannot be deleted because it doesn't exist", "phalcon/Mvc/Collection.zep", 416); - return; - } - ZEPHIR_OBS_VAR(&_0); - zephir_read_static_property_ce(&_0, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC); - ZEPHIR_CPY_WRT(&disableEvents, &_0); - if (!(zephir_is_true(&disableEvents))) { - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "beforeDelete"); - ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "fireeventcancel", NULL, 0, &_2$$4); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$4)) { - RETURN_MM_BOOL(0); - } - } - zephir_read_property(&_0, this_ptr, SL("skipped"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&source))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/Mvc/Collection.zep", 435); - return; - } - ZEPHIR_CALL_METHOD(&collection, &connection, "selectcollection", NULL, 0, &source); - zephir_check_call_status(); - if (Z_TYPE_P(&id) == IS_OBJECT) { - ZEPHIR_CPY_WRT(&mongoId, &id); - } else { - zephir_read_property(&_3$$9, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_4$$9, &_3$$9, "isusingimplicitobjectids", NULL, 0, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&_4$$9)) { - ZEPHIR_INIT_NVAR(&mongoId); - object_init_ex(&mongoId, zephir_get_internal_ce(SL("mongoid"))); - if (zephir_has_constructor(&mongoId TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &mongoId, "__construct", NULL, 0, &id); - zephir_check_call_status(); - } - } else { - ZEPHIR_CPY_WRT(&mongoId, &id); - } - } - success = 0; - ZEPHIR_INIT_VAR(&_5); - zephir_create_array(&_5, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_5, SL("_id"), &mongoId, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_6, SL("w"), &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&status, &collection, "remove", NULL, 0, &_5, &_6); - zephir_check_call_status(); - if (Z_TYPE_P(&status) != IS_ARRAY) { - RETURN_MM_BOOL(0); - } - ZEPHIR_OBS_VAR(&ok); - if (zephir_array_isset_string_fetch(&ok, &status, SL("ok"), 0)) { - if (zephir_is_true(&ok)) { - success = 1; - if (!(zephir_is_true(&disableEvents))) { - ZEPHIR_INIT_VAR(&_7$$15); - ZVAL_STRING(&_7$$15, "afterDelete"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_7$$15); - zephir_check_call_status(); - } - ZEPHIR_INIT_ZVAL_NREF(_8$$14); - ZVAL_LONG(&_8$$14, 2); - zephir_update_property_zval(this_ptr, SL("dirtyState"), &_8$$14); - } - } else { - success = 0; - } - RETURN_MM_BOOL(success); - -} - -/** - * Allows to query a set of records that match the specified conditions - * - * ```php - * // How many robots are there? - * $robots = Robots::find(); - * - * echo "There are ", count($robots), "\n"; - * - * // How many mechanical robots are there? - * $robots = Robots::find( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "There are ", count(robots), "\n"; - * - * // Get and print virtual robots ordered by name - * $robots = Robots::findFirst( - * [ - * [ - * "type" => "virtual" - * ], - * "order" => [ - * "name" => 1, - * ] - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - * // Get first 100 virtual robots ordered by name - * $robots = Robots::find( - * [ - * [ - * "type" => "virtual", - * ], - * "order" => [ - * "name" => 1, - * ], - * "limit" => 100, - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * ``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, find) { - - zend_class_entry *_1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters_param = NULL, className, collection, _0, _2, _3; - zval parameters; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶meters); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, ¶meters_param); - - if (!parameters_param) { - ZEPHIR_INIT_VAR(¶meters); - array_init(¶meters); - } else { - zephir_get_arrval(¶meters, parameters_param); - } - - - ZEPHIR_INIT_VAR(&className); - zephir_get_called_class(&className TSRMLS_CC); - ZEPHIR_INIT_VAR(&collection); - zephir_fetch_safe_class(&_0, &className); - _1 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0), Z_STRLEN_P(&_0), ZEND_FETCH_CLASS_AUTO); - if(!_1) { - RETURN_MM_NULL(); - } - object_init_ex(&collection, _1); - if (zephir_has_constructor(&collection TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &collection, "__construct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&_2, &collection, "getconnection", NULL, 0); - zephir_check_call_status(); - ZVAL_BOOL(&_3, 0); - ZEPHIR_RETURN_CALL_SELF("getresultset", NULL, 0, ¶meters, &collection, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Find a document by its id (_id) - * - * ```php - * // Find user by using \MongoId object - * $user = Users::findById( - * new \MongoId("545eb081631d16153a293a66") - * ); - * - * // Find user by using id as sting - * $user = Users::findById("45cbc4a0e4123f6920000002"); - * - * // Validate input - * if ($user = Users::findById($_POST["id"])) { - * // ... - * } - * ``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, findById) { - - zend_class_entry *_5$$3; - zval _8, _9; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *id, id_sub, className, collection, mongoId, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _6$$3, _7$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&id_sub); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&mongoId); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &id); - - - - if (Z_TYPE_P(id) != IS_OBJECT) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "/^[a-f\\d]{24}$/i"); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "/^[a-f\\d]{24}$/i"); - zephir_preg_match(&_2$$3, &_3$$3, id, &_0$$3, 0, 0 , 0 TSRMLS_CC); - if (!(zephir_is_true(&_2$$3))) { - RETURN_MM_NULL(); - } - ZEPHIR_INIT_VAR(&className); - zephir_get_called_class(&className TSRMLS_CC); - ZEPHIR_INIT_VAR(&collection); - zephir_fetch_safe_class(&_4$$3, &className); - _5$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_4$$3), Z_STRLEN_P(&_4$$3), ZEND_FETCH_CLASS_AUTO); - if(!_5$$3) { - RETURN_MM_NULL(); - } - object_init_ex(&collection, _5$$3); - if (zephir_has_constructor(&collection TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &collection, "__construct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&_6$$3, &collection, "getcollectionmanager", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "isusingimplicitobjectids", NULL, 0, &collection); - zephir_check_call_status(); - if (zephir_is_true(&_7$$3)) { - ZEPHIR_INIT_VAR(&mongoId); - object_init_ex(&mongoId, zephir_get_internal_ce(SL("mongoid"))); - if (zephir_has_constructor(&mongoId TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &mongoId, "__construct", NULL, 0, id); - zephir_check_call_status(); - } - } else { - ZEPHIR_CPY_WRT(&mongoId, id); - } - } else { - ZEPHIR_CPY_WRT(&mongoId, id); - } - ZEPHIR_INIT_VAR(&_8); - zephir_create_array(&_8, 1, 0 TSRMLS_CC); - ZEPHIR_INIT_VAR(&_9); - zephir_create_array(&_9, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_9, SL("_id"), &mongoId, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_8, &_9); - ZEPHIR_RETURN_CALL_SELF("findfirst", NULL, 0, &_8); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Allows to query the first record that match the specified conditions - * - * ```php - * // What's the first robot in the robots table? - * $robot = Robots::findFirst(); - * - * echo "The robot name is ", $robot->name, "\n"; - * - * // What's the first mechanical robot in robots table? - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "The first mechanical robot name is ", $robot->name, "\n"; - * - * // Get first virtual robot ordered by name - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ], - * "order" => [ - * "name" => 1, - * ], - * ] - * ); - * - * echo "The first virtual robot name is ", $robot->name, "\n"; - * - * // Get first robot by id (_id) - * $robot = Robots::findFirst( - * [ - * [ - * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), - * ] - * ] - * ); - * - * echo "The robot id is ", $robot->_id, "\n"; - * ``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, findFirst) { - - zend_class_entry *_1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters_param = NULL, className, collection, connection, _0, _2; - zval parameters; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶meters); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, ¶meters_param); - - if (!parameters_param) { - ZEPHIR_INIT_VAR(¶meters); - array_init(¶meters); - } else { - zephir_get_arrval(¶meters, parameters_param); - } - - - ZEPHIR_INIT_VAR(&className); - zephir_get_called_class(&className TSRMLS_CC); - ZEPHIR_INIT_VAR(&collection); - zephir_fetch_safe_class(&_0, &className); - _1 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0), Z_STRLEN_P(&_0), ZEND_FETCH_CLASS_AUTO); - if(!_1) { - RETURN_MM_NULL(); - } - object_init_ex(&collection, _1); - if (zephir_has_constructor(&collection TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &collection, "__construct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&connection, &collection, "getconnection", NULL, 0); - zephir_check_call_status(); - ZVAL_BOOL(&_2, 1); - ZEPHIR_RETURN_CALL_SELF("getresultset", NULL, 0, ¶meters, &collection, &connection, &_2); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Fires an internal event - */ -PHP_METHOD(Phalcon_Mvc_Collection, fireEvent) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventName_param = NULL, _0; - zval eventName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &eventName_param); - - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_EMPTY_STRING(&eventName); - } - - - if ((zephir_method_exists(this_ptr, &eventName TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &eventName, NULL, 0); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "notifyevent", NULL, 0, &eventName, this_ptr); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Fires an internal event that cancels the operation - */ -PHP_METHOD(Phalcon_Mvc_Collection, fireEventCancel) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventName_param = NULL, _0$$3, _1, _2; - zval eventName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &eventName_param); - - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_EMPTY_STRING(&eventName); - } - - - if ((zephir_method_exists(this_ptr, &eventName TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD_ZVAL(&_0$$3, this_ptr, &eventName, NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_0$$3)) { - RETURN_MM_BOOL(0); - } - } - zephir_read_property(&_1, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2, &_1, "notifyevent", NULL, 0, &eventName, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2)) { - RETURN_MM_BOOL(0); - } - RETURN_MM_BOOL(1); - -} - -/** - * Returns the models manager related to the entity instance - */ -PHP_METHOD(Phalcon_Mvc_Collection, getCollectionManager) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "modelsManager"); - -} - -/** - * Retrieves a database connection - * - * @return \MongoDb - */ -PHP_METHOD(Phalcon_Mvc_Collection, getConnection) { - - zval _0, _1$$3, _2$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - - ZEPHIR_MM_GROW(); - - ZEPHIR_OBS_VAR(&_0); - zephir_read_property(&_0, this_ptr, SL("connection"), PH_NOISY_CC); - if (Z_TYPE_P(&_0) != IS_OBJECT) { - zephir_read_property(&_1$$3, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2$$3, &_1$$3, "getconnection", NULL, 0, this_ptr); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, SL("connection"), &_2$$3); - } - RETURN_MM_MEMBER(getThis(), "connection"); - -} - -/** - * Returns DependencyInjection connection service - */ -PHP_METHOD(Phalcon_Mvc_Collection, getConnectionService) { - - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getconnectionservice", NULL, 0, this_ptr); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Returns the dependency injection container - */ -PHP_METHOD(Phalcon_Mvc_Collection, getDI) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "container"); - -} - -/** - * Returns one of the DIRTY_STATE_* constants telling if the document exists - * in the collection or not - */ -PHP_METHOD(Phalcon_Mvc_Collection, getDirtyState) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "dirtyState"); - -} - -/** - * Returns the custom events manager - */ -PHP_METHOD(Phalcon_Mvc_Collection, getEventsManager) { - - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getcustomeventsmanager", NULL, 0, this_ptr); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Returns the value of the _id property - * - * @return \MongoId - */ -PHP_METHOD(Phalcon_Mvc_Collection, getId) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "_id"); - -} - -/** - * Returns all the validation messages - * - * ```php - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; - * - * $messages = $robot->getMessages(); - * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * ``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, getMessages) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "errorMessages"); - -} - -/** - * Returns an array with reserved properties that cannot be part of the - * insert/update - */ -PHP_METHOD(Phalcon_Mvc_Collection, getReservedAttributes) { - - zval _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, _0, _2; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - - ZEPHIR_MM_GROW(); - - ZEPHIR_OBS_VAR(&_0); - zephir_read_static_property_ce(&_0, phalcon_mvc_collection_ce, SL("reserved"), PH_NOISY_CC); - if (Z_TYPE_P(&_0) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 8, 0 TSRMLS_CC); - zephir_array_update_string(&_1$$3, SL("_connection"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$3, SL("container"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$3, SL("source"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$3, SL("operationMade"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$3, SL("errorMessages"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$3, SL("dirtyState"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$3, SL("modelsManager"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$3, SL("skipped"), &__$true, PH_COPY | PH_SEPARATE); - zend_update_static_property(phalcon_mvc_collection_ce, ZEND_STRL("reserved"), &_1$$3); - } - zephir_read_static_property_ce(&_2, phalcon_mvc_collection_ce, SL("reserved"), PH_NOISY_CC | PH_READONLY); - RETURN_CTOR(&_2); - -} - -/** - * Returns collection name mapped in the model - */ -PHP_METHOD(Phalcon_Mvc_Collection, getSource) { - - zval collection, _0, _1$$3, _2$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, SL("source"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - ZEPHIR_CPY_WRT(&collection, this_ptr); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - zephir_get_class_ns(&_2$$3, &collection, 0 TSRMLS_CC); - zephir_uncamelize(&_1$$3, &_2$$3, NULL ); - zephir_update_property_zval(this_ptr, SL("source"), &_1$$3); - } - RETURN_MM_MEMBER(getThis(), "source"); - -} - -/** - * Reads an attribute value by its name - * - *```php - * echo $robot->readAttribute("name"); - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, readAttribute) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, _0; - zval attribute; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &attribute_param); - - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - ZVAL_EMPTY_STRING(&attribute); - } - - - if (!(zephir_isset_property_zval(this_ptr, &attribute TSRMLS_CC))) { - RETURN_MM_NULL(); - } - ZEPHIR_OBS_VAR(&_0); - zephir_read_property_zval(&_0, this_ptr, &attribute, PH_NOISY_CC); - RETURN_CCTOR(&_0); - -} - -/** - * Creates/Updates a collection based on the values in the attributes - */ -PHP_METHOD(Phalcon_Mvc_Collection, save) { - - zval _6; - zend_bool success = 0, _7; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, exists, data, status, id, ok, collection, _2, _3, _4, _5, _9, _10, _0$$3, _1$$4, _8$$7; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&exists); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&id); - ZVAL_UNDEF(&ok); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_6); - - ZEPHIR_MM_GROW(); - - ZEPHIR_CALL_METHOD(&collection, this_ptr, "preparecu", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&exists, this_ptr, "exists", NULL, 0, &collection); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&exists)) { - ZEPHIR_INIT_ZVAL_NREF(_0$$3); - ZVAL_LONG(&_0$$3, 1); - zephir_update_property_zval(this_ptr, SL("operationMade"), &_0$$3); - } else { - ZEPHIR_INIT_ZVAL_NREF(_1$$4); - ZVAL_LONG(&_1$$4, 2); - zephir_update_property_zval(this_ptr, SL("operationMade"), &_1$$4); - } - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - zephir_update_property_zval(this_ptr, SL("errorMessages"), &_2); - zephir_read_property(&_4, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); - zephir_read_static_property_ce(&_5, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "presave", NULL, 423, &_4, &_5, &exists); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - success = 0; - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_6, SL("w"), &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&status, &collection, "save", NULL, 0, &data, &_6); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&ok); - _7 = zephir_array_isset_string_fetch(&ok, &status, SL("ok"), 0); - if (_7) { - _7 = zephir_is_true(&ok); - } - if (_7) { - success = 1; - if (ZEPHIR_IS_FALSE_IDENTICAL(&exists)) { - ZEPHIR_OBS_VAR(&id); - if (zephir_array_isset_string_fetch(&id, &data, SL("_id"), 0)) { - zephir_update_property_zval(this_ptr, SL("_id"), &id); - } - ZEPHIR_INIT_ZVAL_NREF(_8$$7); - ZVAL_LONG(&_8$$7, 0); - zephir_update_property_zval(this_ptr, SL("dirtyState"), &_8$$7); - } - } - zephir_read_static_property_ce(&_9, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - if (success) { - ZVAL_BOOL(&_10, 1); - } else { - ZVAL_BOOL(&_10, 0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "postsave", NULL, 424, &_9, &_10, &exists); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Serializes the object ignoring connections or protected properties - */ -PHP_METHOD(Phalcon_Mvc_Collection, serialize) { - - zval container, serializer, _1, _2, _6, _3$$4, _4$$4, _5$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - - ZEPHIR_MM_GROW(); - - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_ce, "getdefault", &_0, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Collection.zep", 946); - return; - } - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "serializer"); - ZEPHIR_CALL_METHOD(&_1, &container, "has", NULL, 0, &_2); - zephir_check_call_status(); - if (zephir_is_true(&_1)) { - zephir_read_property(&_3$$4, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_4$$4, &_3$$4, "getshared", NULL, 0, &_5$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_4$$4); - ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &serializer, "setdata", NULL, 0, &_4$$4); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&serializer, "serialize", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_6, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 10, &_6); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Sets the DependencyInjection connection service name - */ -PHP_METHOD(Phalcon_Mvc_Collection, setConnectionService) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connectionService_param = NULL, _0; - zval connectionService; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&connectionService); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &connectionService_param); - - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - ZVAL_EMPTY_STRING(&connectionService); - } - - - zephir_read_property(&_0, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setconnectionservice", NULL, 0, this_ptr, &connectionService); - zephir_check_call_status(); - RETURN_THIS(); - -} - -/** - * Sets the dependency injection container - */ -PHP_METHOD(Phalcon_Mvc_Collection, setDI) { - - zval *container, container_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - - zephir_fetch_params_without_memory_grow(1, 0, &container); - - - - zephir_update_property_zval(this_ptr, SL("container"), container); - -} - -/** - * Sets the dirty state of the object using one of the DIRTY_STATE_* - * constants - */ -PHP_METHOD(Phalcon_Mvc_Collection, setDirtyState) { - - zval *dirtyState_param = NULL, _0; - zend_long dirtyState; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - - zephir_fetch_params_without_memory_grow(1, 0, &dirtyState_param); - - dirtyState = zephir_get_intval(dirtyState_param); - - - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, dirtyState); - zephir_update_property_zval(this_ptr, SL("dirtyState"), &_0); - RETURN_THISW(); - -} - -/** - * Sets a custom events manager - */ -PHP_METHOD(Phalcon_Mvc_Collection, setEventsManager) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventsManager, eventsManager_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventsManager_sub); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &eventsManager); - - - - zephir_read_property(&_0, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setcustomeventsmanager", NULL, 0, this_ptr, eventsManager); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Sets a value for the _id property, creates a MongoId object if needed - * - * @param mixed id - */ -PHP_METHOD(Phalcon_Mvc_Collection, setId) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *id, id_sub, mongoId, _0$$3, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&id_sub); - ZVAL_UNDEF(&mongoId); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &id); - - - - if (Z_TYPE_P(id) != IS_OBJECT) { - zephir_read_property(&_0$$3, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1$$3, &_0$$3, "isusingimplicitobjectids", NULL, 0, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&_1$$3)) { - ZEPHIR_INIT_VAR(&mongoId); - object_init_ex(&mongoId, zephir_get_internal_ce(SL("mongoid"))); - if (zephir_has_constructor(&mongoId TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &mongoId, "__construct", NULL, 0, id); - zephir_check_call_status(); - } - } else { - ZEPHIR_CPY_WRT(&mongoId, id); - } - } else { - ZEPHIR_CPY_WRT(&mongoId, id); - } - zephir_update_property_zval(this_ptr, SL("_id"), &mongoId); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Sets collection name which model should be mapped - */ -PHP_METHOD(Phalcon_Mvc_Collection, setSource) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *source_param = NULL; - zval source; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&source); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &source_param); - - if (UNEXPECTED(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(source_param) == IS_STRING)) { - zephir_get_strval(&source, source_param); - } else { - ZEPHIR_INIT_VAR(&source); - ZVAL_EMPTY_STRING(&source); - } - - - zephir_update_property_zval(this_ptr, SL("source"), &source); - RETURN_THIS(); - -} - -/** - * Skips the current operation forcing a success state - */ -PHP_METHOD(Phalcon_Mvc_Collection, skipOperation) { - - zval *skip_param = NULL, __$true, __$false; - zend_bool skip; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - - zephir_fetch_params_without_memory_grow(1, 0, &skip_param); - - skip = zephir_get_boolval(skip_param); - - - if (skip) { - zephir_update_property_zval(this_ptr, SL("skipped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, SL("skipped"), &__$false); - } - -} - -/** - * Allows to perform a summatory group for a column in the collection - */ -PHP_METHOD(Phalcon_Mvc_Collection, summatory) { - - zend_class_entry *_1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *field_param = NULL, *conditions = NULL, conditions_sub, *finalize = NULL, finalize_sub, __$null, className, model, connection, source, collection, initial, reduce, group, retval, firstRetval, _0, _2, _4$$6; - zval field, _3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&finalize_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&initial); - ZVAL_UNDEF(&reduce); - ZVAL_UNDEF(&group); - ZVAL_UNDEF(&retval); - ZVAL_UNDEF(&firstRetval); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$6); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 2, &field_param, &conditions, &finalize); - - if (UNEXPECTED(Z_TYPE_P(field_param) != IS_STRING && Z_TYPE_P(field_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'field' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(field_param) == IS_STRING)) { - zephir_get_strval(&field, field_param); - } else { - ZEPHIR_INIT_VAR(&field); - ZVAL_EMPTY_STRING(&field); - } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; - } - if (!finalize) { - finalize = &finalize_sub; - finalize = &__$null; - } - - - ZEPHIR_INIT_VAR(&className); - zephir_get_called_class(&className TSRMLS_CC); - ZEPHIR_INIT_VAR(&model); - zephir_fetch_safe_class(&_0, &className); - _1 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0), Z_STRLEN_P(&_0), ZEND_FETCH_CLASS_AUTO); - if(!_1) { - RETURN_MM_NULL(); - } - object_init_ex(&model, _1); - if (zephir_has_constructor(&model TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &model, "__construct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&connection, &model, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&source))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/Mvc/Collection.zep", 1063); - return; - } - ZEPHIR_CALL_METHOD(&collection, &connection, "selectcollection", NULL, 0, &source); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&initial); - zephir_create_array(&initial, 1, 0 TSRMLS_CC); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - zephir_array_update_string(&initial, SL("summatory"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_SVSVSVS(&_3, "function (curr, result) { if (typeof result.summatory[curr.", &field, "] === \"undefined\") { result.summatory[curr.", &field, "] = 1; } else { result.summatory[curr.", &field, "]++; } }"); - ZEPHIR_CPY_WRT(&reduce, &_3); - ZEPHIR_INIT_NVAR(&_2); - array_init(&_2); - ZEPHIR_CALL_METHOD(&group, &collection, "group", NULL, 0, &_2, &initial, &reduce); - zephir_check_call_status(); - if (!(zephir_array_isset_string_fetch(&retval, &group, SL("retval"), 1))) { - array_init(return_value); - RETURN_MM(); - } - if (zephir_array_isset_long_fetch(&firstRetval, &retval, 0, 1 TSRMLS_CC)) { - if (zephir_array_isset_string(&firstRetval, SL("summatory"))) { - zephir_array_fetch_string(&_4$$6, &firstRetval, SL("summatory"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Collection.zep", 1089 TSRMLS_CC); - RETURN_CTOR(&_4$$6); - } - RETURN_CTOR(&firstRetval); - } - RETURN_CTOR(&retval); - -} - -/** - * Returns the instance as an array representation - * - *```php - * print_r( - * $robot->toArray() - * ); - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, toArray) { - - zend_string *_4; - zend_ulong _3; - zval data; - zval reserved, key, value, _0, *_1, _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&reserved); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&data); - - ZEPHIR_MM_GROW(); - - ZEPHIR_CALL_METHOD(&reserved, this_ptr, "getreservedattributes", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&data); - array_init(&data); - ZEPHIR_CALL_FUNCTION(&_0, "get_object_vars", NULL, 214, this_ptr); - zephir_check_call_status(); - zephir_is_iterable(&_0, 0, "phalcon/Mvc/Collection.zep", 1130); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(&key); - if (_4 != NULL) { - ZVAL_STR_COPY(&key, _4); - } else { - ZVAL_LONG(&key, _3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _1); - if (ZEPHIR_IS_STRING(&key, "_id")) { - if (zephir_is_true(&value)) { - zephir_array_update_zval(&data, &key, &value, PH_COPY | PH_SEPARATE); - } - } else if (!(zephir_array_isset(&reserved, &key))) { - zephir_array_update_zval(&data, &key, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &_0, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_0, "current", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&key, "_id")) { - if (zephir_is_true(&value)) { - zephir_array_update_zval(&data, &key, &value, PH_COPY | PH_SEPARATE); - } - } else if (!(zephir_array_isset(&reserved, &key))) { - zephir_array_update_zval(&data, &key, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - RETURN_CTOR(&data); - -} - -/** - * Unserializes the object from a serialized string - */ -PHP_METHOD(Phalcon_Mvc_Collection, unserialize) { - - zend_string *_13$$6; - zend_ulong _12$$6; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL, *_3 = NULL; - zval *data, data_sub, attributes, container, manager, key, value, serializer, _5, _6, _1$$3, _2$$3, _4$$3, _7$$4, _8$$4, _9$$6, *_10$$6, _11$$6; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_11$$6); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &data); - - - - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_ce, "getdefault", &_0, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_collection_exception_ce); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "the services related to the ODM"); - ZEPHIR_CALL_CE_STATIC(&_2$$3, phalcon_mvc_collection_exception_ce, "containerservicenotfound", &_3, 0, &_4$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 5, &_2$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Collection.zep", 1149 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval(this_ptr, SL("container"), &container); - ZEPHIR_INIT_VAR(&_6); - ZVAL_STRING(&_6, "serializer"); - ZEPHIR_CALL_METHOD(&_5, &container, "has", NULL, 0, &_6); - zephir_check_call_status(); - if (zephir_is_true(&_5)) { - ZEPHIR_INIT_VAR(&_8$$4); - ZVAL_STRING(&_8$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_7$$4, &container, "getshared", NULL, 0, &_8$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_7$$4); - ZEPHIR_CALL_METHOD(&attributes, &serializer, "unserialize", NULL, 0, data); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_FUNCTION(&attributes, "unserialize", NULL, 11, data); - zephir_check_call_status(); - } - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_9$$6); - ZVAL_STRING(&_9$$6, "collectionManager"); - ZEPHIR_CALL_METHOD(&manager, &container, "getshared", NULL, 0, &_9$$6); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The injected service 'collectionManager' is not valid", "phalcon/Mvc/Collection.zep", 1173); - return; - } - zephir_update_property_zval(this_ptr, SL("modelsManager"), &manager); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Collection.zep", 1187); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&attributes), _12$$6, _13$$6, _10$$6) - { - ZEPHIR_INIT_NVAR(&key); - if (_13$$6 != NULL) { - ZVAL_STR_COPY(&key, _13$$6); - } else { - ZVAL_LONG(&key, _12$$6); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _10$$6); - zephir_update_property_zval_zval(this_ptr, &key, &value TSRMLS_CC); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11$$6, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &attributes, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &attributes, "current", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &key, &value TSRMLS_CC); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } - ZEPHIR_MM_RESTORE(); - -} - -/** - * Creates/Updates a collection based on the values in the attributes - */ -PHP_METHOD(Phalcon_Mvc_Collection, update) { - - zval _4, _6; - zend_bool success = 0, _7; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, exists, data, status, ok, collection, _0, _1, _2, _3, _5, _8, _9; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&exists); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&ok); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - - ZEPHIR_MM_GROW(); - - ZEPHIR_CALL_METHOD(&collection, this_ptr, "preparecu", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&exists, this_ptr, "exists", NULL, 0, &collection); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&exists))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The document cannot be updated because it doesn't exist", "phalcon/Mvc/Collection.zep", 1208); - return; - } - ZEPHIR_INIT_ZVAL_NREF(_0); - ZVAL_LONG(&_0, 2); - zephir_update_property_zval(this_ptr, SL("operationMade"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, SL("errorMessages"), &_1); - zephir_read_property(&_0, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); - zephir_read_static_property_ce(&_3, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "presave", NULL, 423, &_0, &_3, &exists); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&data, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 1, 0 TSRMLS_CC); - ZEPHIR_OBS_VAR(&_5); - zephir_read_property(&_5, this_ptr, SL("_id"), PH_NOISY_CC); - zephir_array_update_string(&_4, SL("_id"), &_5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_6, SL("w"), &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&status, &collection, "update", NULL, 0, &_4, &data, &_6); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&ok); - _7 = zephir_array_isset_string_fetch(&ok, &status, SL("ok"), 0); - if (_7) { - _7 = zephir_is_true(&ok); - } - if (_7) { - success = 1; - } else { - success = 0; - } - zephir_read_static_property_ce(&_8, phalcon_mvc_collection_ce, SL("disableEvents"), PH_NOISY_CC | PH_READONLY); - if (success) { - ZVAL_BOOL(&_9, 1); - } else { - ZVAL_BOOL(&_9, 0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "postsave", NULL, 424, &_8, &_9, &exists); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Executes validators on every validation call - * - *```php - * use Phalcon\Mvc\Collection; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Collection - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->add( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, validate) { - - zend_object_iterator *_1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *validator, validator_sub, messages, message, _0, _2$$4, _3$$4, _4$$4, _5$$4, _6$$4, _7$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&validator_sub); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &validator); - - - - ZVAL_NULL(&_0); - ZEPHIR_CALL_METHOD(&messages, validator, "validate", NULL, 0, &_0, this_ptr); - zephir_check_call_status(); - if (((Z_TYPE_P(&messages) == IS_TRUE || Z_TYPE_P(&messages) == IS_FALSE) == 1)) { - RETURN_CCTOR(&messages); - } - _1 = zephir_get_iterator(&messages TSRMLS_CC); - _1->funcs->rewind(_1 TSRMLS_CC); - for (;_1->funcs->valid(_1 TSRMLS_CC) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1 TSRMLS_CC)) { - { - ZEPHIR_ITERATOR_COPY(&message, _1); - } - ZEPHIR_INIT_NVAR(&_2$$4); - object_init_ex(&_2$$4, phalcon_messages_message_ce); - ZEPHIR_CALL_METHOD(&_3$$4, &message, "getmessage", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$4, &message, "getfield", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$4, &message, "gettype", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$4, &message, "getcode", NULL, 0); - zephir_check_call_status(); - ZVAL_NULL(&_7$$4); - ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", &_8, 4, &_3$$4, &_4$$4, &_5$$4, &_7$$4, &_6$$4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_9, 0, &_2$$4); - zephir_check_call_status(); - } - zend_iterator_dtor(_1); - RETURN_MM_BOOL(!(zephir_fast_count_int(&messages TSRMLS_CC))); - -} - -/** - * Sets if a model must use implicit objects ids - */ -PHP_METHOD(Phalcon_Mvc_Collection, useImplicitObjectIds) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *useImplicitObjectIds_param = NULL, _0, _1; - zend_bool useImplicitObjectIds; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &useImplicitObjectIds_param); - - useImplicitObjectIds = zephir_get_boolval(useImplicitObjectIds_param); - - - zephir_read_property(&_0, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - if (useImplicitObjectIds) { - ZVAL_BOOL(&_1, 1); - } else { - ZVAL_BOOL(&_1, 0); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "useimplicitobjectids", NULL, 0, this_ptr, &_1); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Writes an attribute value by its name - * - *```php - * $robot->writeAttribute("name", "Rosey"); - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection, writeAttribute) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *value, value_sub; - zval attribute; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value_sub); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &attribute_param, &value); - - zephir_get_strval(&attribute, attribute_param); - - - zephir_update_property_zval_zval(this_ptr, &attribute, value TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Cancel the current operation - */ -PHP_METHOD(Phalcon_Mvc_Collection, cancelOperation) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *disableEvents_param = NULL, eventName, _0; - zend_bool disableEvents; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &disableEvents_param); - - disableEvents = zephir_get_boolval(disableEvents_param); - - - if (disableEvents) { - RETURN_MM_BOOL(0); - } - zephir_read_property(&_0, this_ptr, SL("operationMade"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&eventName); - if (ZEPHIR_IS_LONG(&_0, 3)) { - ZVAL_STRING(&eventName, "notDeleted"); - } else { - ZVAL_STRING(&eventName, "notSaved"); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &eventName); - zephir_check_call_status(); - RETURN_MM_BOOL(1); - -} - -/** - * Checks if the document exists in the collection - * - * @param MongoCollection collection - */ -PHP_METHOD(Phalcon_Mvc_Collection, exists) { - - zval _4; - zend_bool exists = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection, collection_sub, id, mongoId, _2, _3, _0$$5, _1$$5, _5$$9, _6$$10; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&collection_sub); - ZVAL_UNDEF(&id); - ZVAL_UNDEF(&mongoId); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_0$$5); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_6$$10); - ZVAL_UNDEF(&_4); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &collection); - - - - ZEPHIR_OBS_VAR(&id); - if (!(zephir_fetch_property(&id, this_ptr, SL("_id"), PH_SILENT_CC))) { - RETURN_MM_BOOL(0); - } - if (Z_TYPE_P(&id) == IS_OBJECT) { - ZEPHIR_CPY_WRT(&mongoId, &id); - } else { - zephir_read_property(&_0$$5, this_ptr, SL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1$$5, &_0$$5, "isusingimplicitobjectids", NULL, 0, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&_1$$5)) { - ZEPHIR_INIT_NVAR(&mongoId); - object_init_ex(&mongoId, zephir_get_internal_ce(SL("mongoid"))); - if (zephir_has_constructor(&mongoId TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &mongoId, "__construct", NULL, 0, &id); - zephir_check_call_status(); - } - zephir_update_property_zval(this_ptr, SL("_id"), &mongoId); - } else { - ZEPHIR_CPY_WRT(&mongoId, &id); - } - } - zephir_read_property(&_2, this_ptr, SL("dirtyState"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_2))) { - RETURN_MM_BOOL(1); - } - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 1, 0 TSRMLS_CC); - zephir_array_update_string(&_4, SL("_id"), &mongoId, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_3, collection, "count", NULL, 0, &_4); - zephir_check_call_status(); - exists = ZEPHIR_GT_LONG(&_3, 0); - if (exists) { - ZEPHIR_INIT_ZVAL_NREF(_5$$9); - ZVAL_LONG(&_5$$9, 0); - zephir_update_property_zval(this_ptr, SL("dirtyState"), &_5$$9); - } else { - ZEPHIR_INIT_ZVAL_NREF(_6$$10); - ZVAL_LONG(&_6$$10, 1); - zephir_update_property_zval(this_ptr, SL("dirtyState"), &_6$$10); - } - RETURN_MM_BOOL(exists); - -} - -/** - * Perform a count over a resultset - * - * @param array params - * @param \MongoDb connection - */ -PHP_METHOD(Phalcon_Mvc_Collection, getGroupResultset) { - - zend_bool _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *params, params_sub, *collection, collection_sub, *connection, connection_sub, source, mongoCollection, conditions, limit, sort, documentsCursor; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶ms_sub); - ZVAL_UNDEF(&collection_sub); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&mongoCollection); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&sort); - ZVAL_UNDEF(&documentsCursor); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, ¶ms, &collection, &connection); - - - - ZEPHIR_CALL_METHOD(&source, collection, "getsource", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&source))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/Mvc/Collection.zep", 1418); - return; - } - ZEPHIR_CALL_METHOD(&mongoCollection, connection, "selectcollection", NULL, 0, &source); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&conditions); - if (!(zephir_array_isset_long_fetch(&conditions, params, 0, 0 TSRMLS_CC))) { - ZEPHIR_OBS_NVAR(&conditions); - if (!(zephir_array_isset_string_fetch(&conditions, params, SL("conditions"), 0))) { - ZEPHIR_INIT_NVAR(&conditions); - array_init(&conditions); - } - } - _0 = zephir_array_isset_string(params, SL("limit")); - if (!(_0)) { - _0 = zephir_array_isset_string(params, SL("sort")); - } - _1 = _0; - if (!(_1)) { - _1 = zephir_array_isset_string(params, SL("skip")); - } - if (_1) { - ZEPHIR_CALL_METHOD(&documentsCursor, &mongoCollection, "find", NULL, 0, &conditions); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&limit); - if (zephir_array_isset_string_fetch(&limit, params, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &documentsCursor, "limit", NULL, 0, &limit); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&sort); - if (zephir_array_isset_string_fetch(&sort, params, SL("sort"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &documentsCursor, "sort", NULL, 0, &sort); - zephir_check_call_status(); - } - ZEPHIR_OBS_NVAR(&sort); - if (zephir_array_isset_string_fetch(&sort, params, SL("skip"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &documentsCursor, "skip", NULL, 0, &sort); - zephir_check_call_status(); - } - RETURN_MM_LONG(zephir_fast_count_int(&documentsCursor TSRMLS_CC)); - } - ZEPHIR_RETURN_CALL_METHOD(&mongoCollection, "count", NULL, 0, &conditions); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Returns a collection resultset - * - * @param array params - * @param \MongoDb connection - * @return array - */ -PHP_METHOD(Phalcon_Mvc_Collection, getResultset) { - - zend_class_entry *_1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_10 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool unique, _2$$3; - zval *params, params_sub, *collection, collection_sub, *connection, connection_sub, *unique_param = NULL, __$false, source, mongoCollection, conditions, base, documentsCursor, fields, skip, limit, sort, document, collections, className, _6, *_7, _8, _0$$3, _3$$4, _4$$4, _5$$6, _9$$19, _11$$20; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶ms_sub); - ZVAL_UNDEF(&collection_sub); - ZVAL_UNDEF(&connection_sub); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&mongoCollection); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&base); - ZVAL_UNDEF(&documentsCursor); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&skip); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&sort); - ZVAL_UNDEF(&document); - ZVAL_UNDEF(&collections); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_9$$19); - ZVAL_UNDEF(&_11$$20); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 4, 0, ¶ms, &collection, &connection, &unique_param); - - unique = zephir_get_boolval(unique_param); - - - ZEPHIR_OBS_VAR(&className); - if (zephir_array_isset_string_fetch(&className, params, SL("class"), 0)) { - ZEPHIR_INIT_VAR(&base); - zephir_fetch_safe_class(&_0$$3, &className); - _1$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0$$3), Z_STRLEN_P(&_0$$3), ZEND_FETCH_CLASS_AUTO); - if(!_1$$3) { - RETURN_MM_NULL(); - } - object_init_ex(&base, _1$$3); - if (zephir_has_constructor(&base TSRMLS_CC)) { - ZEPHIR_CALL_METHOD(NULL, &base, "__construct", NULL, 0); - zephir_check_call_status(); - } - _2$$3 = zephir_instance_of_ev(&base, phalcon_mvc_collectioninterface_ce TSRMLS_CC); - if (!(_2$$3)) { - _2$$3 = zephir_instance_of_ev(&base, phalcon_mvc_collection_document_ce TSRMLS_CC); - } - if (UNEXPECTED(!(_2$$3))) { - ZEPHIR_INIT_VAR(&_3$$4); - object_init_ex(&_3$$4, phalcon_mvc_collection_exception_ce); - ZEPHIR_INIT_VAR(&_4$$4); - ZEPHIR_CONCAT_SVS(&_4$$4, "Object of class '", &className, "' must be an implementation of Phalcon\\Mvc\\CollectionInterface or an instance of Phalcon\\Mvc\\Collection\\Document"); - ZEPHIR_CALL_METHOD(NULL, &_3$$4, "__construct", NULL, 5, &_4$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$4, "phalcon/Mvc/Collection.zep", 1489 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&base, collection); - } - if (zephir_instance_of_ev(&base, phalcon_mvc_collection_ce TSRMLS_CC)) { - ZVAL_LONG(&_5$$6, 0); - ZEPHIR_CALL_METHOD(NULL, &base, "setdirtystate", NULL, 0, &_5$$6); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&source, collection, "getsource", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&source))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/Mvc/Collection.zep", 1503); - return; - } - ZEPHIR_CALL_METHOD(&mongoCollection, connection, "selectcollection", NULL, 0, &source); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&mongoCollection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Couldn't select mongo collection", "phalcon/Mvc/Collection.zep", 1509); - return; - } - ZEPHIR_OBS_VAR(&conditions); - if (!(zephir_array_isset_long_fetch(&conditions, params, 0, 0 TSRMLS_CC))) { - ZEPHIR_OBS_NVAR(&conditions); - if (!(zephir_array_isset_string_fetch(&conditions, params, SL("conditions"), 0))) { - ZEPHIR_INIT_NVAR(&conditions); - array_init(&conditions); - } - } - if (UNEXPECTED(Z_TYPE_P(&conditions) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Find parameters must be an array", "phalcon/Mvc/Collection.zep", 1522); - return; - } - ZEPHIR_OBS_VAR(&fields); - if (zephir_array_isset_string_fetch(&fields, params, SL("fields"), 0)) { - ZEPHIR_CALL_METHOD(&documentsCursor, &mongoCollection, "find", NULL, 0, &conditions, &fields); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&documentsCursor, &mongoCollection, "find", NULL, 0, &conditions); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&limit); - if (zephir_array_isset_string_fetch(&limit, params, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &documentsCursor, "limit", NULL, 0, &limit); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&sort); - if (zephir_array_isset_string_fetch(&sort, params, SL("sort"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &documentsCursor, "sort", NULL, 0, &sort); - zephir_check_call_status(); - } - ZEPHIR_OBS_VAR(&skip); - if (zephir_array_isset_string_fetch(&skip, params, SL("skip"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &documentsCursor, "skip", NULL, 0, &skip); - zephir_check_call_status(); - } - if (unique) { - ZEPHIR_CALL_METHOD(NULL, &documentsCursor, "rewind", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&document, &documentsCursor, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&document) != IS_ARRAY) { - RETURN_MM_BOOL(0); - } - ZEPHIR_RETURN_CALL_SELF("cloneresult", NULL, 0, &base, &document); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&collections); - array_init(&collections); - ZEPHIR_CALL_FUNCTION(&_6, "iterator_to_array", NULL, 426, &documentsCursor, &__$false); - zephir_check_call_status(); - zephir_is_iterable(&_6, 0, "phalcon/Mvc/Collection.zep", 1584); - if (Z_TYPE_P(&_6) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_6), _7) - { - ZEPHIR_INIT_NVAR(&document); - ZVAL_COPY(&document, _7); - ZEPHIR_CALL_SELF(&_9$$19, "cloneresult", &_10, 0, &base, &document); - zephir_check_call_status(); - zephir_array_append(&collections, &_9$$19, PH_SEPARATE, "phalcon/Mvc/Collection.zep", 1581); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_6, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_8, &_6, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_8)) { - break; - } - ZEPHIR_CALL_METHOD(&document, &_6, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_SELF(&_11$$20, "cloneresult", &_10, 0, &base, &document); - zephir_check_call_status(); - zephir_array_append(&collections, &_11$$20, PH_SEPARATE, "phalcon/Mvc/Collection.zep", 1581); - ZEPHIR_CALL_METHOD(NULL, &_6, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&document); - RETURN_CCTOR(&collections); - -} - -/** - * Executes internal hooks before save a document - */ -PHP_METHOD(Phalcon_Mvc_Collection, preSave) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool disableEvents, exists; - zval *container, container_sub, *disableEvents_param = NULL, *exists_param = NULL, eventName, _3, _4, _0$$3, _1$$3, _2$$3, _5$$9, _6$$10, _7$$10, _8$$10, _9$$10, _10$$10; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_6$$10); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$10); - ZVAL_UNDEF(&_10$$10); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &container, &disableEvents_param, &exists_param); - - disableEvents = zephir_get_boolval(disableEvents_param); - exists = zephir_get_boolval(exists_param); - - - if (!(disableEvents)) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "beforeValidation"); - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "fireeventcancel", NULL, 0, &_1$$3); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_0$$3)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&eventName); - if (!(exists)) { - ZVAL_STRING(&eventName, "beforeValidationOnCreate"); - } else { - ZVAL_STRING(&eventName, "beforeValidationOnUpdate"); - } - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "fireeventcancel", NULL, 0, &eventName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2$$3)) { - RETURN_MM_BOOL(0); - } - } - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "validation"); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "fireeventcancel", NULL, 0, &_4); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3)) { - if (!(disableEvents)) { - ZEPHIR_INIT_VAR(&_5$$9); - ZVAL_STRING(&_5$$9, "onValidationFails"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_5$$9); - zephir_check_call_status(); - } - RETURN_MM_BOOL(0); - } - if (!(disableEvents)) { - ZEPHIR_INIT_NVAR(&eventName); - if (!(exists)) { - ZVAL_STRING(&eventName, "afterValidationOnCreate"); - } else { - ZVAL_STRING(&eventName, "afterValidationOnUpdate"); - } - ZEPHIR_CALL_METHOD(&_6$$10, this_ptr, "fireeventcancel", NULL, 0, &eventName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$10)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&_8$$10); - ZVAL_STRING(&_8$$10, "afterValidation"); - ZEPHIR_CALL_METHOD(&_7$$10, this_ptr, "fireeventcancel", NULL, 0, &_8$$10); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_7$$10)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_NVAR(&_8$$10); - ZVAL_STRING(&_8$$10, "beforeSave"); - ZEPHIR_CALL_METHOD(&_9$$10, this_ptr, "fireeventcancel", NULL, 0, &_8$$10); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_9$$10)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_NVAR(&eventName); - if (exists) { - ZVAL_STRING(&eventName, "beforeUpdate"); - } else { - ZVAL_STRING(&eventName, "beforeCreate"); - } - ZEPHIR_CALL_METHOD(&_10$$10, this_ptr, "fireeventcancel", NULL, 0, &eventName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_10$$10)) { - RETURN_MM_BOOL(0); - } - } - RETURN_MM_BOOL(1); - -} - -/** - * Executes internal events after save a document - */ -PHP_METHOD(Phalcon_Mvc_Collection, postSave) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *disableEvents_param = NULL, *success_param = NULL, *exists_param = NULL, eventName, _0$$4, _1$$3, _2$$5; - zend_bool disableEvents, success, exists; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$5); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &disableEvents_param, &success_param, &exists_param); - - disableEvents = zephir_get_boolval(disableEvents_param); - success = zephir_get_boolval(success_param); - exists = zephir_get_boolval(exists_param); - - - if (!(success)) { - if (!(disableEvents)) { - ZEPHIR_INIT_VAR(&_0$$4); - ZVAL_STRING(&_0$$4, "notSaved"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_0$$4); - zephir_check_call_status(); - } - if (disableEvents) { - ZVAL_BOOL(&_1$$3, 1); - } else { - ZVAL_BOOL(&_1$$3, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0, &_1$$3); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - if (!(disableEvents)) { - ZEPHIR_INIT_VAR(&eventName); - if (exists) { - ZVAL_STRING(&eventName, "afterUpdate"); - } else { - ZVAL_STRING(&eventName, "afterCreate"); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &eventName); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2$$5); - ZVAL_STRING(&_2$$5, "afterSave"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_2$$5); - zephir_check_call_status(); - } - RETURN_MM_BOOL(success); - -} - -/** - * Shared Code for CU Operations - * Prepares Collection - */ -PHP_METHOD(Phalcon_Mvc_Collection, prepareCU) { - - zval container, connection, source, collection, _0, _1$$3, _2$$3, _4$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_3 = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - - ZEPHIR_MM_GROW(); - - zephir_read_property(&_0, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_collection_exception_ce); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "the services related to the ODM"); - ZEPHIR_CALL_CE_STATIC(&_2$$3, phalcon_mvc_collection_exception_ce, "containerservicenotfound", &_3, 0, &_4$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 5, &_2$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Collection.zep", 1709 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&source))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Method getSource() returns empty string", "phalcon/Mvc/Collection.zep", 1714); - return; - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&collection, &connection, "selectcollection", NULL, 0, &source); - zephir_check_call_status(); - RETURN_CCTOR(&collection); - -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Collection(zend_class_entry *class_type TSRMLS_DC) { - - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - ZEPHIR_MM_GROW(); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property(&_0, this_ptr, SL("errorMessages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval(this_ptr, SL("errorMessages"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } - -} - diff --git a/ext/phalcon/mvc/collection.zep.h b/ext/phalcon/mvc/collection.zep.h deleted file mode 100644 index 19816a3bc82..00000000000 --- a/ext/phalcon/mvc/collection.zep.h +++ /dev/null @@ -1,487 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection); - -PHP_METHOD(Phalcon_Mvc_Collection, __construct); -PHP_METHOD(Phalcon_Mvc_Collection, addBehavior); -PHP_METHOD(Phalcon_Mvc_Collection, aggregate); -PHP_METHOD(Phalcon_Mvc_Collection, appendMessage); -PHP_METHOD(Phalcon_Mvc_Collection, cloneResult); -PHP_METHOD(Phalcon_Mvc_Collection, create); -PHP_METHOD(Phalcon_Mvc_Collection, createIfNotExist); -PHP_METHOD(Phalcon_Mvc_Collection, count); -PHP_METHOD(Phalcon_Mvc_Collection, delete); -PHP_METHOD(Phalcon_Mvc_Collection, find); -PHP_METHOD(Phalcon_Mvc_Collection, findById); -PHP_METHOD(Phalcon_Mvc_Collection, findFirst); -PHP_METHOD(Phalcon_Mvc_Collection, fireEvent); -PHP_METHOD(Phalcon_Mvc_Collection, fireEventCancel); -PHP_METHOD(Phalcon_Mvc_Collection, getCollectionManager); -PHP_METHOD(Phalcon_Mvc_Collection, getConnection); -PHP_METHOD(Phalcon_Mvc_Collection, getConnectionService); -PHP_METHOD(Phalcon_Mvc_Collection, getDI); -PHP_METHOD(Phalcon_Mvc_Collection, getDirtyState); -PHP_METHOD(Phalcon_Mvc_Collection, getEventsManager); -PHP_METHOD(Phalcon_Mvc_Collection, getId); -PHP_METHOD(Phalcon_Mvc_Collection, getMessages); -PHP_METHOD(Phalcon_Mvc_Collection, getReservedAttributes); -PHP_METHOD(Phalcon_Mvc_Collection, getSource); -PHP_METHOD(Phalcon_Mvc_Collection, readAttribute); -PHP_METHOD(Phalcon_Mvc_Collection, save); -PHP_METHOD(Phalcon_Mvc_Collection, serialize); -PHP_METHOD(Phalcon_Mvc_Collection, setConnectionService); -PHP_METHOD(Phalcon_Mvc_Collection, setDI); -PHP_METHOD(Phalcon_Mvc_Collection, setDirtyState); -PHP_METHOD(Phalcon_Mvc_Collection, setEventsManager); -PHP_METHOD(Phalcon_Mvc_Collection, setId); -PHP_METHOD(Phalcon_Mvc_Collection, setSource); -PHP_METHOD(Phalcon_Mvc_Collection, skipOperation); -PHP_METHOD(Phalcon_Mvc_Collection, summatory); -PHP_METHOD(Phalcon_Mvc_Collection, toArray); -PHP_METHOD(Phalcon_Mvc_Collection, unserialize); -PHP_METHOD(Phalcon_Mvc_Collection, update); -PHP_METHOD(Phalcon_Mvc_Collection, validate); -PHP_METHOD(Phalcon_Mvc_Collection, useImplicitObjectIds); -PHP_METHOD(Phalcon_Mvc_Collection, writeAttribute); -PHP_METHOD(Phalcon_Mvc_Collection, cancelOperation); -PHP_METHOD(Phalcon_Mvc_Collection, exists); -PHP_METHOD(Phalcon_Mvc_Collection, getGroupResultset); -PHP_METHOD(Phalcon_Mvc_Collection, getResultset); -PHP_METHOD(Phalcon_Mvc_Collection, preSave); -PHP_METHOD(Phalcon_Mvc_Collection, postSave); -PHP_METHOD(Phalcon_Mvc_Collection, prepareCU); -zend_object *zephir_init_properties_Phalcon_Mvc_Collection(zend_class_entry *class_type TSRMLS_DC); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection___construct, 0, 0, 0) - ZEND_ARG_OBJ_INFO(0, container, Phalcon\\Di\\DiInterface, 1) - ZEND_ARG_OBJ_INFO(0, modelsManager, Phalcon\\Mvc\\Collection\\ManagerInterface, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_addbehavior, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, behavior, Phalcon\\Mvc\\Collection\\BehaviorInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_aggregate, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_aggregate, 0, 0, IS_ARRAY, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, parameters, 1) - ZEND_ARG_ARRAY_INFO(0, options, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_appendmessage, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, message, Phalcon\\Messages\\MessageInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_cloneresult, 0, 2, Phalcon\\Mvc\\CollectionInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_cloneresult, 0, 2, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 0) -#endif - ZEND_ARG_OBJ_INFO(0, collection, Phalcon\\Mvc\\CollectionInterface, 0) - ZEND_ARG_ARRAY_INFO(0, document, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_create, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_create, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_createifnotexist, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_createifnotexist, 0, 1, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, criteria, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_count, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_count, 0, 0, IS_LONG, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, parameters, 1) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_delete, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_delete, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_find, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_find, 0, 0, IS_ARRAY, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, parameters, 1) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_findbyid, 0, 1, Phalcon\\Mvc\\CollectionInterface, 1) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_findbyid, 0, 1, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 1) -#endif - ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_findfirst, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_findfirst, 0, 0, IS_ARRAY, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, parameters, 1) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_fireevent, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_fireevent, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_fireeventcancel, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_fireeventcancel, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_getcollectionmanager, 0, 0, Phalcon\\Mvc\\Collection\\ManagerInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getcollectionmanager, 0, 0, IS_OBJECT, "Phalcon\\Mvc\\Collection\\ManagerInterface", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getconnectionservice, 0, 0, IS_STRING, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getconnectionservice, 0, 0, IS_STRING, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_getdi, 0, 0, Phalcon\\Di\\DiInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getdi, 0, 0, IS_OBJECT, "Phalcon\\Di\\DiInterface", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getdirtystate, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getdirtystate, 0, 0, IS_LONG, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_geteventsmanager, 0, 0, Phalcon\\Mvc\\Collection\\ManagerInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_geteventsmanager, 0, 0, IS_OBJECT, "Phalcon\\Mvc\\Collection\\ManagerInterface", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getmessages, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getmessages, 0, 0, IS_ARRAY, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getreservedattributes, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getreservedattributes, 0, 0, IS_ARRAY, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getsource, 0, 0, IS_STRING, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getsource, 0, 0, IS_STRING, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_readattribute, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, attribute, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, attribute) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_save, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_save, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_serialize, 0, 0, IS_STRING, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_serialize, 0, 0, IS_STRING, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_setconnectionservice, 0, 1, Phalcon\\Mvc\\Collection, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_setconnectionservice, 0, 1, IS_OBJECT, "Phalcon\\Mvc\\Collection", 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, connectionService, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, connectionService) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_setdi, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, container, Phalcon\\Di\\DiInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_setdirtystate, 0, 1, Phalcon\\Mvc\\CollectionInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_setdirtystate, 0, 1, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, dirtyState, IS_LONG, 0) -#else - ZEND_ARG_INFO(0, dirtyState) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_seteventsmanager, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, eventsManager, Phalcon\\Mvc\\Collection\\ManagerInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_setid, 0, 0, 1) - ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_setsource, 0, 1, Phalcon\\Mvc\\Collection, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_setsource, 0, 1, IS_OBJECT, "Phalcon\\Mvc\\Collection", 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, source, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, source) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_skipoperation, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, skip, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, skip) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_summatory, 0, 1, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_summatory, 0, 1, IS_ARRAY, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, field) -#endif - ZEND_ARG_INFO(0, conditions) - ZEND_ARG_INFO(0, finalize) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_toarray, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_toarray, 0, 0, IS_ARRAY, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_unserialize, 0, 0, 1) - ZEND_ARG_INFO(0, data) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_update, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_update, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_validate, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_validate, 0, 1, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_OBJ_INFO(0, validator, Phalcon\\Validation\\ValidationInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_useimplicitobjectids, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, useImplicitObjectIds, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, useImplicitObjectIds) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_writeattribute, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, attribute, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, attribute) -#endif - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_canceloperation, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_canceloperation, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, disableEvents, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, disableEvents) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_exists, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_exists, 0, 1, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_INFO(0, collection) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getgroupresultset, 0, 3, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_getgroupresultset, 0, 3, IS_LONG, NULL, 0) -#endif - ZEND_ARG_INFO(0, params) - ZEND_ARG_OBJ_INFO(0, collection, Phalcon\\Mvc\\Collection, 0) - ZEND_ARG_INFO(0, connection) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_getresultset, 0, 0, 4) - ZEND_ARG_INFO(0, params) - ZEND_ARG_OBJ_INFO(0, collection, Phalcon\\Mvc\\CollectionInterface, 0) - ZEND_ARG_INFO(0, connection) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, unique, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, unique) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_presave, 0, 3, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_presave, 0, 3, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_OBJ_INFO(0, container, Phalcon\\Di\\DiInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, disableEvents, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, disableEvents) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, exists, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, exists) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_postsave, 0, 3, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_postsave, 0, 3, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, disableEvents, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, disableEvents) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, success, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, success) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, exists, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, exists) -#endif -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_method_entry) { - PHP_ME(Phalcon_Mvc_Collection, __construct, arginfo_phalcon_mvc_collection___construct, ZEND_ACC_FINAL|ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_ME(Phalcon_Mvc_Collection, addBehavior, arginfo_phalcon_mvc_collection_addbehavior, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, aggregate, arginfo_phalcon_mvc_collection_aggregate, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, appendMessage, arginfo_phalcon_mvc_collection_appendmessage, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, cloneResult, arginfo_phalcon_mvc_collection_cloneresult, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, create, arginfo_phalcon_mvc_collection_create, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, createIfNotExist, arginfo_phalcon_mvc_collection_createifnotexist, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, count, arginfo_phalcon_mvc_collection_count, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, delete, arginfo_phalcon_mvc_collection_delete, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, find, arginfo_phalcon_mvc_collection_find, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, findById, arginfo_phalcon_mvc_collection_findbyid, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, findFirst, arginfo_phalcon_mvc_collection_findfirst, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, fireEvent, arginfo_phalcon_mvc_collection_fireevent, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, fireEventCancel, arginfo_phalcon_mvc_collection_fireeventcancel, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getCollectionManager, arginfo_phalcon_mvc_collection_getcollectionmanager, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getConnection, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getConnectionService, arginfo_phalcon_mvc_collection_getconnectionservice, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getDI, arginfo_phalcon_mvc_collection_getdi, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getDirtyState, arginfo_phalcon_mvc_collection_getdirtystate, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getEventsManager, arginfo_phalcon_mvc_collection_geteventsmanager, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, getId, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getMessages, arginfo_phalcon_mvc_collection_getmessages, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getReservedAttributes, arginfo_phalcon_mvc_collection_getreservedattributes, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, getSource, arginfo_phalcon_mvc_collection_getsource, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, readAttribute, arginfo_phalcon_mvc_collection_readattribute, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, save, arginfo_phalcon_mvc_collection_save, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, serialize, arginfo_phalcon_mvc_collection_serialize, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, setConnectionService, arginfo_phalcon_mvc_collection_setconnectionservice, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, setDI, arginfo_phalcon_mvc_collection_setdi, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, setDirtyState, arginfo_phalcon_mvc_collection_setdirtystate, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, setEventsManager, arginfo_phalcon_mvc_collection_seteventsmanager, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, setId, arginfo_phalcon_mvc_collection_setid, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, setSource, arginfo_phalcon_mvc_collection_setsource, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, skipOperation, arginfo_phalcon_mvc_collection_skipoperation, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, summatory, arginfo_phalcon_mvc_collection_summatory, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, toArray, arginfo_phalcon_mvc_collection_toarray, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, unserialize, arginfo_phalcon_mvc_collection_unserialize, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, update, arginfo_phalcon_mvc_collection_update, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, validate, arginfo_phalcon_mvc_collection_validate, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, useImplicitObjectIds, arginfo_phalcon_mvc_collection_useimplicitobjectids, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, writeAttribute, arginfo_phalcon_mvc_collection_writeattribute, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection, cancelOperation, arginfo_phalcon_mvc_collection_canceloperation, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, exists, arginfo_phalcon_mvc_collection_exists, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, getGroupResultset, arginfo_phalcon_mvc_collection_getgroupresultset, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, getResultset, arginfo_phalcon_mvc_collection_getresultset, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC) - PHP_ME(Phalcon_Mvc_Collection, preSave, arginfo_phalcon_mvc_collection_presave, ZEND_ACC_FINAL|ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, postSave, arginfo_phalcon_mvc_collection_postsave, ZEND_ACC_FINAL|ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection, prepareCU, NULL, ZEND_ACC_PROTECTED) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collection/behavior.zep.c b/ext/phalcon/mvc/collection/behavior.zep.c deleted file mode 100644 index 11d51c09f81..00000000000 --- a/ext/phalcon/mvc/collection/behavior.zep.c +++ /dev/null @@ -1,210 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../ext_config.h" -#endif - -#include -#include "../../../php_ext.h" -#include "../../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/object.h" -#include "kernel/memory.h" -#include "kernel/operators.h" -#include "kernel/array.h" -#include "ext/spl/spl_exceptions.h" -#include "kernel/exception.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\Behavior - * - * This is an optional base class for ORM behaviors - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior) { - - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Collection, Behavior, phalcon, mvc_collection_behavior, phalcon_mvc_collection_behavior_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_mvc_collection_behavior_ce, SL("options"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_class_implements(phalcon_mvc_collection_behavior_ce TSRMLS_CC, 1, phalcon_mvc_collection_behaviorinterface_ce); - return SUCCESS; - -} - -/** - * Phalcon\Mvc\Collection\Behavior - */ -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, __construct) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; - zval options; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&options); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &options_param); - - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - - - zephir_update_property_zval(this_ptr, SL("options"), &options); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Returns the behavior options related to an event - * - * @return array - */ -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, getOptions) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *eventName_param = NULL, options, eventOptions, _0; - zval eventName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&eventOptions); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 0, 1, &eventName_param); - - if (!eventName_param) { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_STRING(&eventName, ""); - } else { - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_EMPTY_STRING(&eventName); - } - } - - - zephir_read_property(&_0, this_ptr, SL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - if (!ZEPHIR_IS_STRING_IDENTICAL(&eventName, "")) { - if (zephir_array_isset_fetch(&eventOptions, &options, &eventName, 1 TSRMLS_CC)) { - RETURN_CTOR(&eventOptions); - } - RETURN_MM_NULL(); - } - RETURN_CCTOR(&options); - -} - -/** - * Acts as fallbacks when a missing method is called on the collection - */ -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, missingMethod) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval arguments; - zval method; - zval *model, model_sub, *method_param = NULL, *arguments_param = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&arguments); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 1, &model, &method_param, &arguments_param); - - zephir_get_strval(&method, method_param); - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); - } else { - zephir_get_arrval(&arguments, arguments_param); - } - - - RETURN_MM_NULL(); - -} - -/** - * Checks whether the behavior must take action on certain event - */ -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, mustTakeAction) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *eventName_param = NULL, _0; - zval eventName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &eventName_param); - - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_EMPTY_STRING(&eventName); - } - - - zephir_read_property(&_0, this_ptr, SL("options"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &eventName)); - -} - -/** - * This method receives the notifications from the EventsManager - */ -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, notify) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *type_param = NULL, *model, model_sub; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &type_param, &model); - - zephir_get_strval(&type, type_param); - - - RETURN_MM_NULL(); - -} - diff --git a/ext/phalcon/mvc/collection/behavior.zep.h b/ext/phalcon/mvc/collection/behavior.zep.h deleted file mode 100644 index 3cbc2872eab..00000000000 --- a/ext/phalcon/mvc/collection/behavior.zep.h +++ /dev/null @@ -1,62 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_behavior_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior); - -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, __construct); -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, getOptions); -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, missingMethod); -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, mustTakeAction); -PHP_METHOD(Phalcon_Mvc_Collection_Behavior, notify); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behavior___construct, 0, 0, 0) - ZEND_ARG_ARRAY_INFO(0, options, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behavior_getoptions, 0, 0, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 1) -#else - ZEND_ARG_INFO(0, eventName) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behavior_missingmethod, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, method) -#endif - ZEND_ARG_ARRAY_INFO(0, arguments, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_behavior_musttakeaction, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_behavior_musttakeaction, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behavior_notify, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, type) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_behavior_method_entry) { - PHP_ME(Phalcon_Mvc_Collection_Behavior, __construct, arginfo_phalcon_mvc_collection_behavior___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) - PHP_ME(Phalcon_Mvc_Collection_Behavior, getOptions, arginfo_phalcon_mvc_collection_behavior_getoptions, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection_Behavior, missingMethod, arginfo_phalcon_mvc_collection_behavior_missingmethod, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Behavior, mustTakeAction, arginfo_phalcon_mvc_collection_behavior_musttakeaction, ZEND_ACC_PROTECTED) - PHP_ME(Phalcon_Mvc_Collection_Behavior, notify, arginfo_phalcon_mvc_collection_behavior_notify, ZEND_ACC_PUBLIC) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collection/behavior/softdelete.zep.c b/ext/phalcon/mvc/collection/behavior/softdelete.zep.c deleted file mode 100644 index 73720f1a0fd..00000000000 --- a/ext/phalcon/mvc/collection/behavior/softdelete.zep.c +++ /dev/null @@ -1,154 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../../ext_config.h" -#endif - -#include -#include "../../../../php_ext.h" -#include "../../../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/operators.h" -#include "kernel/fcall.h" -#include "kernel/array.h" -#include "kernel/memory.h" -#include "kernel/exception.h" -#include "kernel/object.h" -#include "ext/spl/spl_exceptions.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\Behavior\SoftDelete - * - * Instead of permanently delete a record it marks the record as - * deleted changing the value of a flag column - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior_SoftDelete) { - - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Collection\\Behavior, SoftDelete, phalcon, mvc_collection_behavior_softdelete, phalcon_mvc_collection_behavior_ce, phalcon_mvc_collection_behavior_softdelete_method_entry, 0); - - return SUCCESS; - -} - -/** - * Listens for notifications from the models manager - */ -PHP_METHOD(Phalcon_Mvc_Collection_Behavior_SoftDelete, notify) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_7 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *model, model_sub, options, value, field, updateModel, message, _0, _1, _2, _3$$7, *_4$$7, _5$$7; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&updateModel); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_5$$7); - - 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 of the type 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); - } - - - if (!ZEPHIR_IS_STRING_IDENTICAL(&type, "beforeDelete")) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_VAR(&value); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &options, SL("value"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'value' is required", "phalcon/Mvc/Collection/Behavior/SoftDelete.zep", 42); - return; - } - ZEPHIR_OBS_VAR(&field); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'field' is required", "phalcon/Mvc/Collection/Behavior/SoftDelete.zep", 49); - return; - } - ZVAL_BOOL(&_0, 1); - ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, model, "readattribute", NULL, 0, &field); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&_1, &value)) { - RETURN_MM_NULL(); - } - ZEPHIR_INIT_VAR(&updateModel); - if (zephir_clone(&updateModel, model TSRMLS_CC) == FAILURE) { - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &updateModel, "writeattribute", NULL, 0, &field, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, &updateModel, "save", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_2))) { - ZEPHIR_CALL_METHOD(&_3$$7, &updateModel, "getmessages", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_3$$7, 0, "phalcon/Mvc/Collection/Behavior/SoftDelete.zep", 82); - if (Z_TYPE_P(&_3$$7) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3$$7), _4$$7) - { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _4$$7); - ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_6, 0, &message); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$7, &_3$$7, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&message, &_3$$7, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, &message); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&message); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, &value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); - -} - diff --git a/ext/phalcon/mvc/collection/behavior/softdelete.zep.h b/ext/phalcon/mvc/collection/behavior/softdelete.zep.h deleted file mode 100644 index 382a98ea337..00000000000 --- a/ext/phalcon/mvc/collection/behavior/softdelete.zep.h +++ /dev/null @@ -1,20 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_behavior_softdelete_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior_SoftDelete); - -PHP_METHOD(Phalcon_Mvc_Collection_Behavior_SoftDelete, notify); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behavior_softdelete_notify, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, type) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_behavior_softdelete_method_entry) { - PHP_ME(Phalcon_Mvc_Collection_Behavior_SoftDelete, notify, arginfo_phalcon_mvc_collection_behavior_softdelete_notify, ZEND_ACC_PUBLIC) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collection/behavior/timestampable.zep.c b/ext/phalcon/mvc/collection/behavior/timestampable.zep.c deleted file mode 100644 index 8190dad1177..00000000000 --- a/ext/phalcon/mvc/collection/behavior/timestampable.zep.c +++ /dev/null @@ -1,157 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../../ext_config.h" -#endif - -#include -#include "../../../../php_ext.h" -#include "../../../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/memory.h" -#include "kernel/fcall.h" -#include "kernel/operators.h" -#include "kernel/array.h" -#include "kernel/exception.h" -#include "Zend/zend_closures.h" -#include "kernel/object.h" -#include "kernel/time.h" -#include "ext/spl/spl_exceptions.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\Behavior\Timestampable - * - * Allows to automatically update a model’s attribute saving the - * datetime when a record is created or updated - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior_Timestampable) { - - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Collection\\Behavior, Timestampable, phalcon, mvc_collection_behavior_timestampable, phalcon_mvc_collection_behavior_ce, phalcon_mvc_collection_behavior_timestampable_method_entry, 0); - - return SUCCESS; - -} - -/** - * Listens for notifications from the models manager - */ -PHP_METHOD(Phalcon_Mvc_Collection_Behavior_Timestampable, notify) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *model, model_sub, options, timestamp, singleField, field, generator, format, _0, *_1$$12, _2$$12; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(×tamp); - ZVAL_UNDEF(&singleField); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&generator); - ZVAL_UNDEF(&format); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$12); - - 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 of the type 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 (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The option 'field' is required", "phalcon/Mvc/Collection/Behavior/Timestampable.zep", 47); - return; - } - ZEPHIR_INIT_VAR(×tamp); - ZVAL_NULL(×tamp); - ZEPHIR_OBS_VAR(&format); - if (zephir_array_isset_string_fetch(&format, &options, SL("format"), 0)) { - ZEPHIR_CALL_FUNCTION(×tamp, "date", NULL, 420, &format); - zephir_check_call_status(); - } else { - ZEPHIR_OBS_VAR(&generator); - if (zephir_array_isset_string_fetch(&generator, &options, SL("generator"), 0)) { - if (Z_TYPE_P(&generator) == IS_OBJECT) { - if (zephir_instance_of_ev(&generator, zend_ce_closure TSRMLS_CC)) { - ZEPHIR_INIT_NVAR(×tamp); - ZEPHIR_CALL_USER_FUNC(×tamp, &generator); - zephir_check_call_status(); - } - } - } - } - if (Z_TYPE_P(×tamp) == IS_NULL) { - ZEPHIR_INIT_NVAR(×tamp); - zephir_time(×tamp); - } - if (Z_TYPE_P(&field) == IS_ARRAY) { - zephir_is_iterable(&field, 0, "phalcon/Mvc/Collection/Behavior/Timestampable.zep", 85); - if (Z_TYPE_P(&field) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&field), _1$$12) - { - ZEPHIR_INIT_NVAR(&singleField); - ZVAL_COPY(&singleField, _1$$12); - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_3, 0, &singleField, ×tamp); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &field, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$12, &field, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$12)) { - break; - } - ZEPHIR_CALL_METHOD(&singleField, &field, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_4, 0, &singleField, ×tamp); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &field, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&singleField); - } else { - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, ×tamp); - zephir_check_call_status(); - } - } - ZEPHIR_MM_RESTORE(); - -} - diff --git a/ext/phalcon/mvc/collection/behavior/timestampable.zep.h b/ext/phalcon/mvc/collection/behavior/timestampable.zep.h deleted file mode 100644 index c0d1d2092dd..00000000000 --- a/ext/phalcon/mvc/collection/behavior/timestampable.zep.h +++ /dev/null @@ -1,20 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_behavior_timestampable_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Behavior_Timestampable); - -PHP_METHOD(Phalcon_Mvc_Collection_Behavior_Timestampable, notify); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behavior_timestampable_notify, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, type) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_behavior_timestampable_method_entry) { - PHP_ME(Phalcon_Mvc_Collection_Behavior_Timestampable, notify, arginfo_phalcon_mvc_collection_behavior_timestampable_notify, ZEND_ACC_PUBLIC) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collection/behaviorinterface.zep.c b/ext/phalcon/mvc/collection/behaviorinterface.zep.c deleted file mode 100644 index e95b4422918..00000000000 --- a/ext/phalcon/mvc/collection/behaviorinterface.zep.c +++ /dev/null @@ -1,45 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../ext_config.h" -#endif - -#include -#include "../../../php_ext.h" -#include "../../../ext.h" - -#include - -#include "kernel/main.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\BehaviorInterface - * - * Interface for Phalcon\Mvc\Collection\Behavior - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_BehaviorInterface) { - - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Collection, BehaviorInterface, phalcon, mvc_collection_behaviorinterface, phalcon_mvc_collection_behaviorinterface_method_entry); - - return SUCCESS; - -} - -/** - * Calls a method when it's missing in the collection - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_BehaviorInterface, missingMethod); - -/** - * This method receives the notifications from the EventsManager - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_BehaviorInterface, notify); - diff --git a/ext/phalcon/mvc/collection/behaviorinterface.zep.h b/ext/phalcon/mvc/collection/behaviorinterface.zep.h deleted file mode 100644 index 68751b8c2f2..00000000000 --- a/ext/phalcon/mvc/collection/behaviorinterface.zep.h +++ /dev/null @@ -1,29 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_behaviorinterface_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_BehaviorInterface); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behaviorinterface_missingmethod, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, collection, Phalcon\\Mvc\\CollectionInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, method) -#endif - ZEND_ARG_ARRAY_INFO(0, arguments, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_behaviorinterface_notify, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, type) -#endif - ZEND_ARG_OBJ_INFO(0, collection, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_behaviorinterface_method_entry) { - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_BehaviorInterface, missingMethod, arginfo_phalcon_mvc_collection_behaviorinterface_missingmethod) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_BehaviorInterface, notify, arginfo_phalcon_mvc_collection_behaviorinterface_notify) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collection/document.zep.c b/ext/phalcon/mvc/collection/document.zep.c deleted file mode 100644 index 29f0b87cb9d..00000000000 --- a/ext/phalcon/mvc/collection/document.zep.c +++ /dev/null @@ -1,224 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../ext_config.h" -#endif - -#include -#include "../../../php_ext.h" -#include "../../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/array.h" -#include "kernel/memory.h" -#include "kernel/object.h" -#include "kernel/exception.h" -#include "ext/spl/spl_exceptions.h" -#include "kernel/operators.h" -#include "kernel/fcall.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\Document - * - * This component allows Phalcon\Mvc\Collection to return rows without an associated entity. - * This objects implements the ArrayAccess interface to allow access the object as object->x or array[x]. - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Document) { - - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Collection, Document, phalcon, mvc_collection_document, phalcon_mvc_collection_document_method_entry, 0); - - zend_class_implements(phalcon_mvc_collection_document_ce TSRMLS_CC, 1, phalcon_mvc_entityinterface_ce); - zend_class_implements(phalcon_mvc_collection_document_ce TSRMLS_CC, 1, zend_ce_arrayaccess); - return SUCCESS; - -} - -/** - * Returns the value of a field using the ArrayAccess interfase - */ -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetGet) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *index, index_sub, value; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&value); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &index); - - - - ZEPHIR_OBS_VAR(&value); - if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, index, PH_SILENT_CC)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "The index does not exist in the row", "phalcon/Mvc/Collection/Document.zep", 33); - return; - } - RETURN_CCTOR(&value); - -} - -/** - * Checks whether an offset exists in the document - */ -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetExists) { - - zval *index, index_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - - zephir_fetch_params_without_memory_grow(1, 0, &index); - - - - RETURN_BOOL(zephir_isset_property_zval(this_ptr, index TSRMLS_CC)); - -} - -/** - * Change a value using the ArrayAccess interface - */ -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetSet) { - - zval *index, index_sub, *value, value_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&value_sub); - - zephir_fetch_params_without_memory_grow(2, 0, &index, &value); - - - - zephir_update_property_zval_zval(this_ptr, index, value TSRMLS_CC); - -} - -/** - * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface - */ -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetUnset) { - - zval *index, index_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - - zephir_fetch_params_without_memory_grow(1, 0, &index); - - - - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_collection_exception_ce, "The index does not exist in the row", "phalcon/Mvc/Collection/Document.zep", 60); - return; - -} - -/** - * Reads an attribute value by its name - * - *```php - * echo $robot->readAttribute("name"); - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection_Document, readAttribute) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, value; - zval attribute; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &attribute_param); - - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - ZVAL_EMPTY_STRING(&attribute); - } - - - ZEPHIR_OBS_VAR(&value); - if (!(zephir_fetch_property_zval(&value, this_ptr, &attribute, PH_SILENT_CC))) { - RETURN_MM_NULL(); - } - RETURN_CTOR(&value); - -} - -/** - * Returns the instance as an array representation - */ -PHP_METHOD(Phalcon_Mvc_Collection_Document, toArray) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - - ZEPHIR_MM_GROW(); - - ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 214, this_ptr); - zephir_check_call_status(); - RETURN_MM(); - -} - -/** - * Writes an attribute value by its name - * - *```php - * $robot->writeAttribute("name", "Rosey"); - *``` - */ -PHP_METHOD(Phalcon_Mvc_Collection_Document, writeAttribute) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *value, value_sub; - zval attribute; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value_sub); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &attribute_param, &value); - - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - ZVAL_EMPTY_STRING(&attribute); - } - - - zephir_update_property_zval_zval(this_ptr, &attribute, value TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - -} - diff --git a/ext/phalcon/mvc/collection/document.zep.h b/ext/phalcon/mvc/collection/document.zep.h deleted file mode 100644 index 3409c508976..00000000000 --- a/ext/phalcon/mvc/collection/document.zep.h +++ /dev/null @@ -1,68 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_document_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Document); - -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetGet); -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetExists); -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetSet); -PHP_METHOD(Phalcon_Mvc_Collection_Document, offsetUnset); -PHP_METHOD(Phalcon_Mvc_Collection_Document, readAttribute); -PHP_METHOD(Phalcon_Mvc_Collection_Document, toArray); -PHP_METHOD(Phalcon_Mvc_Collection_Document, writeAttribute); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_document_offsetget, 0, 0, 1) - ZEND_ARG_INFO(0, index) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_document_offsetexists, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_document_offsetexists, 0, 1, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_INFO(0, index) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_document_offsetset, 0, 0, 2) - ZEND_ARG_INFO(0, index) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_document_offsetunset, 0, 0, 1) - ZEND_ARG_INFO(0, index) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_document_readattribute, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, attribute, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, attribute) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_document_toarray, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_document_toarray, 0, 0, IS_ARRAY, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_document_writeattribute, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, attribute, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, attribute) -#endif - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_document_method_entry) { - PHP_ME(Phalcon_Mvc_Collection_Document, offsetGet, arginfo_phalcon_mvc_collection_document_offsetget, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Document, offsetExists, arginfo_phalcon_mvc_collection_document_offsetexists, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Document, offsetSet, arginfo_phalcon_mvc_collection_document_offsetset, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Document, offsetUnset, arginfo_phalcon_mvc_collection_document_offsetunset, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Document, readAttribute, arginfo_phalcon_mvc_collection_document_readattribute, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Document, toArray, arginfo_phalcon_mvc_collection_document_toarray, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Document, writeAttribute, arginfo_phalcon_mvc_collection_document_writeattribute, ZEND_ACC_PUBLIC) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collection/exception.zep.c b/ext/phalcon/mvc/collection/exception.zep.c deleted file mode 100644 index d5535c6c6aa..00000000000 --- a/ext/phalcon/mvc/collection/exception.zep.c +++ /dev/null @@ -1,38 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../ext_config.h" -#endif - -#include -#include "../../../php_ext.h" -#include "../../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\Exception - * - * Exceptions thrown in Phalcon\Mvc\Collection\* classes will use this class - * - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Exception) { - - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Collection, Exception, phalcon, mvc_collection_exception, phalcon_exception_ce, NULL, 0); - - return SUCCESS; - -} - diff --git a/ext/phalcon/mvc/collection/exception.zep.h b/ext/phalcon/mvc/collection/exception.zep.h deleted file mode 100644 index 390bad92535..00000000000 --- a/ext/phalcon/mvc/collection/exception.zep.h +++ /dev/null @@ -1,5 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_exception_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Exception); - diff --git a/ext/phalcon/mvc/collection/manager.zep.c b/ext/phalcon/mvc/collection/manager.zep.c deleted file mode 100644 index e2dfa11333b..00000000000 --- a/ext/phalcon/mvc/collection/manager.zep.c +++ /dev/null @@ -1,761 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../ext_config.h" -#endif - -#include -#include "../../../php_ext.h" -#include "../../../ext.h" - -#include -#include -#include - -#include "kernel/main.h" -#include "kernel/object.h" -#include "kernel/memory.h" -#include "kernel/array.h" -#include "kernel/exception.h" -#include "kernel/fcall.h" -#include "kernel/string.h" -#include "ext/spl/spl_exceptions.h" -#include "kernel/operators.h" -#include "kernel/concat.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\Manager - * - * This components controls the initialization of models, keeping record of relations - * between the different models of the application. - * - * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. - * - * ```php - * $di = new \Phalcon\Di(); - * - * $di->set( - * "collectionManager", - * function () { - * return new \Phalcon\Mvc\Collection\Manager(); - * } - * ); - * - * $robot = new Robots($di); - * ``` - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Manager) { - - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Collection, Manager, phalcon, mvc_collection_manager, phalcon_mvc_collection_manager_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("behaviors"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("connectionServices"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("container"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("customEventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("eventsManager"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("implicitObjectsIds"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("initialized"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_null(phalcon_mvc_collection_manager_ce, SL("lastInitialized"), ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_declare_property_string(phalcon_mvc_collection_manager_ce, SL("serviceName"), "mongo", ZEND_ACC_PROTECTED TSRMLS_CC); - - zend_class_implements(phalcon_mvc_collection_manager_ce TSRMLS_CC, 1, phalcon_di_injectionawareinterface_ce); - zend_class_implements(phalcon_mvc_collection_manager_ce TSRMLS_CC, 1, phalcon_events_eventsawareinterface_ce); - return SUCCESS; - -} - -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getServiceName) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "serviceName"); - -} - -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setServiceName) { - - zval *serviceName, serviceName_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&serviceName_sub); - - zephir_fetch_params_without_memory_grow(1, 0, &serviceName); - - - - zephir_update_property_zval(this_ptr, SL("serviceName"), serviceName); - RETURN_THISW(); - -} - -/** - * Binds a behavior to a model - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, addBehavior) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, *behavior, behavior_sub, entityName, modelsBehaviors, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&behavior_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&modelsBehaviors); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &behavior); - - - - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1 TSRMLS_CC); - ZEPHIR_OBS_VAR(&modelsBehaviors); - zephir_read_property(&_0, this_ptr, SL("behaviors"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&modelsBehaviors, &_0, &entityName, 0 TSRMLS_CC))) { - ZEPHIR_INIT_NVAR(&modelsBehaviors); - array_init(&modelsBehaviors); - } - zephir_array_append(&modelsBehaviors, behavior, PH_SEPARATE, "phalcon/Mvc/Collection/Manager.zep", 80); - zephir_update_property_array(this_ptr, SL("behaviors"), &entityName, &modelsBehaviors); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Returns a custom events manager related to a model - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getCustomEventsManager) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, customEventsManager, className, _0, _1$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&customEventsManager); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - - zephir_read_property(&_0, this_ptr, SL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&customEventsManager, &_0); - if (Z_TYPE_P(&customEventsManager) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, model, 1 TSRMLS_CC); - if (zephir_array_isset(&customEventsManager, &className)) { - zephir_array_fetch(&_1$$4, &customEventsManager, &className, PH_NOISY | PH_READONLY, "phalcon/Mvc/Collection/Manager.zep", 99 TSRMLS_CC); - RETURN_CTOR(&_1$$4); - } - } - RETURN_MM_NULL(); - -} - -/** - * Returns the connection related to a model - * - * @return \Mongo - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getConnection) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_3 = NULL; - zval *model, model_sub, service, connectionService, connection, container, entityName, _0, _1$$5, _2$$5, _4$$5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&connectionService); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_4$$5); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - - ZEPHIR_OBS_VAR(&service); - zephir_read_property(&service, this_ptr, SL("serviceName"), PH_NOISY_CC); - ZEPHIR_OBS_VAR(&connectionService); - zephir_read_property(&connectionService, this_ptr, SL("connectionServices"), PH_NOISY_CC); - if (Z_TYPE_P(&connectionService) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 0 TSRMLS_CC); - if (zephir_array_isset(&connectionService, &entityName)) { - ZEPHIR_OBS_NVAR(&service); - zephir_array_fetch(&service, &connectionService, &entityName, PH_NOISY, "phalcon/Mvc/Collection/Manager.zep", 124 TSRMLS_CC); - } - } - zephir_read_property(&_0, this_ptr, SL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_1$$5); - object_init_ex(&_1$$5, phalcon_mvc_collection_exception_ce); - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "the services related to the ORM"); - ZEPHIR_CALL_CE_STATIC(&_2$$5, phalcon_mvc_collection_exception_ce, "containerservicenotfound", &_3, 0, &_4$$5); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$5, "__construct", NULL, 5, &_2$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$5, "phalcon/Mvc/Collection/Manager.zep", 134 TSRMLS_CC); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&connection, &container, "getshared", NULL, 0, &service); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_collection_exception_ce, "Invalid injected connection service", "phalcon/Mvc/Collection/Manager.zep", 142); - return; - } - RETURN_CCTOR(&connection); - -} - -/** - * Gets a connection service for a specific model - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getConnectionService) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, service, entityName, _0, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - - ZEPHIR_OBS_VAR(&service); - zephir_read_property(&service, this_ptr, SL("serviceName"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 0 TSRMLS_CC); - zephir_read_property(&_0, this_ptr, SL("connectionServices"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &entityName)) { - zephir_read_property(&_1$$3, this_ptr, SL("connectionServices"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_OBS_NVAR(&service); - zephir_array_fetch(&service, &_1$$3, &entityName, PH_NOISY, "phalcon/Mvc/Collection/Manager.zep", 158 TSRMLS_CC); - } - RETURN_CCTOR(&service); - -} - -/** - * Returns the DependencyInjector container - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getDI) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "container"); - -} - -/** - * Returns the internal event manager - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getEventsManager) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "eventsManager"); - -} - -/** - * Get the latest initialized model - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getLastInitialized) { - - zval *this_ptr = getThis(); - - - RETURN_MEMBER(getThis(), "lastInitialized"); - -} - -/** - * Checks if a model is using implicit object ids - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, isUsingImplicitObjectIds) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, implicit, _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&implicit); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - - zephir_read_property(&_0, this_ptr, SL("implicitObjectsIds"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 0 TSRMLS_CC); - if (zephir_array_isset_fetch(&implicit, &_0, &_1, 1 TSRMLS_CC)) { - RETURN_CTOR(&implicit); - } - RETURN_MM_BOOL(1); - -} - -/** - * Check whether a model is already initialized - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, isInitialized) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *className_param = NULL, _0, _1; - zval className; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &className_param); - - if (UNEXPECTED(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(className_param) == IS_STRING)) { - zephir_get_strval(&className, className_param); - } else { - ZEPHIR_INIT_VAR(&className); - ZVAL_EMPTY_STRING(&className); - } - - - zephir_read_property(&_0, this_ptr, SL("initialized"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &className); - RETURN_MM_BOOL(zephir_array_isset(&_0, &_1)); - -} - -/** - * Initializes a model in the models manager - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, initialize) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, className, initialized, eventsManager, _0, _1$$3, _2$$5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&initialized); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$5); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 1, 0, &model); - - - - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, model, 1 TSRMLS_CC); - zephir_read_property(&_0, this_ptr, SL("initialized"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&initialized, &_0); - if (!(zephir_array_isset(&initialized, &className))) { - if ((zephir_method_exists_ex(model, SL("initialize") TSRMLS_CC) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0); - zephir_check_call_status(); - } - zephir_read_property(&_1$$3, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_1$$3); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_2$$5); - ZVAL_STRING(&_2$$5, "collectionManager:afterInitialize"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_2$$5, model); - zephir_check_call_status(); - } - zephir_update_property_array(this_ptr, SL("initialized"), &className, model); - zephir_update_property_zval(this_ptr, SL("lastInitialized"), model); - } - ZEPHIR_MM_RESTORE(); - -} - -/** - * Dispatch an event to the listeners and behaviors - * This method expects that the endpoint listeners/behaviors returns true - * meaning that at least one was implemented - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, missingMethod) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval eventName, _4$$9; - zval *model, model_sub, *eventName_param = NULL, *data, data_sub, behaviors, modelsBehaviors, result, eventsManager, behavior, _0, _1$$3, *_2$$4, _3$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&behaviors); - ZVAL_UNDEF(&modelsBehaviors); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&behavior); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_4$$9); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 3, 0, &model, &eventName_param, &data); - - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_EMPTY_STRING(&eventName); - } - - - zephir_read_property(&_0, this_ptr, SL("behaviors"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&behaviors, &_0); - if (Z_TYPE_P(&behaviors) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&modelsBehaviors); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_get_class(&_1$$3, model, 1 TSRMLS_CC); - if (zephir_array_isset_fetch(&modelsBehaviors, &behaviors, &_1$$3, 0 TSRMLS_CC)) { - zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Collection/Manager.zep", 273); - if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$4) - { - ZEPHIR_INIT_NVAR(&behavior); - ZVAL_COPY(&behavior, _2$$4); - ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); - zephir_check_call_status(); - if (Z_TYPE_P(&result) != IS_NULL) { - RETURN_CCTOR(&result); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$4, &modelsBehaviors, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); - zephir_check_call_status(); - if (Z_TYPE_P(&result) != IS_NULL) { - RETURN_CCTOR(&result); - } - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&behavior); - } - } - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_4$$9); - ZEPHIR_CONCAT_SV(&_4$$9, "model:", &eventName); - ZEPHIR_RETURN_CALL_METHOD(&eventsManager, "fire", NULL, 0, &_4$$9, model, data); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_MM_BOOL(0); - -} - -/** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, notifyEvent) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventName_param = NULL, *model, model_sub, behavior, behaviors, modelsBehaviors, eventsManager, status, customEventsManager, _0, _1$$3, *_2$$4, _3$$4, _5$$11; - zval eventName, _4$$9, _6$$12; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_6$$12); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&behavior); - ZVAL_UNDEF(&behaviors); - ZVAL_UNDEF(&modelsBehaviors); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&customEventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$11); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &eventName_param, &model); - - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_EMPTY_STRING(&eventName); - } - - - ZEPHIR_INIT_VAR(&status); - ZVAL_NULL(&status); - zephir_read_property(&_0, this_ptr, SL("behaviors"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&behaviors, &_0); - if (Z_TYPE_P(&behaviors) == IS_ARRAY) { - ZEPHIR_OBS_VAR(&modelsBehaviors); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_get_class(&_1$$3, model, 1 TSRMLS_CC); - if (zephir_array_isset_fetch(&modelsBehaviors, &behaviors, &_1$$3, 0 TSRMLS_CC)) { - zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Collection/Manager.zep", 309); - if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$4) - { - ZEPHIR_INIT_NVAR(&behavior); - ZVAL_COPY(&behavior, _2$$4); - ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$4, &modelsBehaviors, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&behavior); - } - } - zephir_read_property(&_0, this_ptr, SL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_4$$9); - ZEPHIR_CONCAT_SV(&_4$$9, "collection:", &eventName); - ZEPHIR_CALL_METHOD(&status, &eventsManager, "fire", NULL, 0, &_4$$9, model); - zephir_check_call_status(); - if (!(zephir_is_true(&status))) { - RETURN_CCTOR(&status); - } - } - zephir_read_property(&_0, this_ptr, SL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&customEventsManager, &_0); - if (Z_TYPE_P(&customEventsManager) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_5$$11); - zephir_get_class(&_5$$11, model, 1 TSRMLS_CC); - if (zephir_array_isset(&customEventsManager, &_5$$11)) { - ZEPHIR_INIT_VAR(&_6$$12); - ZEPHIR_CONCAT_SV(&_6$$12, "collection:", &eventName); - ZEPHIR_CALL_METHOD(&status, &customEventsManager, "fire", NULL, 0, &_6$$12, model); - zephir_check_call_status(); - if (!(zephir_is_true(&status))) { - RETURN_CCTOR(&status); - } - } - } - RETURN_CCTOR(&status); - -} - -/** - * Sets a custom events manager for a specific model - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setCustomEventsManager) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, *eventsManager, eventsManager_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&eventsManager_sub); - ZVAL_UNDEF(&_0); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &eventsManager); - - - - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 0 TSRMLS_CC); - zephir_update_property_array(this_ptr, SL("customEventsManager"), &_0, eventsManager); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Sets a connection service for a specific model - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setConnectionService) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval connectionService; - zval *model, model_sub, *connectionService_param = NULL, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&connectionService); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &connectionService_param); - - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string") TSRMLS_CC); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - ZVAL_EMPTY_STRING(&connectionService); - } - - - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 0 TSRMLS_CC); - zephir_update_property_array(this_ptr, SL("connectionServices"), &_0, &connectionService); - ZEPHIR_MM_RESTORE(); - -} - -/** - * Sets the DependencyInjector container - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setDI) { - - zval *container, container_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - - zephir_fetch_params_without_memory_grow(1, 0, &container); - - - - zephir_update_property_zval(this_ptr, SL("container"), container); - -} - -/** - * Sets the event manager - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setEventsManager) { - - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventsManager_sub); - - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - - - - zephir_update_property_zval(this_ptr, SL("eventsManager"), eventsManager); - -} - -/** - * Sets whether a model must use implicit objects ids - */ -PHP_METHOD(Phalcon_Mvc_Collection_Manager, useImplicitObjectIds) { - - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool useImplicitObjectIds; - zval *model, model_sub, *useImplicitObjectIds_param = NULL, _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - - ZEPHIR_MM_GROW(); - zephir_fetch_params(1, 2, 0, &model, &useImplicitObjectIds_param); - - useImplicitObjectIds = zephir_get_boolval(useImplicitObjectIds_param); - - - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 0 TSRMLS_CC); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, useImplicitObjectIds); - zephir_update_property_array(this_ptr, SL("implicitObjectsIds"), &_0, &_1); - ZEPHIR_MM_RESTORE(); - -} - diff --git a/ext/phalcon/mvc/collection/manager.zep.h b/ext/phalcon/mvc/collection/manager.zep.h deleted file mode 100644 index daceede24ae..00000000000 --- a/ext/phalcon/mvc/collection/manager.zep.h +++ /dev/null @@ -1,171 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_manager_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_Manager); - -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getServiceName); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setServiceName); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, addBehavior); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getCustomEventsManager); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getConnection); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getConnectionService); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getDI); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getEventsManager); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, getLastInitialized); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, isUsingImplicitObjectIds); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, isInitialized); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, initialize); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, missingMethod); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, notifyEvent); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setCustomEventsManager); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setConnectionService); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setDI); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, setEventsManager); -PHP_METHOD(Phalcon_Mvc_Collection_Manager, useImplicitObjectIds); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_setservicename, 0, 0, 1) - ZEND_ARG_INFO(0, serviceName) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_addbehavior, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) - ZEND_ARG_OBJ_INFO(0, behavior, Phalcon\\Mvc\\Collection\\BehaviorInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_getcustomeventsmanager, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_getconnection, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_getconnectionservice, 0, 1, IS_STRING, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_getconnectionservice, 0, 1, IS_STRING, NULL, 0) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_manager_getdi, 0, 0, Phalcon\\Di\\DiInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_getdi, 0, 0, IS_OBJECT, "Phalcon\\Di\\DiInterface", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_manager_geteventsmanager, 0, 0, Phalcon\\Events\\ManagerInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_geteventsmanager, 0, 0, IS_OBJECT, "Phalcon\\Events\\ManagerInterface", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_manager_getlastinitialized, 0, 0, Phalcon\\Mvc\\CollectionInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_getlastinitialized, 0, 0, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_isusingimplicitobjectids, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_isusingimplicitobjectids, 0, 1, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_isinitialized, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_isinitialized, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, className, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, className) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_initialize, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_missingmethod, 0, 3, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_manager_missingmethod, 0, 3, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif - ZEND_ARG_INFO(0, data) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_notifyevent, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_setcustomeventsmanager, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) - ZEND_ARG_OBJ_INFO(0, eventsManager, Phalcon\\Events\\ManagerInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_setconnectionservice, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, connectionService, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, connectionService) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_setdi, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, container, Phalcon\\Di\\DiInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_seteventsmanager, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, eventsManager, Phalcon\\Events\\ManagerInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_manager_useimplicitobjectids, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, useImplicitObjectIds, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, useImplicitObjectIds) -#endif -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_manager_method_entry) { - PHP_ME(Phalcon_Mvc_Collection_Manager, getServiceName, NULL, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, setServiceName, arginfo_phalcon_mvc_collection_manager_setservicename, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, addBehavior, arginfo_phalcon_mvc_collection_manager_addbehavior, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, getCustomEventsManager, arginfo_phalcon_mvc_collection_manager_getcustomeventsmanager, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, getConnection, arginfo_phalcon_mvc_collection_manager_getconnection, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, getConnectionService, arginfo_phalcon_mvc_collection_manager_getconnectionservice, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, getDI, arginfo_phalcon_mvc_collection_manager_getdi, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, getEventsManager, arginfo_phalcon_mvc_collection_manager_geteventsmanager, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, getLastInitialized, arginfo_phalcon_mvc_collection_manager_getlastinitialized, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, isUsingImplicitObjectIds, arginfo_phalcon_mvc_collection_manager_isusingimplicitobjectids, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, isInitialized, arginfo_phalcon_mvc_collection_manager_isinitialized, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, initialize, arginfo_phalcon_mvc_collection_manager_initialize, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, missingMethod, arginfo_phalcon_mvc_collection_manager_missingmethod, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, notifyEvent, arginfo_phalcon_mvc_collection_manager_notifyevent, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, setCustomEventsManager, arginfo_phalcon_mvc_collection_manager_setcustomeventsmanager, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, setConnectionService, arginfo_phalcon_mvc_collection_manager_setconnectionservice, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, setDI, arginfo_phalcon_mvc_collection_manager_setdi, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, setEventsManager, arginfo_phalcon_mvc_collection_manager_seteventsmanager, ZEND_ACC_PUBLIC) - PHP_ME(Phalcon_Mvc_Collection_Manager, useImplicitObjectIds, arginfo_phalcon_mvc_collection_manager_useimplicitobjectids, ZEND_ACC_PUBLIC) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collection/managerinterface.zep.c b/ext/phalcon/mvc/collection/managerinterface.zep.c deleted file mode 100644 index d9a795c91ad..00000000000 --- a/ext/phalcon/mvc/collection/managerinterface.zep.c +++ /dev/null @@ -1,107 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../../ext_config.h" -#endif - -#include -#include "../../../php_ext.h" -#include "../../../ext.h" - -#include - -#include "kernel/main.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Phalcon\Mvc\Collection\Manager - * - * This components controls the initialization of models, keeping record of relations - * between the different models of the application. - * - * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. - * - * ```php - * $di = new \Phalcon\Di(); - * - * $di->set( - * "collectionManager", - * function() { - * return new \Phalcon\Mvc\Collection\Manager(); - * } - * ); - * - * $robot = new Robots(di); - * ``` - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_ManagerInterface) { - - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Collection, ManagerInterface, phalcon, mvc_collection_managerinterface, phalcon_mvc_collection_managerinterface_method_entry); - - return SUCCESS; - -} - -/** - * Binds a behavior to a collection - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, addBehavior); - -/** - * Returns the connection related to a model - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, getConnection); - -/** - * Returns a custom events manager related to a model - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, getCustomEventsManager); - -/** - * Get the latest initialized model - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, getLastInitialized); - -/** - * Initializes a model in the models manager - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, initialize); - -/** - * Check whether a model is already initialized - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, isInitialized); - -/** - * Checks if a model is using implicit object ids - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, isUsingImplicitObjectIds); - -/** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, notifyEvent); - -/** - * Sets a custom events manager for a specific model - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, setCustomEventsManager); - -/** - * Sets a connection service for a specific model - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, setConnectionService); - -/** - * Sets if a model must use implicit objects ids - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Collection_ManagerInterface, useImplicitObjectIds); - diff --git a/ext/phalcon/mvc/collection/managerinterface.zep.h b/ext/phalcon/mvc/collection/managerinterface.zep.h deleted file mode 100644 index a46355c3d4b..00000000000 --- a/ext/phalcon/mvc/collection/managerinterface.zep.h +++ /dev/null @@ -1,103 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collection_managerinterface_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Collection_ManagerInterface); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_addbehavior, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) - ZEND_ARG_OBJ_INFO(0, behavior, Phalcon\\Mvc\\Collection\\BehaviorInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_getconnection, 0, 1, Phalcon\\Db\\Adapter\\AdapterInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_getconnection, 0, 1, IS_OBJECT, "Phalcon\\Db\\Adapter\\AdapterInterface", 0) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_getcustomeventsmanager, 0, 1, Phalcon\\Events\\ManagerInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_getcustomeventsmanager, 0, 1, IS_OBJECT, "Phalcon\\Events\\ManagerInterface", 0) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_getlastinitialized, 0, 0, Phalcon\\Mvc\\CollectionInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_getlastinitialized, 0, 0, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 0) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_initialize, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_isinitialized, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_isinitialized, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, className, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, className) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_isusingimplicitobjectids, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_isusingimplicitobjectids, 0, 1, _IS_BOOL, NULL, 0) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_notifyevent, 0, 0, 2) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_setcustomeventsmanager, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) - ZEND_ARG_OBJ_INFO(0, eventsManager, Phalcon\\Events\\ManagerInterface, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_setconnectionservice, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, connectionService, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, connectionService) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collection_managerinterface_useimplicitobjectids, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, model, Phalcon\\Mvc\\CollectionInterface, 0) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, useImplicitObjectIds, _IS_BOOL, 0) -#else - ZEND_ARG_INFO(0, useImplicitObjectIds) -#endif -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collection_managerinterface_method_entry) { - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, addBehavior, arginfo_phalcon_mvc_collection_managerinterface_addbehavior) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, getConnection, arginfo_phalcon_mvc_collection_managerinterface_getconnection) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, getCustomEventsManager, arginfo_phalcon_mvc_collection_managerinterface_getcustomeventsmanager) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, getLastInitialized, arginfo_phalcon_mvc_collection_managerinterface_getlastinitialized) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, initialize, arginfo_phalcon_mvc_collection_managerinterface_initialize) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, isInitialized, arginfo_phalcon_mvc_collection_managerinterface_isinitialized) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, isUsingImplicitObjectIds, arginfo_phalcon_mvc_collection_managerinterface_isusingimplicitobjectids) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, notifyEvent, arginfo_phalcon_mvc_collection_managerinterface_notifyevent) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, setCustomEventsManager, arginfo_phalcon_mvc_collection_managerinterface_setcustomeventsmanager) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, setConnectionService, arginfo_phalcon_mvc_collection_managerinterface_setconnectionservice) - PHP_ABSTRACT_ME(Phalcon_Mvc_Collection_ManagerInterface, useImplicitObjectIds, arginfo_phalcon_mvc_collection_managerinterface_useimplicitobjectids) - PHP_FE_END -}; diff --git a/ext/phalcon/mvc/collectioninterface.zep.c b/ext/phalcon/mvc/collectioninterface.zep.c deleted file mode 100644 index 882b7f3ac3d..00000000000 --- a/ext/phalcon/mvc/collectioninterface.zep.c +++ /dev/null @@ -1,146 +0,0 @@ - -#ifdef HAVE_CONFIG_H -#include "../../ext_config.h" -#endif - -#include -#include "../../php_ext.h" -#include "../../ext.h" - -#include - -#include "kernel/main.h" - - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ -/** - * Interface for Phalcon\Mvc\Collection - */ -ZEPHIR_INIT_CLASS(Phalcon_Mvc_CollectionInterface) { - - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, CollectionInterface, phalcon, mvc_collectioninterface, phalcon_mvc_collectioninterface_method_entry); - - return SUCCESS; - -} - -/** - * Appends a customized message on the validation process - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, appendMessage); - -/** - * Returns a cloned collection - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, cloneResult); - -/** - * Perform a count over a collection - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, count); - -/** - * Deletes a model instance. Returning true on success or false otherwise - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, delete); - -/** - * Allows to query a set of records that match the specified conditions - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, find); - -/** - * Find a document by its id - * - * @param string id - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, findById); - -/** - * Allows to query the first record that match the specified conditions - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, findFirst); - -/** - * Fires an event, implicitly calls behaviors and listeners in the events - * manager are notified - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, fireEvent); - -/** - * Fires an event, implicitly listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns bool false - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, fireEventCancel); - -/** - * Retrieves a database connection - * - * @return MongoDb - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getConnection); - -/** - * Returns one of the DIRTY_STATE_* constants telling if the record exists - * in the database or not - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getDirtyState); - -/** - * Returns the value of the _id property - * - * @return MongoId - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getId); - -/** - * Returns all the validation messages - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getMessages); - -/** - * Returns an array with reserved properties that cannot be part of the - * insert/update - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getReservedAttributes); - -/** - * Returns collection name mapped in the model - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, getSource); - -/** - * Creates/Updates a collection based on the values in the attributes - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, save); - -/** - * Sets a service in the services container that returns the Mongo database - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, setConnectionService); - -/** - * Sets the dirty state of the object using one of the DIRTY_STATE_* - * constants - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, setDirtyState); - -/** - * Sets a value for the _id property, creates a MongoId object if needed - * - * @param mixed id - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, setId); - -/** - * Check whether validation process has generated any messages - */ -ZEPHIR_DOC_METHOD(Phalcon_Mvc_CollectionInterface, validationHasFailed); - diff --git a/ext/phalcon/mvc/collectioninterface.zep.h b/ext/phalcon/mvc/collectioninterface.zep.h deleted file mode 100644 index 134cfaa6c85..00000000000 --- a/ext/phalcon/mvc/collectioninterface.zep.h +++ /dev/null @@ -1,170 +0,0 @@ - -extern zend_class_entry *phalcon_mvc_collectioninterface_ce; - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_CollectionInterface); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collectioninterface_appendmessage, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, message, Phalcon\\Messages\\MessageInterface, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collectioninterface_cloneresult, 0, 2, Phalcon\\Mvc\\CollectionInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_cloneresult, 0, 2, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 0) -#endif - ZEND_ARG_OBJ_INFO(0, collection, Phalcon\\Mvc\\CollectionInterface, 0) - ZEND_ARG_ARRAY_INFO(0, document, 0) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_count, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_count, 0, 0, IS_LONG, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, parameters, 1) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_delete, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_delete, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_find, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_find, 0, 0, IS_ARRAY, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, parameters, 1) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collectioninterface_findbyid, 0, 1, Phalcon\\Mvc\\CollectionInterface, 1) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_findbyid, 0, 1, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 1) -#endif - ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_findfirst, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_findfirst, 0, 0, IS_ARRAY, NULL, 0) -#endif - ZEND_ARG_ARRAY_INFO(0, parameters, 1) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_fireevent, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_fireevent, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_fireeventcancel, 0, 1, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_fireeventcancel, 0, 1, _IS_BOOL, NULL, 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, eventName, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, eventName) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getdirtystate, 0, 0, IS_LONG, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getdirtystate, 0, 0, IS_LONG, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getmessages, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getmessages, 0, 0, IS_ARRAY, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getreservedattributes, 0, 0, IS_ARRAY, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getreservedattributes, 0, 0, IS_ARRAY, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getsource, 0, 0, IS_STRING, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_getsource, 0, 0, IS_STRING, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_save, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_save, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collectioninterface_setconnectionservice, 0, 0, 1) -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, connectionService, IS_STRING, 0) -#else - ZEND_ARG_INFO(0, connectionService) -#endif -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_phalcon_mvc_collectioninterface_setdirtystate, 0, 1, Phalcon\\Mvc\\CollectionInterface, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_setdirtystate, 0, 1, IS_OBJECT, "Phalcon\\Mvc\\CollectionInterface", 0) -#endif -#if PHP_VERSION_ID >= 70200 - ZEND_ARG_TYPE_INFO(0, dirtyState, IS_LONG, 0) -#else - ZEND_ARG_INFO(0, dirtyState) -#endif -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_collectioninterface_setid, 0, 0, 1) - ZEND_ARG_INFO(0, id) -ZEND_END_ARG_INFO() - -#if PHP_VERSION_ID >= 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_validationhasfailed, 0, 0, _IS_BOOL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_phalcon_mvc_collectioninterface_validationhasfailed, 0, 0, _IS_BOOL, NULL, 0) -#endif -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(phalcon_mvc_collectioninterface_method_entry) { - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, appendMessage, arginfo_phalcon_mvc_collectioninterface_appendmessage) - ZEND_FENTRY(cloneResult, NULL, arginfo_phalcon_mvc_collectioninterface_cloneresult, ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC) - ZEND_FENTRY(count, NULL, arginfo_phalcon_mvc_collectioninterface_count, ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, delete, arginfo_phalcon_mvc_collectioninterface_delete) - ZEND_FENTRY(find, NULL, arginfo_phalcon_mvc_collectioninterface_find, ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC) - ZEND_FENTRY(findById, NULL, arginfo_phalcon_mvc_collectioninterface_findbyid, ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC) - ZEND_FENTRY(findFirst, NULL, arginfo_phalcon_mvc_collectioninterface_findfirst, ZEND_ACC_STATIC|ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, fireEvent, arginfo_phalcon_mvc_collectioninterface_fireevent) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, fireEventCancel, arginfo_phalcon_mvc_collectioninterface_fireeventcancel) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, getConnection, NULL) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, getDirtyState, arginfo_phalcon_mvc_collectioninterface_getdirtystate) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, getId, NULL) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, getMessages, arginfo_phalcon_mvc_collectioninterface_getmessages) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, getReservedAttributes, arginfo_phalcon_mvc_collectioninterface_getreservedattributes) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, getSource, arginfo_phalcon_mvc_collectioninterface_getsource) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, save, arginfo_phalcon_mvc_collectioninterface_save) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, setConnectionService, arginfo_phalcon_mvc_collectioninterface_setconnectionservice) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, setDirtyState, arginfo_phalcon_mvc_collectioninterface_setdirtystate) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, setId, arginfo_phalcon_mvc_collectioninterface_setid) - PHP_ABSTRACT_ME(Phalcon_Mvc_CollectionInterface, validationHasFailed, arginfo_phalcon_mvc_collectioninterface_validationhasfailed) - PHP_FE_END -}; diff --git a/phalcon/Mvc/Collection.zep b/phalcon/Mvc/Collection.zep deleted file mode 100644 index 42d0213a4ae..00000000000 --- a/phalcon/Mvc/Collection.zep +++ /dev/null @@ -1,1726 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc; - -use Mongo; -use MongoCollection; -use MongoId; -use Phalcon\Di; -use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Messages\MessageInterface; -use Phalcon\Mvc\Collection\BehaviorInterface; -use Phalcon\Mvc\Collection\Document; -use Phalcon\Mvc\Collection\Exception; -use Phalcon\Mvc\Collection\ManagerInterface; -use Phalcon\Messages\Message as Message; -use Phalcon\Validation\ValidationInterface; -use Phalcon\Storage\Serializer\SerializerInterface; -use Serializable; - -/** - * Phalcon\Mvc\Collection - * - * This component implements a high level abstraction for NoSQL databases which - * works with documents - */ -abstract class Collection implements EntityInterface, CollectionInterface, InjectionAwareInterface, Serializable -{ - const DIRTY_STATE_DETACHED = 2; - const DIRTY_STATE_PERSISTENT = 0; - const DIRTY_STATE_TRANSIENT = 1; - const OP_CREATE = 1; - const OP_DELETE = 3; - const OP_NONE = 0; - const OP_UPDATE = 2; - - public _id; - - protected connection; - - protected container; - - protected dirtyState = 1; - - protected static disableEvents; - - protected errorMessages = []; - - protected modelsManager; - - protected operationMade = 0; - - protected static reserved; - - protected skipped = false; - - protected source; - - /** - * Phalcon\Mvc\Collection constructor - */ - final public function __construct( container = null, modelsManager = null) - { - /** - * We use a default DI if the user doesn't define one - */ - if typeof container != "object" { - let container = Di::getDefault(); - } - - if unlikely typeof container != "object" { - throw new Exception( - Exception::containerServiceNotFound( - "the services related to the ODM" - ) - ); - } - - let this->container = container; - - /** - * Inject the manager service from the DI - */ - if typeof modelsManager != "object" { - let modelsManager = container->getShared("collectionManager"); - if unlikely typeof modelsManager != "object" { - throw new Exception( - "The injected service 'modelsManager' is not valid" - ); - } - } - - /** - * Update the models-manager - */ - let this->modelsManager = modelsManager; - - /** - * The manager always initializes the object - */ - modelsManager->initialize(this); - - /** - * This allows the developer to execute initialization stuff every time - * an instance is created - */ - if method_exists(this, "onConstruct") { - this->{"onConstruct"}(); - } - } - - /** - * Sets up a behavior in a collection - */ - protected function addBehavior( behavior) -> void - { - ( this->modelsManager)->addBehavior(this, behavior); - } - - /** - * Perform an aggregation using the Mongo aggregation framework - */ - public static function aggregate(array parameters = null, array options = null) -> array - { - var className, model, connection, source; - - let className = get_called_class(); - - let model = new {className}(); - - let connection = model->getConnection(); - - let source = model->getSource(); - if unlikely empty source { - throw new Exception("Method getSource() returns empty string"); - } - - return connection->selectCollection(source)->aggregate( - parameters, - options - ); - } - - /** - * Appends a customized message on the validation process - * - *```php - * use \Phalcon\Messages\Message as Message; - * - * class Robots extends \Phalcon\Mvc\Model - * { - * public function beforeSave() - * { - * if ($this->name === "Peter") { - * $message = new Message( - * "Sorry, but a robot cannot be named Peter" - * ); - * - * $this->appendMessage(message); - * } - * } - * } - *``` - */ - public function appendMessage( message) - { - let this->errorMessages[] = message; - } - - /** - * Returns a cloned collection - */ - public static function cloneResult( collection, array! document) -> - { - var clonedCollection, key, value; - - let clonedCollection = clone collection; - for key, value in document { - clonedCollection->writeAttribute(key, value); - } - - if method_exists(clonedCollection, "afterFetch") { - clonedCollection->{"afterFetch"}(); - } - - return clonedCollection; - } - - /** - * Creates a collection based on the values in the attributes - */ - public function create() -> bool - { - var data, success, status, id, ok, collection; - bool exists; - - let collection = this->prepareCU(); - - /** - * Check the dirty state of the current operation to update the current - * operation - */ - let exists = false; - let this->operationMade = self::OP_CREATE; - - /** - * The messages added to the validator are reset here - */ - let this->errorMessages = []; - - /** - * Execute the preSave hook - */ - if this->preSave(this->container, self::disableEvents, exists) === false { - return false; - } - - let data = this->toArray(); - - let success = false; - - /** - * We always use safe stores to get the success state - * Save the document - */ - let status = collection->insert( - data, - [ - "w": true - ] - ); - - if fetch ok, status["ok"] && ok { - let success = true; - - if fetch id, data["_id"] { - let this->_id = id; - } - - let this->dirtyState = self::DIRTY_STATE_PERSISTENT; - } - - /** - * Call the postSave hooks - */ - return this->postSave( - self::disableEvents, - success, - exists - ); - } - - /** - * Creates a document based on the values in the attributes, if not found by - * criteria. Preferred way to avoid duplication is to create index o - * attribute - * - * ```php - * $robot = new Robot(); - * - * $robot->name = "MyRobot"; - * $robot->type = "Droid"; - * - * // Create only if robot with same name and type does not exist - * $robot->createIfNotExist( - * [ - * "name", - * "type", - * ] - * ); - * ``` - */ - public function createIfNotExist(array! criteria) -> bool - { - var exists, data, keys, query, success, status, doc, collection; - - if unlikely empty criteria { - throw new Exception( - "Criteria parameter must be array with one or more attributes of the model" - ); - } - - /** - * Choose a collection according to the collection name - */ - let collection = this->prepareCU(); - - /** - * Assume non-existence to fire beforeCreate events - no update does - * occur anyway - */ - let exists = false; - - /** - * Reset current operation - */ - - let this->operationMade = self::OP_NONE; - - /** - * The messages added to the validator are reset here - */ - let this->errorMessages = []; - - /** - * Execute the preSave hook - */ - if this->preSave(this->container, self::disableEvents, exists) === false { - return false; - } - - let keys = array_flip(criteria); - let data = this->toArray(); - - if unlikely array_diff_key(keys, data) { - throw new Exception( - "Criteria parameter must be array with one or more attributes of the model" - ); - } - - let query = array_intersect_key(data, keys); - - let success = false; - - /** - * $setOnInsert in conjunction with upsert ensures creating a new document - * "new": false returns null if new document created, otherwise new or old document could be returned - */ - let status = collection->findAndModify( - query, - [ - "$setOnInsert": data - ], - null, - [ - "new": false, - "upsert": true - ] - ); - - if status == null { - let doc = collection->findOne(query); - - if typeof doc == "array" { - let success = true; - let this->operationMade = self::OP_CREATE; - let this->_id = doc["_id"]; - } - } else { - this->appendMessage( - new Message("Document already exists") - ); - } - - /** - * Call the postSave hooks - */ - return this->postSave( - self::disableEvents, - success, - exists - ); - } - - /** - * Perform a count over a collection - * - *```php - * echo "There are ", Robots::count(), " robots"; - *``` - */ - public static function count(array parameters = null) -> int - { - var className, collection, connection; - - let className = get_called_class(); - - let collection = new {className}(); - - let connection = collection->getConnection(); - - return self::getGroupResultset(parameters, collection, connection); - } - - /** - * Deletes a model instance. Returning true on success or false otherwise. - * - * ```php - * $robot = Robots::findFirst(); - * - * $robot->delete(); - * - * $robots = Robots::find(); - * - * foreach ($robots as $robot) { - * $robot->delete(); - * } - * ``` - */ - public function delete() -> bool - { - var disableEvents, status, id, connection, source, collection, mongoId, - success, ok; - - if unlikely !fetch id, this->_id { - throw new Exception( - "The document cannot be deleted because it doesn't exist" - ); - } - - let disableEvents = self::disableEvents; - - if !disableEvents { - if this->fireEventCancel("beforeDelete") === false { - return false; - } - } - - if this->skipped === true { - return true; - } - - let connection = this->getConnection(); - - let source = this->getSource(); - if unlikely empty source { - throw new Exception("Method getSource() returns empty string"); - } - - /** - * Get the MongoCollection - */ - let collection = connection->selectCollection(source); - - if typeof id == "object" { - let mongoId = id; - } else { - /** - * Is the collection using implicit object Ids? - */ - if this->modelsManager->isUsingImplicitObjectIds(this) { - let mongoId = new MongoId(id); - } else { - let mongoId = id; - } - } - - let success = false; - - /** - * Remove the instance - */ - let status = collection->remove( - [ - "_id": mongoId - ], - [ - "w": true - ] - ); - - if typeof status != "array" { - return false; - } - - /** - * Check the operation status - */ - if fetch ok, status["ok"] { - if ok { - let success = true; - - if !disableEvents { - this->fireEvent("afterDelete"); - } - - let this->dirtyState = self::DIRTY_STATE_DETACHED; - } - } else { - let success = false; - } - - return success; - } - - /** - * Allows to query a set of records that match the specified conditions - * - * ```php - * // How many robots are there? - * $robots = Robots::find(); - * - * echo "There are ", count($robots), "\n"; - * - * // How many mechanical robots are there? - * $robots = Robots::find( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "There are ", count(robots), "\n"; - * - * // Get and print virtual robots ordered by name - * $robots = Robots::findFirst( - * [ - * [ - * "type" => "virtual" - * ], - * "order" => [ - * "name" => 1, - * ] - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * - * // Get first 100 virtual robots ordered by name - * $robots = Robots::find( - * [ - * [ - * "type" => "virtual", - * ], - * "order" => [ - * "name" => 1, - * ], - * "limit" => 100, - * ] - * ); - * - * foreach ($robots as $robot) { - * echo $robot->name, "\n"; - * } - * ``` - */ - public static function find(array parameters = null) -> array - { - var className, collection; - - let className = get_called_class(); - let collection = new {className}(); - - return self::getResultset( - parameters, - collection, - collection->getConnection(), - false - ); - } - - /** - * Find a document by its id (_id) - * - * ```php - * // Find user by using \MongoId object - * $user = Users::findById( - * new \MongoId("545eb081631d16153a293a66") - * ); - * - * // Find user by using id as sting - * $user = Users::findById("45cbc4a0e4123f6920000002"); - * - * // Validate input - * if ($user = Users::findById($_POST["id"])) { - * // ... - * } - * ``` - */ - public static function findById(var id) -> | null - { - var className, collection, mongoId; - - if typeof id != "object" { - if !preg_match("/^[a-f\d]{24}$/i", id) { - return null; - } - - let className = get_called_class(); - - let collection = new {className}(); - - /** - * Check if the model use implicit ids - */ - if collection->getCollectionManager()->isUsingImplicitObjectIds(collection) { - let mongoId = new MongoId(id); - } else { - let mongoId = id; - } - } else { - let mongoId = id; - } - - return self::findFirst( - [ - [ - "_id": mongoId - ] - ] - ); - } - - /** - * Allows to query the first record that match the specified conditions - * - * ```php - * // What's the first robot in the robots table? - * $robot = Robots::findFirst(); - * - * echo "The robot name is ", $robot->name, "\n"; - * - * // What's the first mechanical robot in robots table? - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ] - * ] - * ); - * - * echo "The first mechanical robot name is ", $robot->name, "\n"; - * - * // Get first virtual robot ordered by name - * $robot = Robots::findFirst( - * [ - * [ - * "type" => "mechanical", - * ], - * "order" => [ - * "name" => 1, - * ], - * ] - * ); - * - * echo "The first virtual robot name is ", $robot->name, "\n"; - * - * // Get first robot by id (_id) - * $robot = Robots::findFirst( - * [ - * [ - * "_id" => new \MongoId("45cbc4a0e4123f6920000002"), - * ] - * ] - * ); - * - * echo "The robot id is ", $robot->_id, "\n"; - * ``` - */ - public static function findFirst(array parameters = null) -> array - { - var className, collection, connection; - - let className = get_called_class(); - - let collection = new {className}(); - - let connection = collection->getConnection(); - - return self::getResultset(parameters, collection, connection, true); - } - - /** - * Fires an internal event - */ - public function fireEvent(string! eventName) -> bool - { - /** - * Check if there is a method with the same name of the event - */ - if method_exists(this, eventName) { - this->{eventName}(); - } - - /** - * Send a notification to the events manager - */ - return this->modelsManager->notifyEvent(eventName, this); - } - - /** - * Fires an internal event that cancels the operation - */ - public function fireEventCancel(string! eventName) -> bool - { - /** - * Check if there is a method with the same name of the event - */ - if method_exists(this, eventName) { - if this->{eventName}() === false { - return false; - } - } - - /** - * Send a notification to the events manager - */ - if this->modelsManager->notifyEvent(eventName, this) === false { - return false; - } - - return true; - } - - /** - * Returns the models manager related to the entity instance - */ - public function getCollectionManager() -> - { - return this->modelsManager; - } - - /** - * Retrieves a database connection - * - * @return \MongoDb - */ - public function getConnection() - { - if typeof this->connection != "object" { - let this->connection = this->modelsManager->getConnection(this); - } - - return this->connection; - } - - /** - * Returns DependencyInjection connection service - */ - public function getConnectionService() -> string - { - return this->modelsManager->getConnectionService(this); - } - - /** - * Returns the dependency injection container - */ - public function getDI() -> - { - return this->container; - } - - /** - * Returns one of the DIRTY_STATE_* constants telling if the document exists - * in the collection or not - */ - public function getDirtyState() -> int - { - return this->dirtyState; - } - - /** - * Returns the custom events manager - */ - protected function getEventsManager() -> - { - return this->modelsManager->getCustomEventsManager(this); - } - - /** - * Returns the value of the _id property - * - * @return \MongoId - */ - public function getId() - { - return this->_id; - } - - /** - * Returns all the validation messages - * - * ```php - * $robot = new Robots(); - * - * $robot->type = "mechanical"; - * $robot->name = "Astro Boy"; - * $robot->year = 1952; - * - * if ($robot->save() === false) { - * echo "Umh, We can't store robots right now "; - * - * $messages = $robot->getMessages(); - * - * foreach ($messages as $message) { - * echo $message; - * } - * } else { - * echo "Great, a new robot was saved successfully!"; - * } - * ``` - */ - public function getMessages() -> - { - return this->errorMessages; - } - - /** - * Returns an array with reserved properties that cannot be part of the - * insert/update - */ - public function getReservedAttributes() -> array - { - if typeof self::reserved != "array" { - let self::reserved = [ - "_connection" : true, - "container" : true, - "source" : true, - "operationMade" : true, - "errorMessages" : true, - "dirtyState" : true, - "modelsManager" : true, - "skipped" : true - ]; - } - - return self::reserved; - } - - /** - * Returns collection name mapped in the model - */ - public function getSource() -> string - { - var collection; - - if !this->source { - let collection = this; - let this->source = uncamelize(get_class_ns(collection)); - } - - return this->source; - } - - /** - * Reads an attribute value by its name - * - *```php - * echo $robot->readAttribute("name"); - *``` - */ - public function readAttribute(string! attribute) -> var | null - { - if !isset this->{attribute} { - return null; - } - - return this->{attribute}; - } - - /** - * Creates/Updates a collection based on the values in the attributes - */ - public function save() -> bool - { - var exists, data, success, status, id, ok, collection; - - let collection = this->prepareCU(); - - /** - * Check the dirty state of the current operation to update the current - * operation - */ - let exists = this->exists(collection); - - if exists === false { - let this->operationMade = self::OP_CREATE; - } else { - let this->operationMade = self::OP_UPDATE; - } - - /** - * The messages added to the validator are reset here - */ - let this->errorMessages = []; - - /** - * Execute the preSave hook - */ - if this->preSave(this->container, self::disableEvents, exists) === false { - return false; - } - - let data = this->toArray(); - - let success = false; - - /** - * We always use safe stores to get the success state - * Save the document - */ - let status = collection->save( - data, - [ - "w": true - ] - ); - - if fetch ok, status["ok"] && ok { - let success = true; - - if exists === false { - if fetch id, data["_id"] { - let this->_id = id; - } - - let this->dirtyState = self::DIRTY_STATE_PERSISTENT; - } - } - - /** - * Call the postSave hooks - */ - return this->postSave( - self::disableEvents, - success, - exists - ); - } - - /** - * Serializes the object ignoring connections or protected properties - */ - public function serialize() -> string - { - var container, serializer; - - /** - * Obtain the default DI - */ - let container = Di::getDefault(); - if unlikely typeof container != "object" { - throw new Exception( - "The dependency injector container is not valid" - ); - } - - if container->has("serializer") { - let serializer = this->container->getShared("serializer"); - - serializer->setData( - this->toArray() - ); - - return serializer->serialize(); - } - - /** - * Use the standard serialize function to serialize the array data - */ - return serialize( - this->toArray() - ); - } - - /** - * Sets the DependencyInjection connection service name - */ - public function setConnectionService(string! connectionService) -> - { - this->modelsManager->setConnectionService(this, connectionService); - - return this; - } - - /** - * Sets the dependency injection container - */ - public function setDI( container) -> void - { - let this->container = container; - } - - /** - * Sets the dirty state of the object using one of the DIRTY_STATE_* - * constants - */ - public function setDirtyState(int dirtyState) -> - { - let this->dirtyState = dirtyState; - - return this; - } - - /** - * Sets a custom events manager - */ - protected function setEventsManager( eventsManager) -> void - { - this->modelsManager->setCustomEventsManager(this, eventsManager); - } - - /** - * Sets a value for the _id property, creates a MongoId object if needed - * - * @param mixed id - */ - public function setId(id) - { - var mongoId; - - if typeof id != "object" { - /** - * Check if the model use implicit ids - */ - if this->modelsManager->isUsingImplicitObjectIds(this) { - let mongoId = new MongoId(id); - } else { - let mongoId = id; - } - } else { - let mongoId = id; - } - - let this->_id = mongoId; - } - - /** - * Sets collection name which model should be mapped - */ - protected function setSource(string! source) -> - { - let this->source = source; - - return this; - } - - /** - * Skips the current operation forcing a success state - */ - public function skipOperation(bool skip) - { - let this->skipped = skip; - } - - /** - * Allows to perform a summatory group for a column in the collection - */ - public static function summatory(string! field, conditions = null, finalize = null) -> array - { - var className, model, connection, source, collection, initial, - reduce, group, retval, firstRetval; - - let className = get_called_class(); - - let model = new {className}(); - - let connection = model->getConnection(); - - let source = model->getSource(); - if unlikely empty source { - throw new Exception("Method getSource() returns empty string"); - } - - let collection = connection->selectCollection(source); - - /** - * Uses a javascript hash to group the results - */ - let initial = [ - "summatory": [] - ]; - - /** - * Uses a javascript hash to group the results, however this is slow - * with larger datasets - */ - let reduce = "function (curr, result) { if (typeof result.summatory[curr." . field . "] === \"undefined\") { result.summatory[curr." . field . "] = 1; } else { result.summatory[curr." . field . "]++; } }"; - - let group = collection->group([], initial, reduce); - - if !fetch retval, group["retval"] { - return []; - } - - if fetch firstRetval, retval[0] { - if isset firstRetval["summatory"] { - return firstRetval["summatory"]; - } - - return firstRetval; - } - - return retval; - } - - /** - * Returns the instance as an array representation - * - *```php - * print_r( - * $robot->toArray() - * ); - *``` - */ - public function toArray() -> array - { - var reserved, key, value; - array data; - - let reserved = this->getReservedAttributes(); - - /** - * Get an array with the values of the object - * We only assign values to the public properties - */ - let data = []; - - for key, value in get_object_vars(this) { - if key == "_id" { - if value { - let data[key] = value; - } - } elseif !isset reserved[key] { - let data[key] = value; - } - } - - return data; - } - - /** - * Unserializes the object from a serialized string - */ - public function unserialize(var data) - { - var attributes, container, manager, key, value, serializer; - - /** - * Obtain the default DI - */ - let container = Di::getDefault(); - if unlikely typeof container != "object" { - throw new Exception( - Exception::containerServiceNotFound( - "the services related to the ODM" - ) - ); - } - - /** - * Update the dependency injector - */ - let this->container = container; - - if container->has("serializer") { - let serializer = container->getShared("serializer"); - let attributes = serializer->unserialize(data); - } else { - let attributes = unserialize(data); - } - - if typeof attributes == "array" { - /** - * Gets the default modelsManager service - */ - let manager = container->getShared("collectionManager"); - - if unlikely typeof manager != "object" { - throw new Exception( - "The injected service 'collectionManager' is not valid" - ); - } - - /** - * Update the models manager - */ - let this->modelsManager = manager; - - /** - * Update the objects attributes - */ - for key, value in attributes { - let this->{key} = value; - } - } - } - - /** - * Creates/Updates a collection based on the values in the attributes - */ - public function update() -> bool - { - var exists, data, success, status, ok, collection; - - let collection = this->prepareCU(); - - /** - * Check the dirty state of the current operation to update the current - * operation - */ - let exists = this->exists(collection); - - if unlikely !exists { - throw new Exception( - "The document cannot be updated because it doesn't exist" - ); - } - - let this->operationMade = self::OP_UPDATE; - - /** - * The messages added to the validator are reset here - */ - let this->errorMessages = []; - - /** - * Execute the preSave hook - */ - if this->preSave(this->container, self::disableEvents, exists) === false { - return false; - } - - let data = this->toArray(); - - /** - * We always use safe stores to get the success state - * Save the document - */ - let status = collection->update( - [ - "_id": this->_id - ], - data, - [ - "w": true - ] - ); - - if fetch ok, status["ok"] && ok { - let success = true; - } else { - let success = false; - } - - /** - * Call the postSave hooks - */ - return this->postSave( - self::disableEvents, - success, - exists - ); - } - - /** - * Executes validators on every validation call - * - *```php - * use Phalcon\Mvc\Collection; - * use Phalcon\Validation; - * use Phalcon\Validation\Validator\ExclusionIn; - * - * class Subscriptors extends Collection - * { - * public function validation() - * { - * $validator = new Validation(); - * - * $validator->add( - * "status", - * new ExclusionIn( - * [ - * "domain" => [ - * "A", - * "I", - * ], - * ] - * ) - * ); - * - * return $this->validate($validator); - * } - * } - *``` - */ - protected function validate( validator) -> bool - { - var messages, message; - - let messages = validator->validate(null, this); - - // Call the validation, if it returns not the bool - // we append the messages to the current object - if typeof messages == "boolean" { - return messages; - } - - for message in iterator(messages) { - this->appendMessage( - new Message( - message->getMessage(), - message->getField(), - message->getType(), - null, - message->getCode() - ) - ); - } - - // If there is a message, it returns false otherwise true - return !count(messages); - } - - /** - * Sets if a model must use implicit objects ids - */ - protected function useImplicitObjectIds(bool useImplicitObjectIds) - { - this->modelsManager->useImplicitObjectIds(this, useImplicitObjectIds); - } - - /** - * Writes an attribute value by its name - * - *```php - * $robot->writeAttribute("name", "Rosey"); - *``` - */ - public function writeAttribute(string attribute, var value) - { - let this->{attribute} = value; - } - - /** - * Cancel the current operation - */ - protected function cancelOperation(bool disableEvents) -> bool - { - var eventName; - - if disableEvents { - return false; - } - - if this->operationMade == self::OP_DELETE { - let eventName = "notDeleted"; - } else { - let eventName = "notSaved"; - } - - this->fireEvent(eventName); - - return true; - } - - /** - * Checks if the document exists in the collection - * - * @param MongoCollection collection - */ - protected function exists(collection) -> bool - { - var id, mongoId, exists; - - if !fetch id, this->_id { - return false; - } - - if typeof id == "object" { - let mongoId = id; - } else { - /** - * Check if the model use implicit ids - */ - if this->modelsManager->isUsingImplicitObjectIds(this) { - let mongoId = new MongoId(id); - let this->_id = mongoId; - } else { - let mongoId = id; - } - } - - /** - * If we already know if the document exists we don't check it - */ - if !this->dirtyState { - return true; - } - - /** - * Perform the count using the function provided by the driver - */ - let exists = collection->count(["_id": mongoId]) > 0; - - if exists { - let this->dirtyState = self::DIRTY_STATE_PERSISTENT; - } else { - let this->dirtyState = self::DIRTY_STATE_TRANSIENT; - } - - return exists; - } - - /** - * Perform a count over a resultset - * - * @param array params - * @param \MongoDb connection - */ - protected static function getGroupResultset(params, collection, connection) -> int - { - var source, mongoCollection, conditions, limit, sort, documentsCursor; - - let source = collection->getSource(); - if unlikely empty source { - throw new Exception("Method getSource() returns empty string"); - } - - let mongoCollection = connection->selectCollection(source); - - /** - * Convert the string to an array - */ - if !fetch conditions, params[0] { - if !fetch conditions, params["conditions"] { - let conditions = []; - } - } - - if isset params["limit"] || isset params["sort"] || isset params["skip"] { - /** - * Perform the find - */ - let documentsCursor = mongoCollection->find(conditions); - - /** - * Check if a "limit" clause was defined - */ - if fetch limit, params["limit"] { - documentsCursor->limit(limit); - } - - /** - * Check if a "sort" clause was defined - */ - if fetch sort, params["sort"] { - documentsCursor->sort(sort); - } - - /** - * Check if a "skip" clause was defined - */ - if fetch sort, params["skip"] { - documentsCursor->skip(sort); - } - - /** - * Only "count" is supported - */ - return count(documentsCursor); - } - - return mongoCollection->count(conditions); - } - - /** - * Returns a collection resultset - * - * @param array params - * @param \MongoDb connection - * @return array - */ - protected static function getResultset(var params, collection, connection, bool unique) - { - var source, mongoCollection, conditions, base, documentsCursor, - fields, skip, limit, sort, document, collections, className; - - /** - * Check if "class" clause was defined - */ - if fetch className, params["class"] { - let base = new {className}(); - - if unlikely !(base instanceof CollectionInterface || base instanceof Collection\Document) { - throw new Exception( - "Object of class '" . className . "' must be an implementation of Phalcon\\Mvc\\CollectionInterface or an instance of Phalcon\\Mvc\\Collection\\Document" - ); - } - } else { - let base = collection; - } - - if base instanceof Collection { - base->setDirtyState( - self::DIRTY_STATE_PERSISTENT - ); - } - - let source = collection->getSource(); - if unlikely empty source { - throw new Exception("Method getSource() returns empty string"); - } - - let mongoCollection = connection->selectCollection(source); - - if unlikely typeof mongoCollection != "object" { - throw new Exception("Couldn't select mongo collection"); - } - - /** - * Convert the string to an array - */ - if !fetch conditions, params[0] { - if !fetch conditions, params["conditions"] { - let conditions = []; - } - } - - if unlikely typeof conditions != "array" { - throw new Exception("Find parameters must be an array"); - } - - /** - * Perform the find - */ - if fetch fields, params["fields"] { - let documentsCursor = mongoCollection->find(conditions, fields); - } else { - let documentsCursor = mongoCollection->find(conditions); - } - - /** - * Check if a "limit" clause was defined - */ - if fetch limit, params["limit"] { - documentsCursor->limit(limit); - } - - /** - * Check if a "sort" clause was defined - */ - if fetch sort, params["sort"] { - documentsCursor->sort(sort); - } - - /** - * Check if a "skip" clause was defined - */ - if fetch skip, params["skip"] { - documentsCursor->skip(skip); - } - - if unique { - /** - * Requesting a single result - */ - documentsCursor->rewind(); - - let document = documentsCursor->current(); - - if typeof document != "array" { - return false; - } - - /** - * Assign the values to the base object - */ - return self::cloneResult(base, document); - } - - /** - * Requesting a complete resultset - */ - let collections = []; - for document in iterator_to_array(documentsCursor, false) { - /** - * Assign the values to the base object - */ - let collections[] = self::cloneResult(base, document); - } - - return collections; - } - - /** - * Executes internal hooks before save a document - */ - final protected function preSave( container, bool disableEvents, bool exists) -> bool - { - var eventName; - - /** - * Run Validation Callbacks Before - */ - if !disableEvents { - if this->fireEventCancel("beforeValidation") === false { - return false; - } - - if !exists { - let eventName = "beforeValidationOnCreate"; - } else { - let eventName = "beforeValidationOnUpdate"; - } - - if this->fireEventCancel(eventName) === false { - return false; - } - } - - /** - * Run validation - */ - if this->fireEventCancel("validation") === false { - if !disableEvents { - this->fireEvent("onValidationFails"); - } - - return false; - } - - if !disableEvents { - /** - * Run Validation Callbacks After - */ - if !exists { - let eventName = "afterValidationOnCreate"; - } else { - let eventName = "afterValidationOnUpdate"; - } - - if this->fireEventCancel(eventName) === false { - return false; - } - - if this->fireEventCancel("afterValidation") === false { - return false; - } - - /** - * Run Before Callbacks - */ - if this->fireEventCancel("beforeSave") === false { - return false; - } - - if exists { - let eventName = "beforeUpdate"; - } else { - let eventName = "beforeCreate"; - } - - if this->fireEventCancel(eventName) === false { - return false; - } - } - - return true; - } - - /** - * Executes internal events after save a document - */ - final protected function postSave(bool disableEvents, bool success, bool exists) -> bool - { - var eventName; - - if !success { - if !disableEvents { - this->fireEvent("notSaved"); - } - - this->cancelOperation(disableEvents); - - return false; - } - - if !disableEvents { - if exists { - let eventName = "afterUpdate"; - } else { - let eventName = "afterCreate"; - } - - this->fireEvent(eventName); - - this->fireEvent("afterSave"); - } - - return success; - } - - /** - * Shared Code for CU Operations - * Prepares Collection - */ - protected function prepareCU() - { - var container, connection, source, collection; - - let container = this->container; - if unlikely typeof container != "object" { - throw new Exception( - Exception::containerServiceNotFound( - "the services related to the ODM" - ) - ); - } - - let source = this->getSource(); - if unlikely empty source { - throw new Exception("Method getSource() returns empty string"); - } - - let connection = this->getConnection(); - - /** - * Choose a collection according to the collection name - */ - let collection = connection->selectCollection(source); - - return collection; - } -} diff --git a/phalcon/Mvc/Collection/Behavior.zep b/phalcon/Mvc/Collection/Behavior.zep deleted file mode 100644 index 1b5c7614b23..00000000000 --- a/phalcon/Mvc/Collection/Behavior.zep +++ /dev/null @@ -1,74 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection; - -use Phalcon\Mvc\CollectionInterface; - -/** - * Phalcon\Mvc\Collection\Behavior - * - * This is an optional base class for ORM behaviors - */ -abstract class Behavior implements BehaviorInterface -{ - protected options; - - /** - * Phalcon\Mvc\Collection\Behavior - */ - public function __construct(array options = []) - { - let this->options = options; - } - - /** - * Returns the behavior options related to an event - * - * @return array - */ - protected function getOptions(string! eventName = null) - { - var options, eventOptions; - - let options = this->options; - if eventName !== null { - if fetch eventOptions, options[eventName] { - return eventOptions; - } - return null; - } - return options; - } - - /** - * Acts as fallbacks when a missing method is called on the collection - */ - public function missingMethod( model, string method, array arguments = []) - { - return null; - } - - /** - * Checks whether the behavior must take action on certain event - */ - protected function mustTakeAction(string! eventName) -> bool - { - return isset this->options[eventName]; - } - - /** - * This method receives the notifications from the EventsManager - */ - public function notify(string type, model) - { - return null; - } -} diff --git a/phalcon/Mvc/Collection/Behavior/SoftDelete.zep b/phalcon/Mvc/Collection/Behavior/SoftDelete.zep deleted file mode 100644 index f1e250dab44..00000000000 --- a/phalcon/Mvc/Collection/Behavior/SoftDelete.zep +++ /dev/null @@ -1,90 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection\Behavior; - -use Phalcon\Mvc\CollectionInterface; -use Phalcon\Mvc\Collection\Behavior; -use Phalcon\Mvc\Collection\Exception; - -/** - * Phalcon\Mvc\Collection\Behavior\SoftDelete - * - * Instead of permanently delete a record it marks the record as - * deleted changing the value of a flag column - */ -class SoftDelete extends Behavior -{ - /** - * Listens for notifications from the models manager - */ - public function notify(string! type, model) - { - var options, value, field, updateModel, message; - - if type !== "beforeDelete" { - return; - } - - let options = this->getOptions(); - - /** - * 'value' is the value to be updated instead of delete the record - */ - if unlikely !fetch value, options["value"] { - throw new Exception("The option 'value' is required"); - } - - /** - * 'field' is the attribute to be updated instead of delete the record - */ - if unlikely !fetch field, options["field"] { - throw new Exception("The option 'field' is required"); - } - - /** - * Skip the current operation - */ - model->skipOperation(true); - - /** - * If the record is already flagged as 'deleted' we don't delete it again - */ - if model->readAttribute(field) == value { - return; - } - - /** - * Clone the current model to make a clean new operation - */ - let updateModel = clone model; - - updateModel->writeAttribute(field, value); - - /** - * Update the cloned model - */ - if !updateModel->save() { - /** - * Transfer the messages from the cloned model to the original model - */ - for message in updateModel->getMessages() { - model->appendMessage(message); - } - - return false; - } - - /** - * Update the original model too - */ - model->writeAttribute(field, value); - } -} diff --git a/phalcon/Mvc/Collection/Behavior/Timestampable.zep b/phalcon/Mvc/Collection/Behavior/Timestampable.zep deleted file mode 100644 index ba762339172..00000000000 --- a/phalcon/Mvc/Collection/Behavior/Timestampable.zep +++ /dev/null @@ -1,90 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection\Behavior; - -use Closure; -use Phalcon\Mvc\CollectionInterface; -use Phalcon\Mvc\Collection\Behavior; -use Phalcon\Mvc\Collection\Exception; - -/** - * Phalcon\Mvc\Collection\Behavior\Timestampable - * - * Allows to automatically update a model’s attribute saving the - * datetime when a record is created or updated - */ -class Timestampable extends Behavior -{ - /** - * Listens for notifications from the models manager - */ - public function notify(string! type, model) - { - var options, timestamp, singleField, field, generator, format; - - /** - * Check if the developer decided to take action here - */ - if this->mustTakeAction(type) !== true { - return null; - } - - let options = this->getOptions(type); - if typeof options == "array" { - - /** - * The field name is required in this behavior - */ - if unlikely !fetch field, options["field"] { - throw new Exception("The option 'field' is required"); - } - - let timestamp = null; - - if fetch format, options["format"] { - /** - * Format is a format for date() - */ - let timestamp = date(format); - } else { - if fetch generator, options["generator"] { - - /** - * A generator is a closure that produce the correct timestamp value - */ - if typeof generator == "object" { - if generator instanceof Closure { - let timestamp = call_user_func(generator); - } - } - } - } - - /** - * Last resort call time() - */ - if timestamp === null { - let timestamp = time(); - } - - /** - * Assign the value to the field, use writeattribute if the property is protected - */ - if typeof field == "array" { - for singleField in field { - model->writeAttribute(singleField, timestamp); - } - } else { - model->writeAttribute(field, timestamp); - } - } - } -} diff --git a/phalcon/Mvc/Collection/BehaviorInterface.zep b/phalcon/Mvc/Collection/BehaviorInterface.zep deleted file mode 100644 index ffa3bb458fa..00000000000 --- a/phalcon/Mvc/Collection/BehaviorInterface.zep +++ /dev/null @@ -1,31 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection; - -use Phalcon\Mvc\CollectionInterface; - -/** - * Phalcon\Mvc\Collection\BehaviorInterface - * - * Interface for Phalcon\Mvc\Collection\Behavior - */ -interface BehaviorInterface -{ - /** - * Calls a method when it's missing in the collection - */ - public function missingMethod( collection, string !method, array arguments = []); - - /** - * This method receives the notifications from the EventsManager - */ - public function notify(string! type, collection); -} diff --git a/phalcon/Mvc/Collection/Document.zep b/phalcon/Mvc/Collection/Document.zep deleted file mode 100644 index f3d63118d7d..00000000000 --- a/phalcon/Mvc/Collection/Document.zep +++ /dev/null @@ -1,100 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection; - -use ArrayAccess; -use Phalcon\Mvc\EntityInterface; -use Phalcon\Mvc\Collection\Exception; - -/** - * Phalcon\Mvc\Collection\Document - * - * This component allows Phalcon\Mvc\Collection to return rows without an associated entity. - * This objects implements the ArrayAccess interface to allow access the object as object->x or array[x]. - */ -class Document implements EntityInterface, ArrayAccess -{ - /** - * Returns the value of a field using the ArrayAccess interfase - */ - public function offsetGet(var index) -> var - { - var value; - - if unlikely !fetch value, this->{index} { - throw new Exception("The index does not exist in the row"); - } - - return value; - } - - /** - * Checks whether an offset exists in the document - */ - public function offsetExists(var index) -> bool - { - return isset this->{index}; - } - - /** - * Change a value using the ArrayAccess interface - */ - public function offsetSet(var index, value) -> void - { - let this->{index} = value; - } - - /** - * Rows cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface - */ - public function offsetUnset(var index) -> void - { - throw new Exception("The index does not exist in the row"); - } - - /** - * Reads an attribute value by its name - * - *```php - * echo $robot->readAttribute("name"); - *``` - */ - public function readAttribute(string! attribute) -> var | null - { - var value; - - if !fetch value, this->{attribute} { - return null; - } - - return value; - } - - /** - * Returns the instance as an array representation - */ - public function toArray() -> array - { - return get_object_vars(this); - } - - /** - * Writes an attribute value by its name - * - *```php - * $robot->writeAttribute("name", "Rosey"); - *``` - */ - public function writeAttribute(string! attribute, var value) -> void - { - let this->{attribute} = value; - } -} diff --git a/phalcon/Mvc/Collection/Exception.zep b/phalcon/Mvc/Collection/Exception.zep deleted file mode 100644 index e3a3e5109c3..00000000000 --- a/phalcon/Mvc/Collection/Exception.zep +++ /dev/null @@ -1,22 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection; - -/** - * Phalcon\Mvc\Collection\Exception - * - * Exceptions thrown in Phalcon\Mvc\Collection\* classes will use this class - * - */ -class Exception extends \Phalcon\Exception -{ - -} diff --git a/phalcon/Mvc/Collection/Manager.zep b/phalcon/Mvc/Collection/Manager.zep deleted file mode 100644 index be75a26c86f..00000000000 --- a/phalcon/Mvc/Collection/Manager.zep +++ /dev/null @@ -1,378 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection; - -use Phalcon\Di\DiInterface; -use Phalcon\Di\InjectionAwareInterface; -use Phalcon\Events\EventsAwareInterface; -use Phalcon\Events\ManagerInterface; -use Phalcon\Mvc\CollectionInterface; -use Phalcon\Mvc\Collection\BehaviorInterface; - -/** - * Phalcon\Mvc\Collection\Manager - * - * This components controls the initialization of models, keeping record of relations - * between the different models of the application. - * - * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. - * - * ```php - * $di = new \Phalcon\Di(); - * - * $di->set( - * "collectionManager", - * function () { - * return new \Phalcon\Mvc\Collection\Manager(); - * } - * ); - * - * $robot = new Robots($di); - * ``` - */ -class Manager implements InjectionAwareInterface, EventsAwareInterface -{ - protected behaviors; - - protected connectionServices; - - protected container; - - protected customEventsManager; - - protected eventsManager; - - protected implicitObjectsIds; - - protected initialized; - - protected lastInitialized; - - protected serviceName = "mongo" { get, set }; - - /** - * Binds a behavior to a model - */ - public function addBehavior( model, behavior) - { - var entityName, modelsBehaviors; - - let entityName = get_class_lower(model); - - /** - * Get the current behaviors - */ - if !fetch modelsBehaviors, this->behaviors[entityName] { - let modelsBehaviors = []; - } - - /** - * Append the behavior to the list of behaviors - */ - let modelsBehaviors[] = behavior; - - /** - * Update the behaviors list - */ - let this->behaviors[entityName] = modelsBehaviors; - } - - /** - * Returns a custom events manager related to a model - */ - public function getCustomEventsManager( model) -> var | null - { - var customEventsManager, className; - - let customEventsManager = this->customEventsManager; - if typeof customEventsManager == "array" { - let className = get_class_lower(model); - if isset customEventsManager[className] { - return customEventsManager[className]; - } - } - - return null; - } - - /** - * Returns the connection related to a model - * - * @return \Mongo - */ - public function getConnection( model) - { - var service, connectionService, connection, container, entityName; - - let service = this->serviceName; - let connectionService = this->connectionServices; - if typeof connectionService == "array" { - let entityName = get_class(model); - - /** - * Check if the model has a custom connection service - */ - if isset connectionService[entityName] { - let service = connectionService[entityName]; - } - } - - let container = this->container; - if unlikely typeof container != "object" { - throw new Exception( - Exception::containerServiceNotFound( - "the services related to the ORM" - ) - ); - } - - /** - * Request the connection service from the DI - */ - let connection = container->getShared(service); - if unlikely typeof connection != "object" { - throw new Exception("Invalid injected connection service"); - } - - return connection; - } - - /** - * Gets a connection service for a specific model - */ - public function getConnectionService( model) -> string - { - var service, entityName; - - let service = this->serviceName; - let entityName = get_class(model); - if isset this->connectionServices[entityName] { - let service = this->connectionServices[entityName]; - } - - return service; - } - - /** - * Returns the DependencyInjector container - */ - public function getDI() -> - { - return this->container; - } - - /** - * Returns the internal event manager - */ - public function getEventsManager() -> - { - return this->eventsManager; - } - - /** - * Get the latest initialized model - */ - public function getLastInitialized() -> - { - return this->lastInitialized; - } - - /** - * Checks if a model is using implicit object ids - */ - public function isUsingImplicitObjectIds( model) -> bool - { - var implicit; - - /** - * All collections use by default are using implicit object ids - */ - if fetch implicit, this->implicitObjectsIds[get_class(model)] { - return implicit; - } - - return true; - } - - /** - * Check whether a model is already initialized - */ - public function isInitialized(string! className) -> bool - { - return isset this->initialized[strtolower(className)]; - } - - /** - * Initializes a model in the models manager - */ - public function initialize( model) -> void - { - var className, initialized, eventsManager; - - let className = get_class_lower(model); - let initialized = this->initialized; - - /** - * Models are just initialized once per request - */ - if !isset initialized[className] { - /** - * Call the 'initialize' method if it's implemented - */ - if method_exists(model, "initialize") { - model->{"initialize"}(); - } - - /** - * If an EventsManager is available we pass to it every initialized model - */ - let eventsManager = this->eventsManager; - if typeof eventsManager == "object" { - eventsManager->fire("collectionManager:afterInitialize", model); - } - - let this->initialized[className] = model; - let this->lastInitialized = model; - } - } - - /** - * Dispatch an event to the listeners and behaviors - * This method expects that the endpoint listeners/behaviors returns true - * meaning that at least one was implemented - */ - public function missingMethod( model, string! eventName, var data) -> bool - { - var behaviors, modelsBehaviors, result, eventsManager, behavior; - - /** - * Dispatch events to the global events manager - */ - let behaviors = this->behaviors; - if typeof behaviors == "array" { - - if fetch modelsBehaviors, behaviors[get_class_lower(model)] { - - /** - * Notify all the events on the behavior - */ - for behavior in modelsBehaviors { - let result = behavior->missingMethod(model, eventName, data); - if result !== null { - return result; - } - } - } - } - - /** - * Dispatch events to the global events manager - */ - let eventsManager = this->eventsManager; - if typeof eventsManager == "object" { - return eventsManager->fire("model:" . eventName, model, data); - } - - return false; - } - - /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model - */ - public function notifyEvent(string! eventName, model) - { - var behavior, behaviors, modelsBehaviors, eventsManager, status = null, - customEventsManager; - - let behaviors = this->behaviors; - if typeof behaviors == "array" { - if fetch modelsBehaviors, behaviors[get_class_lower(model)] { - - /** - * Notify all the events on the behavior - */ - for behavior in modelsBehaviors { - let status = behavior->notify(eventName, model); - if status === false { - return false; - } - } - } - } - - /** - * Dispatch events to the global events manager - */ - let eventsManager = this->eventsManager; - if typeof eventsManager == "object" { - let status = eventsManager->fire( "collection:". eventName, model); - if !status { - return status; - } - } - - /** - * A model can has a specific events manager for it - */ - let customEventsManager = this->customEventsManager; - if typeof customEventsManager == "array" { - if isset customEventsManager[get_class_lower(model)] { - let status = customEventsManager->fire("collection:" . eventName, model); - if !status { - return status; - } - } - } - - return status; - } - - /** - * Sets a custom events manager for a specific model - */ - public function setCustomEventsManager( model, eventsManager) -> void - { - let this->customEventsManager[get_class(model)] = eventsManager; - } - - /** - * Sets a connection service for a specific model - */ - public function setConnectionService( model, string! connectionService) -> void - { - let this->connectionServices[get_class(model)] = connectionService; - } - - /** - * Sets the DependencyInjector container - */ - public function setDI( container) -> void - { - let this->container = container; - } - - /** - * Sets the event manager - */ - public function setEventsManager( eventsManager) -> void - { - let this->eventsManager = eventsManager; - } - - /** - * Sets whether a model must use implicit objects ids - */ - public function useImplicitObjectIds( model, bool useImplicitObjectIds) -> void - { - let this->implicitObjectsIds[get_class(model)] = useImplicitObjectIds; - } -} diff --git a/phalcon/Mvc/Collection/ManagerInterface.zep b/phalcon/Mvc/Collection/ManagerInterface.zep deleted file mode 100644 index 7f9ffb5156e..00000000000 --- a/phalcon/Mvc/Collection/ManagerInterface.zep +++ /dev/null @@ -1,96 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc\Collection; - -use Phalcon\Db\Adapter\AdapterInterface; -use Phalcon\Mvc\CollectionInterface; -use Phalcon\Mvc\Collection\BehaviorInterface; -use Phalcon\Events\ManagerInterface as EventsManagerInterface; - -/** - * Phalcon\Mvc\Collection\Manager - * - * This components controls the initialization of models, keeping record of relations - * between the different models of the application. - * - * A CollectionManager is injected to a model via a Dependency Injector Container such as Phalcon\Di. - * - * ```php - * $di = new \Phalcon\Di(); - * - * $di->set( - * "collectionManager", - * function() { - * return new \Phalcon\Mvc\Collection\Manager(); - * } - * ); - * - * $robot = new Robots(di); - * ``` - */ -interface ManagerInterface -{ - /** - * Binds a behavior to a collection - */ - public function addBehavior( model, behavior); - - /** - * Returns the connection related to a model - */ - public function getConnection( model) -> ; - - /** - * Returns a custom events manager related to a model - */ - public function getCustomEventsManager( model) -> ; - - /** - * Get the latest initialized model - */ - public function getLastInitialized() -> ; - - /** - * Initializes a model in the models manager - */ - public function initialize( model); - - /** - * Check whether a model is already initialized - */ - public function isInitialized(string! className) -> bool; - - /** - * Checks if a model is using implicit object ids - */ - public function isUsingImplicitObjectIds( model) -> bool; - - /** - * Receives events generated in the models and dispatches them to an events-manager if available - * Notify the behaviors that are listening in the model - */ - public function notifyEvent(string! eventName, model); - - /** - * Sets a custom events manager for a specific model - */ - public function setCustomEventsManager( model, eventsManager); - - /** - * Sets a connection service for a specific model - */ - public function setConnectionService( model, string! connectionService); - - /** - * Sets if a model must use implicit objects ids - */ - public function useImplicitObjectIds( model, bool useImplicitObjectIds); -} diff --git a/phalcon/Mvc/CollectionInterface.zep b/phalcon/Mvc/CollectionInterface.zep deleted file mode 100644 index e671923cf39..00000000000 --- a/phalcon/Mvc/CollectionInterface.zep +++ /dev/null @@ -1,132 +0,0 @@ - -/** - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Mvc; - -use Phalcon\Messages\MessageInterface; - -/** - * Interface for Phalcon\Mvc\Collection - */ -interface CollectionInterface -{ - /** - * Appends a customized message on the validation process - */ - public function appendMessage( message); - - /** - * Returns a cloned collection - */ - public static function cloneResult( collection, array! document) -> ; - - /** - * Perform a count over a collection - */ - public static function count(array parameters = null) -> int; - - /** - * Deletes a model instance. Returning true on success or false otherwise - */ - public function delete() -> bool; - - /** - * Allows to query a set of records that match the specified conditions - */ - public static function find(array parameters = null) -> array; - - /** - * Find a document by its id - * - * @param string id - */ - public static function findById(var id) -> | null; - - /** - * Allows to query the first record that match the specified conditions - */ - public static function findFirst(array parameters = null) -> array; - - /** - * Fires an event, implicitly calls behaviors and listeners in the events - * manager are notified - */ - public function fireEvent(string! eventName) -> bool; - - /** - * Fires an event, implicitly listeners in the events manager are notified - * This method stops if one of the callbacks/listeners returns bool false - */ - public function fireEventCancel(string! eventName) -> bool; - - /** - * Retrieves a database connection - * - * @return MongoDb - */ - public function getConnection(); - - /** - * Returns one of the DIRTY_STATE_* constants telling if the record exists - * in the database or not - */ - public function getDirtyState() -> int; - - /** - * Returns the value of the _id property - * - * @return MongoId - */ - public function getId(); - - /** - * Returns all the validation messages - */ - public function getMessages() -> ; - - /** - * Returns an array with reserved properties that cannot be part of the - * insert/update - */ - public function getReservedAttributes() -> array; - - /** - * Returns collection name mapped in the model - */ - public function getSource() -> string; - - /** - * Creates/Updates a collection based on the values in the attributes - */ - public function save() -> bool; - - /** - * Sets a service in the services container that returns the Mongo database - */ - public function setConnectionService(string! connectionService); - - /** - * Sets the dirty state of the object using one of the DIRTY_STATE_* - * constants - */ - public function setDirtyState(int dirtyState) -> ; - - /** - * Sets a value for the _id property, creates a MongoId object if needed - * - * @param mixed id - */ - public function setId(id); - - /** - * Check whether validation process has generated any messages - */ - public function validationHasFailed() -> bool; -} diff --git a/phalcon/Validation/Validator/Uniqueness.zep b/phalcon/Validation/Validator/Uniqueness.zep index f553eb3670d..bebc039d6f3 100644 --- a/phalcon/Validation/Validator/Uniqueness.zep +++ b/phalcon/Validation/Validator/Uniqueness.zep @@ -11,13 +11,13 @@ namespace Phalcon\Validation\Validator; use Phalcon\Messages\Message; +use Phalcon\Mvc\Model; +use Phalcon\Mvc\ModelInterface; use Phalcon\Validation; use Phalcon\Validation\AbstractCombinedFieldsValidator; use Phalcon\Validation\Exception; -use Phalcon\Mvc\ModelInterface; -use Phalcon\Mvc\CollectionInterface; -use Phalcon\Mvc\Model; -use Phalcon\Mvc\Collection; +//use Phalcon\Mvc\CollectionInterface; +//use Phalcon\Mvc\Collection; /** * Check that a field is unique in the related table @@ -132,8 +132,11 @@ class Uniqueness extends AbstractCombinedFieldsValidator protected function isUniqueness( validation, var field) -> bool { - var values, convert, record, params, className, isModel, isDocument, - singleField; + var values, convert, record, params, className, isModel, singleField; +// +// @todo: Restore when new Collection is reintroduced +// +// var isDocument; if typeof field != "array" { let singleField = field, @@ -170,17 +173,29 @@ class Uniqueness extends AbstractCombinedFieldsValidator } } - let isModel = record instanceof ModelInterface, - isDocument = record instanceof CollectionInterface; + let isModel = record instanceof ModelInterface; +// +// @todo: Restore when new Collection is reintroduced +// +// let isDocument = record instanceof CollectionInterface; if isModel { let params = this->isUniquenessModel(record, field, values); - } elseif isDocument { - let params = this->isUniquenessCollection(record, field, values); +// +// @todo: Restore when new Collection is reintroduced +// +// } elseif isDocument { +// let params = this->isUniquenessCollection(record, field, values); } else { throw new Exception( - "The uniqueness validator works only with Phalcon\\Mvc\\Model or Phalcon\\Mvc\\Collection" + "The uniqueness validator works only with Phalcon\\Mvc\\Model" ); +// +// @todo: Restore when new Collection is reintroduced +// +// throw new Exception( +// "The uniqueness validator works only with Phalcon\\Mvc\\Model or Phalcon\\Mvc\\Collection" +// ); } let className = get_class(record); @@ -188,77 +203,81 @@ class Uniqueness extends AbstractCombinedFieldsValidator return {className}::count(params) == 0; } - /** - * Uniqueness method used for collection - */ - protected function isUniquenessCollection(var record, array field, array values) - { - var exceptConditions, fieldExcept, notInValues, value, singleField, - params, except, singleExcept; - - let exceptConditions = []; - let params = [ - "conditions" : [] - ]; - - for singleField in field { - let fieldExcept = null; - let notInValues = []; - let value = values[singleField]; - - let except = this->getOption("except"); - - let params["conditions"][singleField] = value; - - if except { - if typeof except == "array" && count(field) > 1 { - if isset except[singleField] { - let fieldExcept = except[singleField]; - } - } - - if fieldExcept != null { - if typeof fieldExcept == "array" { - for singleExcept in fieldExcept { - let notInValues[] = singleExcept; - } - - let exceptConditions[singleField] = [ - "$nin": notInValues - ]; - } else { - let exceptConditions[singleField] = [ - "$ne": fieldExcept - ]; - } - } elseif typeof except == "array" && count(field) == 1 { - for singleExcept in except { - let notInValues[] = singleExcept; - } - let params["conditions"][singleField] = [ - "$nin": notInValues - ]; - } elseif count(field) == 1 { - let params["conditions"][singleField] = [ - "$ne": except - ]; - } - } - } - - if record->getDirtyState() == Collection::DIRTY_STATE_PERSISTENT { - let params["conditions"]["_id"] = [ - "$ne": record->getId() - ]; - } - - if !empty exceptConditions { - let params["conditions"]["$or"] = [exceptConditions]; - } - - return params; - } +// +// @todo: Restore when new Collection is reintroduced +// +// /** +// * Uniqueness method used for collection +// */ +// protected function isUniquenessCollection(var record, array field, array values) +// { +// var exceptConditions, fieldExcept, notInValues, value, singleField, +// params, except, singleExcept; +// +// let exceptConditions = []; +// let params = [ +// "conditions" : [] +// ]; +// +// for singleField in field { +// let fieldExcept = null; +// let notInValues = []; +// let value = values[singleField]; +// +// let except = this->getOption("except"); +// +// let params["conditions"][singleField] = value; +// +// if except { +// if typeof except == "array" && count(field) > 1 { +// if isset except[singleField] { +// let fieldExcept = except[singleField]; +// } +// } +// +// if fieldExcept != null { +// if typeof fieldExcept == "array" { +// for singleExcept in fieldExcept { +// let notInValues[] = singleExcept; +// } +// +// let exceptConditions[singleField] = [ +// "$nin": notInValues +// ]; +// } else { +// let exceptConditions[singleField] = [ +// "$ne": fieldExcept +// ]; +// } +// } elseif typeof except == "array" && count(field) == 1 { +// for singleExcept in except { +// let notInValues[] = singleExcept; +// } +// +// let params["conditions"][singleField] = [ +// "$nin": notInValues +// ]; +// } elseif count(field) == 1 { +// let params["conditions"][singleField] = [ +// "$ne": except +// ]; +// } +// } +// } +// +// if record->getDirtyState() == Collection::DIRTY_STATE_PERSISTENT { +// let params["conditions"]["_id"] = [ +// "$ne": record->getId() +// ]; +// } +// +// if !empty exceptConditions { +// let params["conditions"]["$or"] = [exceptConditions]; +// } +// +// return params; +// } /** * Uniqueness method used for model diff --git a/tests/integration/Mvc/Collection/AggregateCest.php b/tests/integration/Mvc/Collection/AggregateCest.php deleted file mode 100644 index 16e2b46669d..00000000000 --- a/tests/integration/Mvc/Collection/AggregateCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class AggregateCest - */ -class AggregateCest -{ - /** - * Tests Phalcon\Mvc\Collection :: aggregate() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionAggregate(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - aggregate()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/AppendMessageCest.php b/tests/integration/Mvc/Collection/AppendMessageCest.php deleted file mode 100644 index f32baa020f6..00000000000 --- a/tests/integration/Mvc/Collection/AppendMessageCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class AppendMessageCest - */ -class AppendMessageCest -{ - /** - * Tests Phalcon\Mvc\Collection :: appendMessage() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionAppendMessage(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - appendMessage()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/ConstructCest.php b/tests/integration/Mvc/Collection/Behavior/ConstructCest.php deleted file mode 100644 index 40b720ed6b2..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/ConstructCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior; - -use IntegrationTester; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorConstruct(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior - __construct()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/MissingMethodCest.php b/tests/integration/Mvc/Collection/Behavior/MissingMethodCest.php deleted file mode 100644 index fd757943c28..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/MissingMethodCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior; - -use IntegrationTester; - -/** - * Class MissingMethodCest - */ -class MissingMethodCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior :: missingMethod() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorMissingMethod(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior - missingMethod()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/NotifyCest.php b/tests/integration/Mvc/Collection/Behavior/NotifyCest.php deleted file mode 100644 index 90cf7458d71..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/NotifyCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior; - -use IntegrationTester; - -/** - * Class NotifyCest - */ -class NotifyCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior :: notify() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorNotify(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior - notify()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/SoftDelete/ConstructCest.php b/tests/integration/Mvc/Collection/Behavior/SoftDelete/ConstructCest.php deleted file mode 100644 index 9566624f921..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/SoftDelete/ConstructCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior\SoftDelete; - -use IntegrationTester; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior\SoftDelete :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorSoftdeleteConstruct(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior\SoftDelete - __construct()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/SoftDelete/MissingMethodCest.php b/tests/integration/Mvc/Collection/Behavior/SoftDelete/MissingMethodCest.php deleted file mode 100644 index 426c28d393c..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/SoftDelete/MissingMethodCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior\SoftDelete; - -use IntegrationTester; - -/** - * Class MissingMethodCest - */ -class MissingMethodCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior\SoftDelete :: missingMethod() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorSoftdeleteMissingMethod(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior\SoftDelete - missingMethod()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/SoftDelete/NotifyCest.php b/tests/integration/Mvc/Collection/Behavior/SoftDelete/NotifyCest.php deleted file mode 100644 index 14c8d4ab246..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/SoftDelete/NotifyCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior\SoftDelete; - -use IntegrationTester; - -/** - * Class NotifyCest - */ -class NotifyCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior\SoftDelete :: notify() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorSoftdeleteNotify(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior\SoftDelete - notify()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/Timestampable/ConstructCest.php b/tests/integration/Mvc/Collection/Behavior/Timestampable/ConstructCest.php deleted file mode 100644 index a7daaa94630..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/Timestampable/ConstructCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior\Timestampable; - -use IntegrationTester; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior\Timestampable :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorTimestampableConstruct(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior\Timestampable - __construct()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/Timestampable/MissingMethodCest.php b/tests/integration/Mvc/Collection/Behavior/Timestampable/MissingMethodCest.php deleted file mode 100644 index 780f777c249..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/Timestampable/MissingMethodCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior\Timestampable; - -use IntegrationTester; - -/** - * Class MissingMethodCest - */ -class MissingMethodCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior\Timestampable :: missingMethod() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorTimestampableMissingMethod(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior\Timestampable - missingMethod()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Behavior/Timestampable/NotifyCest.php b/tests/integration/Mvc/Collection/Behavior/Timestampable/NotifyCest.php deleted file mode 100644 index 469a5bd8bf8..00000000000 --- a/tests/integration/Mvc/Collection/Behavior/Timestampable/NotifyCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Behavior\Timestampable; - -use IntegrationTester; - -/** - * Class NotifyCest - */ -class NotifyCest -{ - /** - * Tests Phalcon\Mvc\Collection\Behavior\Timestampable :: notify() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionBehaviorTimestampableNotify(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Behavior\Timestampable - notify()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/CloneResultCest.php b/tests/integration/Mvc/Collection/CloneResultCest.php deleted file mode 100644 index 2e7c8fe16b3..00000000000 --- a/tests/integration/Mvc/Collection/CloneResultCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class CloneResultCest - */ -class CloneResultCest -{ - /** - * Tests Phalcon\Mvc\Collection :: cloneResult() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionCloneResult(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - cloneResult()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/ConstructCest.php b/tests/integration/Mvc/Collection/ConstructCest.php deleted file mode 100644 index 5ae30ec0db8..00000000000 --- a/tests/integration/Mvc/Collection/ConstructCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class ConstructCest - */ -class ConstructCest -{ - /** - * Tests Phalcon\Mvc\Collection :: __construct() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionConstruct(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - __construct()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/CountCest.php b/tests/integration/Mvc/Collection/CountCest.php deleted file mode 100644 index 474c0cf0a04..00000000000 --- a/tests/integration/Mvc/Collection/CountCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class CountCest - */ -class CountCest -{ - /** - * Tests Phalcon\Mvc\Collection :: count() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionCount(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - count()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/CreateCest.php b/tests/integration/Mvc/Collection/CreateCest.php deleted file mode 100644 index f613dda5633..00000000000 --- a/tests/integration/Mvc/Collection/CreateCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class CreateCest - */ -class CreateCest -{ - /** - * Tests Phalcon\Mvc\Collection :: create() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionCreate(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - create()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/CreateIfNotExistCest.php b/tests/integration/Mvc/Collection/CreateIfNotExistCest.php deleted file mode 100644 index 641af06997a..00000000000 --- a/tests/integration/Mvc/Collection/CreateIfNotExistCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class CreateIfNotExistCest - */ -class CreateIfNotExistCest -{ - /** - * Tests Phalcon\Mvc\Collection :: createIfNotExist() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionCreateIfNotExist(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - createIfNotExist()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/DeleteCest.php b/tests/integration/Mvc/Collection/DeleteCest.php deleted file mode 100644 index da6bc05488f..00000000000 --- a/tests/integration/Mvc/Collection/DeleteCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class DeleteCest - */ -class DeleteCest -{ - /** - * Tests Phalcon\Mvc\Collection :: delete() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDelete(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - delete()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Document/OffsetExistsCest.php b/tests/integration/Mvc/Collection/Document/OffsetExistsCest.php deleted file mode 100644 index dc2fdd6b021..00000000000 --- a/tests/integration/Mvc/Collection/Document/OffsetExistsCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Document; - -use IntegrationTester; - -/** - * Class OffsetExistsCest - */ -class OffsetExistsCest -{ - /** - * Tests Phalcon\Mvc\Collection\Document :: offsetExists() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDocumentOffsetExists(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Document - offsetExists()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Document/OffsetGetCest.php b/tests/integration/Mvc/Collection/Document/OffsetGetCest.php deleted file mode 100644 index 989dcd14308..00000000000 --- a/tests/integration/Mvc/Collection/Document/OffsetGetCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Document; - -use IntegrationTester; - -/** - * Class OffsetGetCest - */ -class OffsetGetCest -{ - /** - * Tests Phalcon\Mvc\Collection\Document :: offsetGet() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDocumentOffsetGet(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Document - offsetGet()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Document/OffsetSetCest.php b/tests/integration/Mvc/Collection/Document/OffsetSetCest.php deleted file mode 100644 index b9864e1f025..00000000000 --- a/tests/integration/Mvc/Collection/Document/OffsetSetCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Document; - -use IntegrationTester; - -/** - * Class OffsetSetCest - */ -class OffsetSetCest -{ - /** - * Tests Phalcon\Mvc\Collection\Document :: offsetSet() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDocumentOffsetSet(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Document - offsetSet()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Document/OffsetUnsetCest.php b/tests/integration/Mvc/Collection/Document/OffsetUnsetCest.php deleted file mode 100644 index 46c79ddb9c7..00000000000 --- a/tests/integration/Mvc/Collection/Document/OffsetUnsetCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Document; - -use IntegrationTester; - -/** - * Class OffsetUnsetCest - */ -class OffsetUnsetCest -{ - /** - * Tests Phalcon\Mvc\Collection\Document :: offsetUnset() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDocumentOffsetUnset(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Document - offsetUnset()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Document/ReadAttributeCest.php b/tests/integration/Mvc/Collection/Document/ReadAttributeCest.php deleted file mode 100644 index 4dc2a795fd6..00000000000 --- a/tests/integration/Mvc/Collection/Document/ReadAttributeCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Document; - -use IntegrationTester; - -/** - * Class ReadAttributeCest - */ -class ReadAttributeCest -{ - /** - * Tests Phalcon\Mvc\Collection\Document :: readAttribute() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDocumentReadAttribute(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Document - readAttribute()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Document/ToArrayCest.php b/tests/integration/Mvc/Collection/Document/ToArrayCest.php deleted file mode 100644 index 0953e6024cd..00000000000 --- a/tests/integration/Mvc/Collection/Document/ToArrayCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Document; - -use IntegrationTester; - -/** - * Class ToArrayCest - */ -class ToArrayCest -{ - /** - * Tests Phalcon\Mvc\Collection\Document :: toArray() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDocumentToArray(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Document - toArray()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Document/WriteAttributeCest.php b/tests/integration/Mvc/Collection/Document/WriteAttributeCest.php deleted file mode 100644 index d3222f9f9af..00000000000 --- a/tests/integration/Mvc/Collection/Document/WriteAttributeCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Document; - -use IntegrationTester; - -/** - * Class WriteAttributeCest - */ -class WriteAttributeCest -{ - /** - * Tests Phalcon\Mvc\Collection\Document :: writeAttribute() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionDocumentWriteAttribute(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Document - writeAttribute()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/FindByIdCest.php b/tests/integration/Mvc/Collection/FindByIdCest.php deleted file mode 100644 index dce91530e84..00000000000 --- a/tests/integration/Mvc/Collection/FindByIdCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class FindByIdCest - */ -class FindByIdCest -{ - /** - * Tests Phalcon\Mvc\Collection :: findById() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionFindById(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - findById()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/FindCest.php b/tests/integration/Mvc/Collection/FindCest.php deleted file mode 100644 index 3e281c35d83..00000000000 --- a/tests/integration/Mvc/Collection/FindCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class FindCest - */ -class FindCest -{ - /** - * Tests Phalcon\Mvc\Collection :: find() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionFind(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - find()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/FindFirstCest.php b/tests/integration/Mvc/Collection/FindFirstCest.php deleted file mode 100644 index 92d067a0cb2..00000000000 --- a/tests/integration/Mvc/Collection/FindFirstCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class FindFirstCest - */ -class FindFirstCest -{ - /** - * Tests Phalcon\Mvc\Collection :: findFirst() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionFindFirst(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - findFirst()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/FireEventCancelCest.php b/tests/integration/Mvc/Collection/FireEventCancelCest.php deleted file mode 100644 index f4a945ddae4..00000000000 --- a/tests/integration/Mvc/Collection/FireEventCancelCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class FireEventCancelCest - */ -class FireEventCancelCest -{ - /** - * Tests Phalcon\Mvc\Collection :: fireEventCancel() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionFireEventCancel(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - fireEventCancel()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/FireEventCest.php b/tests/integration/Mvc/Collection/FireEventCest.php deleted file mode 100644 index 93d1df6af9b..00000000000 --- a/tests/integration/Mvc/Collection/FireEventCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class FireEventCest - */ -class FireEventCest -{ - /** - * Tests Phalcon\Mvc\Collection :: fireEvent() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionFireEvent(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - fireEvent()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetCollectionManagerCest.php b/tests/integration/Mvc/Collection/GetCollectionManagerCest.php deleted file mode 100644 index 2fa887a021a..00000000000 --- a/tests/integration/Mvc/Collection/GetCollectionManagerCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetCollectionManagerCest - */ -class GetCollectionManagerCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getCollectionManager() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetCollectionManager(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getCollectionManager()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetConnectionCest.php b/tests/integration/Mvc/Collection/GetConnectionCest.php deleted file mode 100644 index 22a0d9297e1..00000000000 --- a/tests/integration/Mvc/Collection/GetConnectionCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetConnectionCest - */ -class GetConnectionCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getConnection() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetConnection(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getConnection()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetConnectionServiceCest.php b/tests/integration/Mvc/Collection/GetConnectionServiceCest.php deleted file mode 100644 index fffeacd5baf..00000000000 --- a/tests/integration/Mvc/Collection/GetConnectionServiceCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetConnectionServiceCest - */ -class GetConnectionServiceCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getConnectionService() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetConnectionService(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getConnectionService()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetDICest.php b/tests/integration/Mvc/Collection/GetDICest.php deleted file mode 100644 index 5764ab59f28..00000000000 --- a/tests/integration/Mvc/Collection/GetDICest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetDICest - */ -class GetDICest -{ - /** - * Tests Phalcon\Mvc\Collection :: getDI() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetDI(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getDI()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetDirtyStateCest.php b/tests/integration/Mvc/Collection/GetDirtyStateCest.php deleted file mode 100644 index 89928ec98d2..00000000000 --- a/tests/integration/Mvc/Collection/GetDirtyStateCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetDirtyStateCest - */ -class GetDirtyStateCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getDirtyState() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetDirtyState(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getDirtyState()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetIdCest.php b/tests/integration/Mvc/Collection/GetIdCest.php deleted file mode 100644 index 59bf6c28c42..00000000000 --- a/tests/integration/Mvc/Collection/GetIdCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetIdCest - */ -class GetIdCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getId() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetId(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getId()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetMessagesCest.php b/tests/integration/Mvc/Collection/GetMessagesCest.php deleted file mode 100644 index 7eda678ef28..00000000000 --- a/tests/integration/Mvc/Collection/GetMessagesCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetMessagesCest - */ -class GetMessagesCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getMessages() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetMessages(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getMessages()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetReservedAttributesCest.php b/tests/integration/Mvc/Collection/GetReservedAttributesCest.php deleted file mode 100644 index ba8aa1a0708..00000000000 --- a/tests/integration/Mvc/Collection/GetReservedAttributesCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetReservedAttributesCest - */ -class GetReservedAttributesCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getReservedAttributes() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetReservedAttributes(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getReservedAttributes()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/GetSourceCest.php b/tests/integration/Mvc/Collection/GetSourceCest.php deleted file mode 100644 index 611d82419b2..00000000000 --- a/tests/integration/Mvc/Collection/GetSourceCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class GetSourceCest - */ -class GetSourceCest -{ - /** - * Tests Phalcon\Mvc\Collection :: getSource() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionGetSource(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - getSource()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/AddBehaviorCest.php b/tests/integration/Mvc/Collection/Manager/AddBehaviorCest.php deleted file mode 100644 index 9d833ef34c1..00000000000 --- a/tests/integration/Mvc/Collection/Manager/AddBehaviorCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class AddBehaviorCest - */ -class AddBehaviorCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: addBehavior() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerAddBehavior(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - addBehavior()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/GetConnectionCest.php b/tests/integration/Mvc/Collection/Manager/GetConnectionCest.php deleted file mode 100644 index 403b23e712a..00000000000 --- a/tests/integration/Mvc/Collection/Manager/GetConnectionCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class GetConnectionCest - */ -class GetConnectionCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: getConnection() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerGetConnection(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - getConnection()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/GetConnectionServiceCest.php b/tests/integration/Mvc/Collection/Manager/GetConnectionServiceCest.php deleted file mode 100644 index fd6517bab51..00000000000 --- a/tests/integration/Mvc/Collection/Manager/GetConnectionServiceCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class GetConnectionServiceCest - */ -class GetConnectionServiceCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: getConnectionService() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerGetConnectionService(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - getConnectionService()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/GetCustomEventsManagerCest.php b/tests/integration/Mvc/Collection/Manager/GetCustomEventsManagerCest.php deleted file mode 100644 index 075b448f099..00000000000 --- a/tests/integration/Mvc/Collection/Manager/GetCustomEventsManagerCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class GetCustomEventsManagerCest - */ -class GetCustomEventsManagerCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: getCustomEventsManager() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerGetCustomEventsManager(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - getCustomEventsManager()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/GetDICest.php b/tests/integration/Mvc/Collection/Manager/GetDICest.php deleted file mode 100644 index f81c4983387..00000000000 --- a/tests/integration/Mvc/Collection/Manager/GetDICest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class GetDICest - */ -class GetDICest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: getDI() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerGetDI(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - getDI()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/GetEventsManagerCest.php b/tests/integration/Mvc/Collection/Manager/GetEventsManagerCest.php deleted file mode 100644 index fab9ecd16dc..00000000000 --- a/tests/integration/Mvc/Collection/Manager/GetEventsManagerCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class GetEventsManagerCest - */ -class GetEventsManagerCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: getEventsManager() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerGetEventsManager(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - getEventsManager()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/GetLastInitializedCest.php b/tests/integration/Mvc/Collection/Manager/GetLastInitializedCest.php deleted file mode 100644 index 9e700a8e381..00000000000 --- a/tests/integration/Mvc/Collection/Manager/GetLastInitializedCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class GetLastInitializedCest - */ -class GetLastInitializedCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: getLastInitialized() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerGetLastInitialized(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - getLastInitialized()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/GetServiceNameCest.php b/tests/integration/Mvc/Collection/Manager/GetServiceNameCest.php deleted file mode 100644 index fcb02c878d6..00000000000 --- a/tests/integration/Mvc/Collection/Manager/GetServiceNameCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class GetServiceNameCest - */ -class GetServiceNameCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: getServiceName() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerGetServiceName(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - getServiceName()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/InitializeCest.php b/tests/integration/Mvc/Collection/Manager/InitializeCest.php deleted file mode 100644 index 5078fc7fcba..00000000000 --- a/tests/integration/Mvc/Collection/Manager/InitializeCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class InitializeCest - */ -class InitializeCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: initialize() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerInitialize(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - initialize()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/IsInitializedCest.php b/tests/integration/Mvc/Collection/Manager/IsInitializedCest.php deleted file mode 100644 index 570370cf3fc..00000000000 --- a/tests/integration/Mvc/Collection/Manager/IsInitializedCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class IsInitializedCest - */ -class IsInitializedCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: isInitialized() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerIsInitialized(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - isInitialized()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/IsUsingImplicitObjectIdsCest.php b/tests/integration/Mvc/Collection/Manager/IsUsingImplicitObjectIdsCest.php deleted file mode 100644 index a0ad6758ca3..00000000000 --- a/tests/integration/Mvc/Collection/Manager/IsUsingImplicitObjectIdsCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class IsUsingImplicitObjectIdsCest - */ -class IsUsingImplicitObjectIdsCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: isUsingImplicitObjectIds() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerIsUsingImplicitObjectIds(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - isUsingImplicitObjectIds()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/MissingMethodCest.php b/tests/integration/Mvc/Collection/Manager/MissingMethodCest.php deleted file mode 100644 index ee0a461146c..00000000000 --- a/tests/integration/Mvc/Collection/Manager/MissingMethodCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class MissingMethodCest - */ -class MissingMethodCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: missingMethod() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerMissingMethod(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - missingMethod()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/NotifyEventCest.php b/tests/integration/Mvc/Collection/Manager/NotifyEventCest.php deleted file mode 100644 index 401de61de9a..00000000000 --- a/tests/integration/Mvc/Collection/Manager/NotifyEventCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class NotifyEventCest - */ -class NotifyEventCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: notifyEvent() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerNotifyEvent(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - notifyEvent()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/SetConnectionServiceCest.php b/tests/integration/Mvc/Collection/Manager/SetConnectionServiceCest.php deleted file mode 100644 index 10e8dec996c..00000000000 --- a/tests/integration/Mvc/Collection/Manager/SetConnectionServiceCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class SetConnectionServiceCest - */ -class SetConnectionServiceCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: setConnectionService() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerSetConnectionService(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - setConnectionService()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/SetCustomEventsManagerCest.php b/tests/integration/Mvc/Collection/Manager/SetCustomEventsManagerCest.php deleted file mode 100644 index da35523c320..00000000000 --- a/tests/integration/Mvc/Collection/Manager/SetCustomEventsManagerCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class SetCustomEventsManagerCest - */ -class SetCustomEventsManagerCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: setCustomEventsManager() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerSetCustomEventsManager(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - setCustomEventsManager()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/SetDICest.php b/tests/integration/Mvc/Collection/Manager/SetDICest.php deleted file mode 100644 index e1c3ca7d014..00000000000 --- a/tests/integration/Mvc/Collection/Manager/SetDICest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class SetDICest - */ -class SetDICest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: setDI() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerSetDI(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - setDI()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/SetEventsManagerCest.php b/tests/integration/Mvc/Collection/Manager/SetEventsManagerCest.php deleted file mode 100644 index 8c8039a0b14..00000000000 --- a/tests/integration/Mvc/Collection/Manager/SetEventsManagerCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class SetEventsManagerCest - */ -class SetEventsManagerCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: setEventsManager() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerSetEventsManager(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - setEventsManager()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/SetServiceNameCest.php b/tests/integration/Mvc/Collection/Manager/SetServiceNameCest.php deleted file mode 100644 index 0ee3e973887..00000000000 --- a/tests/integration/Mvc/Collection/Manager/SetServiceNameCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class SetServiceNameCest - */ -class SetServiceNameCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: setServiceName() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerSetServiceName(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - setServiceName()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Manager/UseImplicitObjectIdsCest.php b/tests/integration/Mvc/Collection/Manager/UseImplicitObjectIdsCest.php deleted file mode 100644 index 4479d713909..00000000000 --- a/tests/integration/Mvc/Collection/Manager/UseImplicitObjectIdsCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection\Manager; - -use IntegrationTester; - -/** - * Class UseImplicitObjectIdsCest - */ -class UseImplicitObjectIdsCest -{ - /** - * Tests Phalcon\Mvc\Collection\Manager :: useImplicitObjectIds() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionManagerUseImplicitObjectIds(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection\Manager - useImplicitObjectIds()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/ReadAttributeCest.php b/tests/integration/Mvc/Collection/ReadAttributeCest.php deleted file mode 100644 index 6a63d1fe970..00000000000 --- a/tests/integration/Mvc/Collection/ReadAttributeCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class ReadAttributeCest - */ -class ReadAttributeCest -{ - /** - * Tests Phalcon\Mvc\Collection :: readAttribute() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionReadAttribute(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - readAttribute()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/Refactor-BehaviorCest.php b/tests/integration/Mvc/Collection/Refactor-BehaviorCest.php deleted file mode 100644 index 4cab4b690c7..00000000000 --- a/tests/integration/Mvc/Collection/Refactor-BehaviorCest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @author Phalcon Team - * - * The contents of this file are subject to the New BSD License that is - * bundled with this package in the file LICENSE.txt - * - * If you did not receive a copy of the license and are unable to obtain it - * through the world-wide-web, please send an email to license@phalcon.io - * so that we can send you a copy immediately. - */ -class BehaviorCest -{ - use CollectionTrait; - - public function behaviors(IntegrationTester $I) - { - $this->setupMongo($I); - - $I->wantToTest('using behaviors with collections'); - - - - // Timestampable - $subscriber = new Subs(); - - $subscriber->email = 'some@some.com'; - $subscriber->status = 'I'; - - $I->assertTrue( - $subscriber->save() - ); - - $I->assertRegExp( - '/[0-9]{4}-[0-9]{2}-[0-9]{2}/', - $subscriber->created_at - ); - - - - // Soft delete - $total = Subs::count(); - $subscriber = Subs::findFirst(); - - $I->assertTrue( - $subscriber->delete() - ); - - $I->assertEquals( - 'D', - $subscriber->status - ); - - $I->assertEquals( - $total, - Subs::count() - ); - } -} diff --git a/tests/integration/Mvc/Collection/SaveCest.php b/tests/integration/Mvc/Collection/SaveCest.php deleted file mode 100644 index 1d11e055723..00000000000 --- a/tests/integration/Mvc/Collection/SaveCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SaveCest - */ -class SaveCest -{ - /** - * Tests Phalcon\Mvc\Collection :: save() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSave(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - save()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/SerializeCest.php b/tests/integration/Mvc/Collection/SerializeCest.php deleted file mode 100644 index 9e2c78b6967..00000000000 --- a/tests/integration/Mvc/Collection/SerializeCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SerializeCest - */ -class SerializeCest -{ - /** - * Tests Phalcon\Mvc\Collection :: serialize() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSerialize(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - serialize()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/SetConnectionServiceCest.php b/tests/integration/Mvc/Collection/SetConnectionServiceCest.php deleted file mode 100644 index 09131634cc1..00000000000 --- a/tests/integration/Mvc/Collection/SetConnectionServiceCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SetConnectionServiceCest - */ -class SetConnectionServiceCest -{ - /** - * Tests Phalcon\Mvc\Collection :: setConnectionService() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSetConnectionService(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - setConnectionService()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/SetDICest.php b/tests/integration/Mvc/Collection/SetDICest.php deleted file mode 100644 index 5b1a1a74355..00000000000 --- a/tests/integration/Mvc/Collection/SetDICest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SetDICest - */ -class SetDICest -{ - /** - * Tests Phalcon\Mvc\Collection :: setDI() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSetDI(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - setDI()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/SetDirtyStateCest.php b/tests/integration/Mvc/Collection/SetDirtyStateCest.php deleted file mode 100644 index 0c352561f6b..00000000000 --- a/tests/integration/Mvc/Collection/SetDirtyStateCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SetDirtyStateCest - */ -class SetDirtyStateCest -{ - /** - * Tests Phalcon\Mvc\Collection :: setDirtyState() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSetDirtyState(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - setDirtyState()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/SetIdCest.php b/tests/integration/Mvc/Collection/SetIdCest.php deleted file mode 100644 index 606d2f1ec14..00000000000 --- a/tests/integration/Mvc/Collection/SetIdCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SetIdCest - */ -class SetIdCest -{ - /** - * Tests Phalcon\Mvc\Collection :: setId() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSetId(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - setId()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/SkipOperationCest.php b/tests/integration/Mvc/Collection/SkipOperationCest.php deleted file mode 100644 index 961261299b3..00000000000 --- a/tests/integration/Mvc/Collection/SkipOperationCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SkipOperationCest - */ -class SkipOperationCest -{ - /** - * Tests Phalcon\Mvc\Collection :: skipOperation() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSkipOperation(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - skipOperation()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/SummatoryCest.php b/tests/integration/Mvc/Collection/SummatoryCest.php deleted file mode 100644 index 2409116f8d3..00000000000 --- a/tests/integration/Mvc/Collection/SummatoryCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class SummatoryCest - */ -class SummatoryCest -{ - /** - * Tests Phalcon\Mvc\Collection :: summatory() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionSummatory(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - summatory()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/ToArrayCest.php b/tests/integration/Mvc/Collection/ToArrayCest.php deleted file mode 100644 index d446544e010..00000000000 --- a/tests/integration/Mvc/Collection/ToArrayCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class ToArrayCest - */ -class ToArrayCest -{ - /** - * Tests Phalcon\Mvc\Collection :: toArray() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionToArray(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - toArray()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/UnserializeCest.php b/tests/integration/Mvc/Collection/UnserializeCest.php deleted file mode 100644 index dfbcdc6a568..00000000000 --- a/tests/integration/Mvc/Collection/UnserializeCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class UnserializeCest - */ -class UnserializeCest -{ - /** - * Tests Phalcon\Mvc\Collection :: unserialize() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionUnserialize(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - unserialize()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/UpdateCest.php b/tests/integration/Mvc/Collection/UpdateCest.php deleted file mode 100644 index d24dea265a6..00000000000 --- a/tests/integration/Mvc/Collection/UpdateCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class UpdateCest - */ -class UpdateCest -{ - /** - * Tests Phalcon\Mvc\Collection :: update() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionUpdate(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - update()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/ValidationHasFailedCest.php b/tests/integration/Mvc/Collection/ValidationHasFailedCest.php deleted file mode 100644 index 3d70047b1fe..00000000000 --- a/tests/integration/Mvc/Collection/ValidationHasFailedCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class ValidationHasFailedCest - */ -class ValidationHasFailedCest -{ - /** - * Tests Phalcon\Mvc\Collection :: validationHasFailed() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionValidationHasFailed(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - validationHasFailed()'); - $I->skipTest('Need implementation'); - } -} diff --git a/tests/integration/Mvc/Collection/WriteAttributeCest.php b/tests/integration/Mvc/Collection/WriteAttributeCest.php deleted file mode 100644 index ddda6e71927..00000000000 --- a/tests/integration/Mvc/Collection/WriteAttributeCest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -namespace Phalcon\Test\Integration\Mvc\Collection; - -use IntegrationTester; - -/** - * Class WriteAttributeCest - */ -class WriteAttributeCest -{ - /** - * Tests Phalcon\Mvc\Collection :: writeAttribute() - * - * @author Phalcon Team - * @since 2018-11-13 - */ - public function mvcCollectionWriteAttribute(IntegrationTester $I) - { - $I->wantToTest('Mvc\Collection - writeAttribute()'); - $I->skipTest('Need implementation'); - } -}