Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getName()/setName() to Phalcon\Mvc\Router\Group #1775

Merged
merged 2 commits into from Jan 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
- Added Phalcon\Mvc\Model::selectWriteConnection() (#1519)
- Added Phalcon\Mvc\Router\Group::convert()/getConverters() (#1555, #1572)
- Added Phalcon\Mvc\Router\Route::getGroup() (#1682)
- Added Phalcon\Mvc\Router\Group::getName() and setName() (#1682)
- Faster Phalcon\Mvc\Model\Row (#1606)
- Optimized Phalcon\Mvc\Router\Group (#1682)
- Bug fix: no arguments were passed to beforeMatch handler in Phalcon\Mvc\Router (#1556)
Expand Down
28 changes: 28 additions & 0 deletions ext/mvc/router/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ PHALCON_INIT_CLASS(Phalcon_Mvc_Router_Group){
zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_routes"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_beforeMatch"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_converters"), ZEND_ACC_PROTECTED TSRMLS_CC);
zend_declare_property_null(phalcon_mvc_router_group_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC);

return SUCCESS;
}
Expand Down Expand Up @@ -473,3 +474,30 @@ PHP_METHOD(Phalcon_Mvc_Router_Group, getConverters) {

RETURN_MEMBER(this_ptr, "_converters");
}

/**
* Set the name of the group
*
* @param string $hostname
* @return Phalcon\Mvc\Router\Group
*/
PHP_METHOD(Phalcon_Mvc_Router_Group, setName){

zval **name;

phalcon_fetch_params_ex(1, 0, &name);

phalcon_update_property_this(this_ptr, SL("_name"), *name TSRMLS_CC);
RETURN_THISW();
}

/**
* Returns the name of this group
*
* @return string
*/
PHP_METHOD(Phalcon_Mvc_Router_Group, getName){


RETURN_MEMBER(this_ptr, "_name");
}
8 changes: 8 additions & 0 deletions ext/mvc/router/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ PHP_METHOD(Phalcon_Mvc_Router_Group, addHead);
PHP_METHOD(Phalcon_Mvc_Router_Group, clear);
PHP_METHOD(Phalcon_Mvc_Router_Group, convert);
PHP_METHOD(Phalcon_Mvc_Router_Group, getConverters);
PHP_METHOD(Phalcon_Mvc_Router_Group, setName);
PHP_METHOD(Phalcon_Mvc_Router_Group, getName);

ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_router_group___construct, 0, 0, 0)
ZEND_ARG_INFO(0, paths)
Expand Down Expand Up @@ -110,6 +112,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_router_group_convert, 0, 0, 2)
ZEND_ARG_INFO(0, converter)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_router_group_setname, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

PHALCON_INIT_FUNCS(phalcon_mvc_router_group_method_entry){
PHP_ME(Phalcon_Mvc_Router_Group, __construct, arginfo_phalcon_mvc_router_group___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Phalcon_Mvc_Router_Group, setHostname, arginfo_phalcon_mvc_router_group_sethostname, ZEND_ACC_PUBLIC)
Expand All @@ -133,6 +139,8 @@ PHALCON_INIT_FUNCS(phalcon_mvc_router_group_method_entry){
PHP_ME(Phalcon_Mvc_Router_Group, clear, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Mvc_Router_Group, convert, arginfo_phalcon_mvc_router_group_convert, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Mvc_Router_Group, getConverters, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Mvc_Router_Group, setName, arginfo_phalcon_mvc_router_group_setname, ZEND_ACC_PUBLIC)
PHP_ME(Phalcon_Mvc_Router_Group, getName, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};