From Doctrine comments: Pluralize & Singularize implementation are borrowed from CakePHP with some modifications.
 public static function module($module)
 {
     $module = Inflector::pluralize($module);
     return new static($module);
 }
Exemplo n.º 2
0
 private function prepareResourceControllerName()
 {
     $parts = explode('_', $this->controller);
     if (in_array($this->action, array('index', 'create'))) {
         $suffix = array_pop($parts);
     } else {
         $suffix = Inflector::singularize(array_pop($parts));
     }
     $parts[] = $suffix;
     return implode('_', $parts);
 }
Exemplo n.º 3
0
 /**
  * Test resetting inflection rules.
  *
  * @return void
  */
 public function testCustomRuleWithReset()
 {
     Inflector::reset();
     $uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x');
     $pluralIrregular = array('as' => 'ases');
     Inflector::rules('singular', array('rules' => array('/^(.*)(a|e|o|u)is$/i' => '\\1\\2l'), 'uninflected' => $uninflected), true);
     Inflector::rules('plural', array('rules' => array('/^(.*)(a|e|o|u)l$/i' => '\\1\\2is'), 'uninflected' => $uninflected, 'irregular' => $pluralIrregular), true);
     $this->assertEquals(Inflector::pluralize('Alcool'), 'Alcoois');
     $this->assertEquals(Inflector::pluralize('Atlas'), 'Atlas');
     $this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');
     $this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');
 }
 public static function createModule($moduleName)
 {
     $moduleName = ucfirst(Inflector::singularize($moduleName));
     $moduleName = Strings::appendPrefix($moduleName, '\\SugarClient\\Module\\');
     return new $moduleName();
 }
Exemplo n.º 5
0
 private function classNameFromTableName()
 {
     $parts = explode('_', $this->tableName);
     $parts = $this->removeTablePrefix($parts);
     $parts[] = Inflector::singularize(array_pop($parts));
     $parts = Arrays::map($parts, 'ucfirst');
     return implode('', $parts);
 }
Exemplo n.º 6
0
 /**
  * @return string
  */
 public function getNameForObject()
 {
     return Inflector::singularize(ucfirst($this->getSanitizedName()));
 }
Exemplo n.º 7
0
 public static function getModuleName()
 {
     $reflectionClass = new ReflectionClass(get_called_class());
     return Inflector::pluralize($reflectionClass->getShortName());
 }
Exemplo n.º 8
-1
 protected function _generateArray(Type $parameter)
 {
     $type = $parameter->getComplexType() ? 'ns:' : 'xsd:';
     $typesComplex = new TypesComplex();
     $typesComplex->setName('ArrayOf' . ucfirst($parameter->getName()))->setArrayType($type . $this->_getObjectName($parameter) . '[]')->setArrayTypeName(Inflector::singularize($parameter->getName()));
     if ($parameter->getComplexType()) {
         $typesComplex->setComplex($this->_generateObject($parameter->getComplexType()));
     }
     return $typesComplex;
 }