Skip to content

Commit

Permalink
Added Phalcon\Mvc\View __isset Magic method
Browse files Browse the repository at this point in the history
  • Loading branch information
kamijo committed Jul 25, 2013
1 parent 272160f commit 1de706a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ext/mvc/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1808,3 +1808,30 @@ PHP_METHOD(Phalcon_Mvc_View, __get){
RETURN_MM_NULL();
}


/**
* Magic method to inaccessible a variable passed to the view
*
*<code>
* isset($this->view->products)
*</code>
*
* @param string $key
* @return mixed
*/
PHP_METHOD(Phalcon_Mvc_View, __isset){

zval *key, *params;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &key);

PHALCON_OBS_VAR(params);
phalcon_read_property_this(&params, this_ptr, SL("_viewParams"), PH_NOISY_CC);
if (phalcon_array_isset(params, key)) {
RETURN_MM_TRUE;
}

RETURN_MM_FALSE;
}
2 changes: 2 additions & 0 deletions ext/mvc/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ PHP_METHOD(Phalcon_Mvc_View, enable);
PHP_METHOD(Phalcon_Mvc_View, reset);
PHP_METHOD(Phalcon_Mvc_View, __set);
PHP_METHOD(Phalcon_Mvc_View, __get);
PHP_METHOD(Phalcon_Mvc_View, __isset);

ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_view___construct, 0, 0, 0)
ZEND_ARG_INFO(0, options)
Expand Down Expand Up @@ -223,6 +224,7 @@ PHALCON_INIT_FUNCS(phalcon_mvc_view_method_entry){
PHP_ME(Phalcon_Mvc_View, reset, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Mvc_View, __set, arginfo_phalcon_mvc_view___set, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Mvc_View, __get, arginfo_phalcon_mvc_view___get, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Mvc_View, __isset, arginfo_phalcon_mvc_view___get, ZEND_ACC_PUBLIC)
PHP_FE_END
};

0 comments on commit 1de706a

Please sign in to comment.