当前位置: 首页>>代码示例>>PHP>>正文


PHP Inflector::ucwords方法代码示例

本文整理汇总了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>');
 }
开发者ID:rougin,项目名称:weasley,代码行数:39,代码来源:CreateViewCommand.php

示例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!', '-_ '));
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:9,代码来源:InflectorTest.php

示例3: ucwords

 public function ucwords($delimiters = " \n\t\r\v-")
 {
     return new static(Inflector::ucwords($this->var, $delimiters));
 }
开发者ID:php-genie,项目名称:genie,代码行数:4,代码来源:Str.php

示例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);
 }
开发者ID:rougin,项目名称:weasley,代码行数:24,代码来源:ControllerGenerator.php


注:本文中的Doctrine\Common\Inflector\Inflector::ucwords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。