public function getChangeDescription() { if ($this->count === 1) { return $this->changeInfos[0]->getChangeDescription(); } return sprintf("%s %d %s", Strings::capitalize(StringUtils::verbToPastTense($this->getAction())), $this->count, StringUtils::pluralize($this->getEntityName())); }
public function getChangeDescription() { if ($this->action === 'activate') { return "Site language switched to '{$this->languageName}'"; } return Strings::capitalize(StringUtils::verbToPastTense($this->action)) . " translation '{$this->languageName}'"; }
public function getChangeDescription() { if ($this->postType === "nav_menu_item") { return "Updated menu items"; } switch ($this->getAction()) { case "create": return "Created {$this->postType} '{$this->postTitle}'"; case "trash": return Strings::capitalize($this->postType) . " '{$this->postTitle}' moved to trash"; case "untrash": return Strings::capitalize($this->postType) . " '{$this->postTitle}' moved from trash"; case "delete": return "Deleted {$this->postType} '{$this->postTitle}'"; case "draft": return "Created draft for {$this->postType} '{$this->postTitle}'"; case "publish": return "Published {$this->postType} '{$this->postTitle}'"; } if (count(array_intersect(self::$CONTENT_PROPERTIES, explode(",", $this->postUpdatedProperties))) > 0) { return "Edited {$this->postType} '{$this->postTitle}'"; } else { return "Updated {$this->postType} '{$this->postTitle}'"; } }
public function getChangeDescription() { if ($this->action === 'switch') { return "Theme switched to '{$this->themeName}'"; } return Strings::capitalize(StringUtils::verbToPastTense($this->action)) . " theme '{$this->themeName}'"; }
public function getChangeDescription() { if ($this->count === 1) { return $this->changeInfos[0]->getChangeDescription(); } return Strings::capitalize(StringUtils::verbToPastTense($this->getAction())) . " {$this->count} options"; }
/** * @param \App\type $id * @return \App\PresenterLinkSettings */ public function create($id) { $item = $this->menuItemDataSource->get($id, function (Selection $context) { $pageKey = ':menu_has_page.page.id'; $context->select('section.module, menu.section_id, menu.name'); $context->select("{$pageKey}"); $context->where("{$pageKey} IS NOT NULL"); }); $module = Strings::capitalize($item->module); return $this->presenterLinkSettingsFactory->create(":{$module}:Page:default", ['id' => $item->id]); }
/** * @param \App\type $id * @return \App\PresenterLinkSettings */ public function create($id) { $item = $this->menuItemDataSource->get($id, function (Selection $context) { $pageKey = ':menu_has_presenter.presenter.code'; $context->select('section.module, menu.section_id, menu.name'); $context->select("{$pageKey}"); $context->where("{$pageKey} IS NOT NULL"); }); $module = Strings::capitalize($item->module); $presenter = Strings::firstUpper($item->code); return $this->presenterLinkSettingsFactory->create(":{$module}:{$presenter}:", []); }
public function getChangeDescription() { $entityName = $this->getScope(); $action = $this->getAction(); if ($this->count === 1) { $defaultDescription = $this->changeInfos[0]->getChangeDescription(); } else { $defaultDescription = sprintf("%s %d %s", Strings::capitalize(StringUtils::verbToPastTense($action)), $this->count, StringUtils::pluralize($entityName)); } $tags = array_map(function (TrackedChangeInfo $changeInfo) { return $changeInfo->getCustomTags(); }, $this->changeInfos); return apply_filters("vp_bulk_change_description_{$entityName}", $defaultDescription, $action, $this->count, $tags); }
public function getChangeDescription() { switch ($this->action) { case "install": // Pre-1.0-beta2 message, see also WP-219 return "Installed VersionPress"; case "activate": return "Activated VersionPress " . $this->versionPressVersion; case "deactivate": return "Deactivated VersionPress"; default: // just in case, this path shouldn't really be reached return Strings::capitalize(StringUtils::verbToPastTense($this->action)) . " VersionPress"; } }
public function getChangeDescription() { return Strings::capitalize(StringUtils::verbToPastTense($this->action)) . " plugin '{$this->pluginName}'"; }
/** * @param int $cityId * @return array */ protected function streetWithoutRegions($cityId, $title = NULL) { $data = []; if ($title) { $criteria = ['partCity.city.code' => $cityId, 'title LIKE' => '%' . $title . '%']; } else { $criteria = ['partCity.city.code' => $cityId]; } $streets = $this->streetRepository->findBy($criteria, ['title' => Criteria::ASC, 'id' => Criteria::ASC]); foreach ($streets as $street) { if (is_numeric($street->title) || array_key_exists($street->title, $this->tempArray)) { continue; } $this->tempArray[$street->title] = 1; $data[] = ['streetId' => $street->id, 'title' => Strings::capitalize($street->title), 'code' => $street->code]; } $city = $this->cityRepository->findOneBy(['code' => $cityId]); return ['city' => $city ? $city->title : NULL, 'streets' => $data]; }
/** * Converts the given string to "PascalCase". * @param string $string * @return string */ public static function toPascalCase($string) { return Strings::replace(Strings::capitalize(self::toSnakeCase($string)), '/[_-]/'); }
/** * @param Application\Request $request * * @return Application\IResponse * * @throws Application\BadRequestException */ public function run(Application\Request $request) { $this->request = $request; if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) { $refUrl = clone $this->httpRequest->getUrl(); $url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath())); if ($url !== NULL && !$this->httpRequest->getUrl()->isEqual($url)) { return new Application\Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY); } } $params = $request->getParameters(); if (!isset($params['action'])) { throw new Application\BadRequestException('Parameter action is missing.'); } if (!isset($params['id'])) { throw new Application\BadRequestException('Parameter id is missing.'); } // calls $this->action<Action>() if (!($response = $this->tryCall(Application\UI\Presenter::formatActionMethod(Utils\Strings::capitalize($params['action'])), $params))) { throw new Application\BadRequestException('Action not callable.'); } return $response; }
/** @var \VersionPress\Storages\StorageFactory $storageFactory */ $storageFactory = $versionPressContainer->resolve(VersionPressServices::STORAGE_FACTORY); /** @var \VersionPress\Storages\DirectoryStorage $termStorage */ $termStorage = $storageFactory->getStorage('term'); $termId = isset($newEntity['vp_term_id']) ? $newEntity['vp_term_id'] : $oldEntity['vp_term_id']; $term = $termStorage->loadEntity($termId); $tags['VP-Term-Name'] = $term['name']; return $tags; }, 10, 4); add_filter('vp_entity_files_term_taxonomy', function ($files, $oldEntity, $newEntity) { $files[] = ["type" => "all-storage-files", "entity" => "option"]; // sometimes term change can affect option (e.g. deleting menu) return $files; }, 10, 3); add_filter('vp_bulk_change_description_composer', function ($description, $action, $count) { return sprintf("%s %d Composer packages", Strings::capitalize(StringUtils::verbToPastTense($action)), $count); }, 10, 3); add_filter('vp_bulk_change_description_revert', function ($description, $action, $count) { if ($action === 'undo' || $action === 'rollback') { return "Reverted" . " {$count} changes"; } return $description; }, 10, 3); add_filter('vp_meta_entity_tags_postmeta', function ($tags, $oldEntity, $newEntity, $action, $oldParent, $newParent) { $tags['VP-Post-Type'] = isset($newParent['post_type']) ? $newParent['post_type'] : $oldParent['post_type']; $tags['VP-Post-Title'] = isset($newParent['post_title']) ? $newParent['post_title'] : $oldParent['post_title']; return $tags; }, 10, 6); add_filter('vp_meta_entity_files_postmeta', function ($files, $oldEntity, $newEntity, $oldParentEntity, $newParentEntity) { $postType = isset($newParentEntity['post_type']) ? $newParentEntity['post_type'] : $oldParentEntity['post_type']; if ($postType !== "attachment") {
/** * Converts the given string to `StudlyCase` * @param string $string * @return string */ public static function studlyCase($string) { $string = Strings::capitalize(Strings::replace($string, ['/-/', '/_/'], ' ')); return Strings::replace($string, '/ /'); }
/** * Get winner announcement. * * @param string $winner * @return string */ private function getMessageForWinner($winner) { return Strings::capitalize($winner) . ' is the winner! Congratulations!'; }
function getChangeDescription() { return Strings::capitalize(StringUtils::verbToPastTense($this->getAction())) . " option '{$this->getEntityId()}'"; }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $languageArgument = $input->getArgument(self::LANGUAGE_ARGUMENT); /** @var Language $language */ if (($language = $this->languagesRepository->findOneBy(['shortCode' => $languageArgument])) === NULL) { $output->writeln("<error>Unknown language {$languageArgument}</error>"); return 1; } /** @var Season $season */ foreach ($this->seasonsRepository->findBy(['language' => $language]) as $season) { foreach ($season->getEpisodes() as $episode) { $file = "S{$season->getNumber()}E{$episode->getNumber()}{$language->getShortCode()}.txt"; $handle = fopen($this->scenariosDir . '/' . $file, 'r'); if ($handle) { $screenplayLine = 1; while (($line = fgets($handle)) !== FALSE) { $name = Strings::before($line, ':'); $isCharacter = $name && !in_array($name, self::KNOWN_NON_CHARACTERS, TRUE) && str_word_count($name, 0) < 3 ? TRUE : FALSE; $character = $isCharacter ? $this->charactersRepository->findOneBy(['slug' => Strings::webalize($name), 'language' => $language]) : NULL; if ($isCharacter && $character === NULL) { $character = new Character(Strings::capitalize($name), $language); $this->entityManager->persist($character); $this->entityManager->flush($character); } $text = $isCharacter ? str_replace($name . ': ', '', $line) : $line; $text = Strings::trim($text); if (empty($text)) { continue; } $screenplay = new Screenplay($episode, $text, $character, $screenplayLine, !$isCharacter); $this->entityManager->persist($screenplay); $this->entityManager->flush($screenplay); $screenplayLine++; } fclose($handle); } else { $output->writeln("<error>Scénář {$file} neexistuje!</error>"); return 1; } } } return 0; }
public function getChangeDescription() { return Strings::capitalize(StringUtils::verbToPastTense($this->getAction())) . " {$this->count} translations"; }
/** * @param string $name * @param mixed $args * * @return mixed * * @throws Exceptions\DecoratorNotRegisteredException */ public function __call($name, $args) { if (Utils\Strings::startsWith($name, 'render')) { // Get decorator name if ($decoratorName = Utils\Strings::capitalize(Utils\Strings::substring($name, 6))) { // Set widget decorator $this->setDecorator($decoratorName); } // Call component rendering $this->render(); } else { return parent::__call($name, $args); } }