1 
2 #ifdef HAVE_CONFIG_H
3 #include "../../../../../ext_config.h"
4 #endif
5 
6 #include <php.h>
7 #include "../../../../../php_ext.h"
8 #include "../../../../../ext.h"
9 
10 #include <Zend/zend_operators.h>
11 #include <Zend/zend_exceptions.h>
12 #include <Zend/zend_interfaces.h>
13 
14 #include "kernel/main.h"
15 #include "kernel/object.h"
16 #include "kernel/fcall.h"
17 #include "kernel/memory.h"
18 #include "kernel/operators.h"
19 
20 
21 /**
22  * Phalcon\Mvc\View\Exception
23  *
24  * Class for exceptions thrown by Phalcon\Mvc\View
25  */
ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Engine_Volt_Exception)26 ZEPHIR_INIT_CLASS(Phalcon_Mvc_View_Engine_Volt_Exception) {
27 
28 	ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\View\\Engine\\Volt, Exception, phalcon, mvc_view_engine_volt_exception, phalcon_mvc_view_exception_ce, phalcon_mvc_view_engine_volt_exception_method_entry, 0);
29 
30 	zend_declare_property_null(phalcon_mvc_view_engine_volt_exception_ce, SL("statement"), ZEND_ACC_PROTECTED TSRMLS_CC);
31 
32 	return SUCCESS;
33 
34 }
35 
PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Exception,__construct)36 PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Exception, __construct) {
37 
38 	zend_long code, ZEPHIR_LAST_CALL_STATUS;
39 	zval *statement = NULL;
40 	zval *message_param = NULL, *statement_param = NULL, *code_param = NULL, *previous = NULL, *_0;
41 	zval *message = NULL;
42 
43 	ZEPHIR_MM_GROW();
44 	zephir_fetch_params(1, 0, 4, &message_param, &statement_param, &code_param, &previous);
45 
46 	if (!message_param) {
47 		ZEPHIR_INIT_VAR(message);
48 		ZVAL_STRING(message, "", 1);
49 	} else {
50 		zephir_get_strval(message, message_param);
51 	}
52 	if (!statement_param) {
53 		ZEPHIR_INIT_VAR(statement);
54 		array_init(statement);
55 	} else {
56 		zephir_get_arrval(statement, statement_param);
57 	}
58 	if (!code_param) {
59 		code = 0;
60 	} else {
61 		code = zephir_get_intval(code_param);
62 	}
63 	if (!previous) {
64 		previous = ZEPHIR_GLOBAL(global_null);
65 	}
66 
67 
68 	zephir_update_property_this(getThis(), SL("statement"), statement TSRMLS_CC);
69 	ZEPHIR_INIT_VAR(_0);
70 	ZVAL_LONG(_0, code);
71 	ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_view_engine_volt_exception_ce, getThis(), "__construct", NULL, 0, message, _0, previous);
72 	zephir_check_call_status();
73 	ZEPHIR_MM_RESTORE();
74 
75 }
76 
77 /**
78  * Gets currently parsed statement (if any).
79  */
PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Exception,getStatement)80 PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Exception, getStatement) {
81 
82 	zval *statement = NULL, *_0;
83 
84 	ZEPHIR_MM_GROW();
85 
86 	_0 = zephir_fetch_nproperty_this(this_ptr, SL("statement"), PH_NOISY_CC);
87 	ZEPHIR_CPY_WRT(statement, _0);
88 	if (Z_TYPE_P(statement) != IS_ARRAY) {
89 		ZEPHIR_INIT_NVAR(statement);
90 		array_init(statement);
91 	}
92 	RETURN_CCTOR(statement);
93 
94 }
95 
96