當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Container::underscore方法代碼示例

本文整理匯總了PHP中Container::underscore方法的典型用法代碼示例。如果您正苦於以下問題:PHP Container::underscore方法的具體用法?PHP Container::underscore怎麽用?PHP Container::underscore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Container的用法示例。


在下文中一共展示了Container::underscore方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAlias

 /**
  * Returns the recommended alias to use in XML.
  *
  * This alias is also the mandatory prefix to use when using YAML.
  *
  * This convention is to remove the "Extension" postfix from the class
  * name and then lowercase and underscore the result. So:
  *
  *     AcmeHelloExtension
  *
  * becomes
  *
  *     acme_hello
  *
  * This can be overridden in a sub-class to specify the alias manually.
  *
  * @return string The alias
  *
  * @throws \BadMethodCallException When the extension name does not follow conventions
  */
 public function getAlias()
 {
     $className = get_class($this);
     if (substr($className, -9) != 'Extension') {
         throw new \BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
     }
     $classBaseName = substr(strrchr($className, '\\'), 1, -9);
     return Container::underscore($classBaseName);
 }
開發者ID:simple-php-mvc,項目名稱:simple-php-mvc,代碼行數:29,代碼來源:Extension.php

示例2: generateAdmin

 /**
  * @param QuestionHelper $question
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param BundleInterface $bundle
  * @param $metadata
  * @param $entity
  * @param $filename
  */
 protected function generateAdmin(QuestionHelper $question, InputInterface $input, OutputInterface $output, BundleInterface $bundle, $metadata, $entity, $filename)
 {
     $auto = true;
     if ($input->isInteractive()) {
         $auto = $question->ask($input, $output, new ConfirmationQuestion('Confirm automatic generation of the Admin service?', false));
     }
     if ($auto) {
         $group = ucfirst(str_replace('_', ' ', Container::underscore(substr($bundle->getName(), 0, -6))));
         $label = $entity;
         $translationDomain = 'Sonata';
         $groupQuestion = new Question('Group for the admin service: ', $group);
         $groupQuestion->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
         $groupQuestion->setAutocompleterValues([$group]);
         $group = $question->ask($input, $output, $groupQuestion);
         $labelQuestion = new Question('Label for the admin service: ', $label);
         $labelQuestion->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
         $labelQuestion->setAutocompleterValues([$label]);
         $label = $question->ask($input, $output, $labelQuestion);
         $translationDomainQuestion = new Question('Translation domain for the admin service: ', $translationDomain);
         $translationDomainQuestion->setAutocompleterValues([$translationDomain]);
         $translationDomain = $question->ask($input, $output, $labelQuestion);
         $output->write('Creating the service: ');
         $this->getContainer()->get('filesystem')->mkdir($bundle->getPath() . '/Resources/config/');
         $admin = new AdminManipulator($bundle->getPath() . '/Resources/config/' . $filename);
         try {
             $ret = $auto ? $admin->addResource($bundle, $entity, $group, $label, $translationDomain) : false;
         } catch (\RuntimeException $exc) {
             $ret = false;
         }
         if ($ret) {
             $output->write('Creating the Admin class: ');
             $generator = $this->getGenerator($bundle);
             $generator->generateAdminClass($metadata[0], $input->getOption('overwrite'));
         }
     }
 }
開發者ID:stopfstedt,項目名稱:TdnPilotBundle,代碼行數:45,代碼來源:GenerateSonataCommand.php

示例3: underscore

 public static function underscore($string)
 {
     return Container::underscore($string);
 }
開發者ID:nuxia,項目名稱:nuxia-plugin,代碼行數:4,代碼來源:StringHelper.php


注:本文中的Container::underscore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。