/** * {@inheritdoc} */ public function resolve(&$value) { if (is_string($value) && strlen($value) > 0) { $value = \Phalcon\Text::lower($value); } return $value; }
/** * Cast value to string * @param $value * @return string */ public function cast($value) { if ($this->_trim === null && self::$_defaultTrim !== null) { $this->_trim = self::$_defaultTrim; } if (is_scalar($value)) { $value = (string) $value; if ($this->_trim === true) { $value = trim($value); } if ($this->_uppercase === true) { $value = \Phalcon\Text::upper($value); } elseif ($this->_lowercase === true) { $value = \Phalcon\Text::lower($value); } return $value; } return ''; }
/** * Initializes dispatcher */ public function register() { $di = $this->getDi(); $eventsManager = $this->getEventsManager(); $config = $this->_config; $defaultModuleDir = $this->_module->getDefaultModuleDirectory(); $di->set('defualtModuleDir', function () use($defaultModuleDir) { return $defaultModuleDir; }); $moduleDirectory = $this->_module->getModuleDirectory(); $di->set('moduleDirectory', function () use($moduleDirectory) { return $moduleDirectory; }); $di->set('dispatcher', function () use($di, $eventsManager, $config) { // Create dispatcher $dispatcher = new MvcDispatcher(); //Attach a listener $eventsManager->attach("dispatch:beforeException", function ($event, \Phalcon\Mvc\Dispatcher $dispatcher, $exception) use($di, $config) { if ($config->application->debug && $di->has('logger')) { $logger = $di->get('logger'); $logger->error($exception->getMessage()); } //Handle 404 exceptions if ($exception instanceof DispatchException) { $dispatcher->forward(['controller' => 'error', 'action' => 'show404']); return false; } if ($di->get('request')->isAjax() == true) { } //Handle other exceptions $dispatcher->forward(['controller' => 'error', 'action' => 'show503']); return false; }); $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, \Phalcon\Mvc\Dispatcher $dispatcher) { $dispatcher->setControllerName(\Phalcon\Text::lower($dispatcher->getControllerName())); }); $dispatcher->setEventsManager($eventsManager); return $dispatcher; }); }
$url->setBaseUri("http://" . $_SERVER["SERVER_NAME"] . "/"); return $url; }); $di->set('router', function () { $router = new \Phalcon\Mvc\Router(); $router->setDefaultModule("frontend"); $router->add("/", array('module' => 'frontend', 'controller' => 'index', 'action' => 'index')); $router->add("/contactanos", array('module' => 'frontend', 'controller' => 'index', 'action' => 'contactanos')); $router->add("/token", array('module' => 'frontend', 'controller' => 'index', 'action' => 'token')); $router->notFound(array('module' => 'frontend', 'controller' => 'index', 'action' => 'show404')); /* Dashboard */ $router->add("/dashboard", array('module' => 'dashboard', 'controller' => 'index', 'action' => 'index')); $router->add("/login", array('module' => 'dashboard', 'controller' => 'login', 'action' => 'index')); $router->add("/logout", array('module' => 'dashboard', 'controller' => 'login', 'action' => 'logout')); $router->add('/dashboard/([a-zA-Z\\-]+)/([a-zA-Z\\-]+)', array('module' => 'dashboard', 'controller' => 1, 'action' => 2))->setName("controllers")->convert('action', function ($action) { return \Phalcon\Text::lower(\Phalcon\Text::camelize($action)); }); $router->removeExtraSlashes(true); return $router; }); /** * Start the session the first time some component request the session service */ $di->set('dispatcher', function () use($di) { $dispatcher = new \Phalcon\Mvc\Dispatcher(); $eventsManager = $di->getShared('eventsManager'); $security = new Security($di); $eventsManager->attach('dispatch', $security); $dispatcher->setEventsManager($eventsManager); return $dispatcher; });
public static function lower($str) { return parent::lower($str); }
public static function lower($str, $encoding = "UTF-8") { return parent::lower($str, $encoding); }
public function testLower() { $this->assertEquals(PhText::lower('hello'), 'hello'); $this->assertEquals(PhText::lower('HELLO'), 'hello'); $this->assertEquals(PhText::lower('1234'), '1234'); }
public function testLowerException() { $this->setExpectedException('\\Phalcon\\Exception'); \Phalcon\Text::lower(13.43); }