Пример #1
0
<?php

/*
 * Define custom routes. File gets included in the router service definition.
 */
$router = new \Phalcon\Mvc\Router();
//Remove trailing slashes automatically
$router->removeExtraSlashes(true);
$router->add('/([a-zA-Z\\-]+)/([a-zA-Z\\-]+)/:params', array('controller' => 1, 'action' => 2, 'params' => 3))->convert('action', function ($action) {
    return Phalcon\Text::camelize($action);
});
$router->add('/signup', array('namespace' => 'Talon\\Controllers', 'controller' => 'session', 'action' => 'signup'))->setName('session-signup');
$router->add('/login', array('namespace' => 'Talon\\Controllers', 'controller' => 'session', 'action' => 'login'))->setName('session-login');
$router->add('/forgot-password', array('namespace' => 'Talon\\Controllers', 'controller' => 'session', 'action' => 'forgotPassword'))->setName('session-forgotPassword');
$router->add('/reset-password/{code}/{email}', array('controller' => 'users_control', 'action' => 'resetPassword'))->setName('session-resetPassword');
$router->add('/confirm/{code}/{email}', array('controller' => 'users_control', 'action' => 'confirmEmail'))->setName('users_control-confirmEmail');
$router->add('/resend-confirmation/{email}', array('controller' => 'users_control', 'action' => 'resendConfirmation'))->setName('users_control-resendConfirmation');
return $router;
Пример #2
0
 /**
  * Magic method to use attribute in snake_case
  * For example $ex->a_method = $value is same as $ex->setAMethod($value)
  * @param string $property The property in snake_case
  * @param array $params The value that will be passed to set method
  * @return mixed Call the method if it exists, otherwise call parent __set() method
  */
 public function __set($property, $params)
 {
     $method = 'set' . Phalcon\Text::camelize($property);
     if (method_exists($this, $method)) {
         return $this->{$method}($params);
     }
     parent::__set($property, $params);
 }
Пример #3
0
<?php

//Create the router
//The order of routes in here DOES MATTER.  The list is in reverse, so routes lower in the list have higher precedence.
$router = new Phalcon\Mvc\Router();
$router->removeExtraSlashes(true);
$router->add("[/]{0,1}", array('controller' => 'default', 'action' => 'index'))->setName('base');
$router->add("/:controller", array('controller' => 1, 'action' => 'index'))->setName('index-action');
//
//
//$router->add(
//    "/:controller/:action/:params",
//    array(
//        'controller' => 1,
//        'action' => 2,
//        'params' => 3
//    )
//)
//->setName('full')
//->convert('action', function($action) {
//    return lcfirst(Phalcon\Text::camelize($action));
//});
$router->add("/:controller/:action/([\\d]+)/:params", array('controller' => 1, 'action' => 2, 'id' => 3, 'params' => 4))->setName('controller-action-id')->convert('action', function ($action) {
    return lcfirst(Phalcon\Text::camelize($action));
});
$router->add("/(login|logout)", array('controller' => 'default', 'action' => 1))->setName('default-action')->convert('action', function ($action) {
    return lcfirst(Phalcon\Text::camelize($action));
});
$router->add('/flush[/]?{id}', array('controller' => 'default', 'action' => 'flush'));
return $router;
Пример #4
0
<?php

echo Phalcon\Text::camelize('CocoBongo');
//coco_bongo
Пример #5
0
<?php

echo Phalcon\Text::camelize('coco_bongo');
//CocoBongo