/** * Set default names for views and models * * @param array An optional associative array of configuration settings. * @return void */ protected function _setDefaultNames($config = array()) { parent::_setDefaultNames($config); $prefix = strtolower($this->getName()); $suffix = strtolower($this->getNameSuffix()); // Grid view name if (array_key_exists('list_view', $config)) { $this->_listView = $config['list_view']; } else { if (EInflector::isSingular($this->_defaultView)) { $this->_listView = EInflector::pluralize($this->_defaultView); } else { $this->_listView = $this->_defaultView; } } // Edit view name if (array_key_exists('item_view', $config)) { $this->_itemView = $config['item_view']; } else { $singularView = EInflector::singularize($this->_listView); if (!empty($singularView)) { $this->_itemView = $singularView; } else { if (!empty($suffix)) { $this->_itemView = $suffix; } else { $this->_itemView = $prefix; } } } }
/** * Set default names for views and models * * @param array An optional associative array of configuration settings. * @return void */ protected function _setDefaultNames($config = array()) { $prefix = strtolower($this->getName()); $suffix = strtolower($this->getNameSuffix()); // Default view name if (array_key_exists('default_view', $config)) { $this->_defaultView = $config['default_view']; } else { if (empty($suffix)) { // use the prefix $this->_defaultView = $prefix; } else { // Use suffix if it's plural, otherwise plurizalize it if (EInflector::isSingular($suffix)) { $this->_defaultView = EInflector::pluralize($suffix); } else { $this->_defaultView = $suffix; } } } // Default model name if (array_key_exists('default_model', $config)) { $this->_defaultModel = $config['default_model']; } else { // Default model names are always singular $this->_defaultModel = empty($suffix) ? $prefix : $suffix; } }
/** * Finds the database table name for this class * * @return string table name */ protected function _findTableName() { list($prefix, $suffix) = explode('Table', get_class($this), 2); if (empty($suffix)) { throw new Exception('Invalid Table Name: ' . get_class($this)); } $name = '#__' . (!empty($prefix) ? $prefix . '_' : '') . EInflector::pluralize($suffix); return strtolower($name); }
public function testOverride() { EInflector::addWord('test', 'different_plural'); $this->assertEquals('test', EInflector::singularize('different_plural')); $this->assertEquals('different_plural', EInflector::pluralize('test')); }