本文整理汇总了PHP中Doctrine\Common\Inflector\Inflector::ucwords方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::ucwords方法的具体用法?PHP Inflector::ucwords怎么用?PHP Inflector::ucwords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Inflector\Inflector
的用法示例。
在下文中一共展示了Inflector::ucwords方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Executes the command.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return object|\Symfony\Component\Console\Output\OutputInterface
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$config = Configuration::get();
$templates = str_replace('Commands', 'Templates', __DIR__);
$contents = [];
$generator = new ViewGenerator($this->describe);
$data = ['{name}' => $input->getArgument('name'), '{pluralTitle}' => Inflector::ucwords(str_replace('_', ' ', Inflector::pluralize($input->getArgument('name')))), '{plural}' => Inflector::pluralize($input->getArgument('name')), '{singular}' => Inflector::singularize($input->getArgument('name'))];
$contents['create'] = $generator->generate($data, $templates, 'create');
$contents['edit'] = $generator->generate($data, $templates, 'edit');
$contents['index'] = $generator->generate($data, $templates, 'index');
$contents['show'] = $generator->generate($data, $templates, 'show');
$fileName = $config->folders->views . '/' . $data['{plural}'] . '/';
$layout = $config->folders->views . '/layouts/master.twig';
if (!$this->filesystem->has($layout)) {
$template = file_get_contents($templates . '/Views/layout.twig');
$keywords = ['{application}' => $config->application->name];
$template = str_replace(array_keys($keywords), array_values($keywords), $template);
$this->filesystem->write($layout, $template);
}
foreach ($contents as $type => $content) {
$view = $fileName . $type . '.twig';
if ($this->filesystem->has($view)) {
if (!$input->getOption('overwrite')) {
return $output->writeln('<error>View already exists.</error>');
} else {
$this->filesystem->delete($view);
}
}
$this->filesystem->write($view, $content);
}
return $output->writeln('<info>View created successfully.</info>');
}
示例2: testUcwordsWithCustomDelimeters
/**
* Test ucwords functionality with custom delimeters.
*
* @return void
*/
public function testUcwordsWithCustomDelimeters()
{
$this->assertSame('Top-O-The-Morning To All_Of_You!', Inflector::ucwords('top-o-the-morning to all_of_you!', '-_ '));
}
示例3: ucwords
public function ucwords($delimiters = " \n\t\r\v-")
{
return new static(Inflector::ucwords($this->var, $delimiters));
}
示例4: generateRoute
/**
* Generates route contents.
*
* @param string $routeContents
* @param string $tableName
*/
public function generateRoute(&$routeContents, $tableName)
{
$config = Configuration::get();
$lines = preg_split("/\\r\\n|\\r|\\n/", $routeContents);
$endBracket = $lines[count($lines) - 2];
if ($endBracket != '];') {
$endBracket = $lines[count($lines) - 1];
}
$template = $this->routesTemplate . $endBracket;
$routeContents = str_replace($endBracket, $template, $routeContents);
$keywords = [];
$keywords['{pluralTitle}'] = Inflector::classify(Inflector::pluralize($tableName));
$keywords['{pluralTitleDescription}'] = Inflector::ucwords(str_replace('_', ' ', Inflector::pluralize($tableName)));
$keywords['{plural}'] = Inflector::pluralize($tableName);
$keywords['{application}'] = $config->application->name;
$keywords['{namespace}'] = $config->namespaces->controllers;
$routeContents = str_replace(array_keys($keywords), array_values($keywords), $routeContents);
}