/** * Method to set a controller object attached to the dispatcher * * @param mixed $controller An object that implements KControllerInterface, KObjectIdentifier object * or valid identifier string * @param array $config An optional associative array of configuration options * @return KDispatcherAbstract */ public function setController($controller, $config = array()) { if (!$controller instanceof KControllerInterface) { if (is_string($controller) && strpos($controller, '.') === false) { // Controller names are always singular if (KStringInflector::isPlural($controller)) { $controller = KStringInflector::singularize($controller); } $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('controller'); $identifier['name'] = $controller; $identifier = $this->getIdentifier($identifier); } else { $identifier = $this->getIdentifier($controller); } //Set the configuration $identifier->getConfig()->append($config); $controller = $identifier; } $this->_controller = $controller; return $this; }
/** * Check if we are rendering an entity collection * * @return bool */ public function isCollection() { return KStringInflector::isPlural($this->getName()); }
/** * @dataProvider providePlurals */ public function testIsPlural($singular, $plural) { $this->assertTrue(KStringInflector::isPlural($plural)); }