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


PHP Option::setName方法代碼示例

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


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

示例1: testSetOptionName

 function testSetOptionName()
 {
     //arrange
     $name = "peanut allergy";
     $test_allergy = new Option($name);
     //act
     $test_allergy->setName("peanut allergy");
     $result = $test_allergy->getName();
     //assert
     $this->assertEquals("peanut allergy", $result);
 }
開發者ID:ben-pritchard,項目名稱:allergen_avoider,代碼行數:11,代碼來源:OptionTest.php

示例2: getListOptions

 /**
  * @param $renderApi
  * @param $unit
  * @return IOptionProvider
  */
 public function getListOptions($renderApi, $unit)
 {
     $options = preg_split('/\\n/', $renderApi->getFormValue($unit, 'listFieldOptions'));
     foreach ($options as $option) {
         $checked = false;
         if (preg_match('/\\*$/', $option)) {
             $checked = true;
             $option = preg_replace('/\\*$/', '', $option);
         }
         $optionObj = new \Option();
         $optionObj->setName($option);
         $optionObj->setValue($option);
         $optionObj->setChecked($checked);
         $this->optionProvider->addOption($optionObj);
     }
     return $this->optionProvider;
 }
開發者ID:rukzuk,項目名稱:rukzuk,代碼行數:22,代碼來源:ListOptions.php

示例3: testSetName

 /**
  * @covers Phossa\Console\Option::setName
  */
 public function testSetName()
 {
     $this->object->setName('test');
     $this->assertEquals('test', $this->object->getName());
 }
開發者ID:phossa,項目名稱:phossa-console,代碼行數:8,代碼來源:OptionTest.php

示例4: main

 /**
  * The main entry point method.
  */
 public function main()
 {
     $command = array();
     $command[] = !empty($this->bin) ? $this->bin : 'drush';
     if (!empty($this->alias)) {
         $command[] = $this->alias;
     }
     if (empty($this->color)) {
         $option = new Option();
         $option->setName('nocolor');
         $this->options[] = $option;
     }
     if (!empty($this->root)) {
         $option = new Option();
         $option->setName('root');
         $option->addText($this->root);
         $this->options[] = $option;
     }
     if (!empty($this->uri)) {
         $option = new Option();
         $option->setName('uri');
         $option->addText($this->uri);
         $this->options[] = $option;
     }
     if (!empty($this->config)) {
         $option = new Option();
         $option->setName('config');
         $option->addText($this->config);
         $this->options[] = $option;
     }
     if (!empty($this->aliasPath)) {
         $option = new Option();
         $option->setName('alias-path');
         $option->addText($this->aliasPath);
         $this->options[] = $option;
     }
     if (is_bool($this->assume)) {
         $option = new Option();
         $option->setName($this->assume ? 'yes' : 'no');
         $this->options[] = $option;
     }
     if ($this->simulate) {
         $option = new Option();
         $option->setName('simulate');
         $this->options[] = $option;
     }
     if ($this->pipe) {
         $option = new Option();
         $option->setName('pipe');
         $this->options[] = $option;
     }
     if ($this->verbose) {
         $option = new Option();
         $option->setName('verbose');
         $this->options[] = $option;
     }
     foreach ($this->options as $option) {
         $command[] = $option->toString();
     }
     $command[] = $this->command;
     foreach ($this->params as $param) {
         $command[] = '"' . escapeshellcmd($param->getValue()) . '"';
     }
     $command = implode(' ', $command);
     if ($this->dir !== NULL) {
         $currdir = getcwd();
         @chdir($this->dir->getPath());
     }
     // Execute Drush.
     $this->log("Executing '{$command}'...");
     $output = array();
     exec($command, $output, $return);
     if (isset($currdir)) {
         @chdir($currdir);
     }
     // Collect Drush output for display through Phing's log.
     foreach ($output as $line) {
         $this->log($line);
     }
     // Set value of the 'pipe' property.
     if (!empty($this->returnProperty)) {
         $this->getProject()->setProperty($this->returnProperty, implode($this->returnGlue, $output));
     }
     // Build fail.
     if ($this->haltOnError && $return != 0) {
         throw new \BuildException("Drush exited with code {$return}");
     }
     return $return != 0;
 }
開發者ID:anton87gp,項目名稱:phing-drush-task,代碼行數:92,代碼來源:Task.php


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