public function testSlugify() { $this->assertEquals('hello-world', Inflector::slugify('Hello world!'), 'removing chars and spaces'); $this->assertEquals('hello-world', Inflector::slugify('_hello_!world'), 'underscore char at the begin'); $this->assertEquals('privet-habr', Inflector::slugify('Привет хабр!'), 'russian slug'); }
/** * @param Model $caller */ public function preSave($caller) { if (array_key_exists($this->_sourceField, $caller->getChangedData())) { $caller->{$this->_valueField} = Inflector::slugify($caller->getChangedData($this->_sourceField)); } }
protected function detectTemplate() { $route = DC::getApplication()->getRoute(); $folder = Inflector::slugify(substr($route->getControllerName(), 0, -10)); $action = Inflector::slugify(substr($route->getActionName(), 0, -6)); if (is_file($this->getTemplatesPath() . $folder . '/' . $action . '.slot')) { $this->setTemplateName($folder . '/' . $action); } elseif (is_file($this->getTemplatesPath() . $action . '.slot')) { $this->setTemplateName($action); } else { throw new \Exception('Cannot detect template:' . $folder . '/' . $action); } }