public function testPluralisation() { $words = ["church" => "churches", "goat" => "goats", "ship" => "ships", "company" => "companies", "fox" => "foxes", "grass" => "grasses"]; foreach ($words as $singular => $plural) { $this->assertEquals($plural, StringTools::makePlural($singular)); } }
protected function getTitle() { if ($this->restModel !== null) { if ($this->restModel->isNewRecord()) { return "Adding a new " . strtolower(StringTools::wordifyStringByUpperCase(SolutionSchema::getModelNameFromClass(get_class($this->restModel)))) . " entry"; } else { return ucfirst(strtolower(StringTools::wordifyStringByUpperCase(SolutionSchema::getModelNameFromClass(get_class($this->restModel)))) . " '" . $this->restModel->GetLabel() . "'"); } } else { if ($this->restCollection !== null) { return StringTools::wordifyStringByUpperCase(StringTools::makePlural(SolutionSchema::getModelNameFromClass($this->restCollection->getModelClassName()))); } else { return "Untitled"; } } }
protected function onBeforePrintViewContent() { parent::onBeforePrintViewContent(); $restModel = $this->raiseEvent("GetRestModel"); if (is_object($restModel)) { $pageSettings = new HtmlPageSettings(); if ($restModel instanceof Model) { if ($restModel->isNewRecord()) { $pageSettings->PageTitle = "Add a " . $restModel->getModelName(); } else { $pageSettings->PageTitle = "Editing " . $restModel->getModelName() . " '" . $restModel->getLabel() . "'"; } } elseif ($restModel instanceof Collection) { $pageSettings->PageTitle = StringTools::pluralise($restModel->getModelName(), 2); } } }
public function __construct($name) { $this->name = $name; $this->label = StringTools::wordifyStringByUpperCase($name); }
protected function registerUrlHandlers() { $this->addUrlHandlers(["/communications/" => new CrudUrlHandler(Communication::class, StringTools::getNamespaceFromClass(CommunicationCollection::class)), "/communication-items/" => new CrudUrlHandler(CommunicationItem::class, StringTools::getNamespaceFromClass(CommunicationItemCollection::class), ['archive' => CommunicationItemArchiveCollection::class])]); }