當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。