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


PHP Option类代码示例

本文整理汇总了PHP中Option的典型用法代码示例。如果您正苦于以下问题:PHP Option类的具体用法?PHP Option怎么用?PHP Option使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Option类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: offsetSet

 /**
  * Set a new option.
  *
  * @param   string  $name    No use here, we use option name.
  * @param   Option  $option  The option object to set in this set.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function offsetSet($name, $option)
 {
     $name = $option->getName();
     $aliases = $option->getAlias();
     $this->setAlias($aliases, $name);
     parent::offsetSet($name, $option);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:17,代码来源:OptionSet.php

示例2: getContent

 /**
  * The getter for $content
  *
  * @return string
  */
 public function getContent()
 {
     $content = parent::getContent();
     if (!isset($content)) {
         $values = $this->values;
         asort($values);
         if (isset($values[''])) {
             $value = $values[''];
             unset($values['']);
             $values = ['' => $value] + $values;
         }
         $content = '';
         $selected = $this->selected();
         /** @var $selected_option Option */
         $selected_option = null;
         foreach ($values as $value => $caption) {
             $html_option = new Option($value, $caption);
             if ($value === $selected) {
                 $html_option->setAttribute('selected');
                 if ($selected_option) {
                     $selected_option->removeAttribute('selected');
                 }
             }
             if ($html_option->getContent() == $selected && !$selected_option) {
                 $html_option->setAttribute('selected');
                 $selected_option = $html_option;
             }
             $content .= strval($html_option);
         }
         $this->setContent($content);
     }
     return $content;
 }
开发者ID:TuxBoy,项目名称:Demo-saf,代码行数:38,代码来源:Select.php

示例3: it_is_a_correct_object

 /** @test */
 public function it_is_a_correct_object()
 {
     $field = new Option('test', 'Test');
     $field->render();
     $this->assertSame('test', $field->getValue());
     $this->assertSame('administr/form::option', $field->getView());
     $this->assertInstanceOf(AbstractType::class, $field);
 }
开发者ID:administrcms,项目名称:form,代码行数:9,代码来源:OptionFieldTest.php

示例4: deleteRowsByID

 public function deleteRowsByID($id)
 {
     global $wpdb;
     $entity = new Entity();
     $option = new Option();
     $entity->deleteById($id);
     $option->deleteByOwnerId($id);
     return $entity && $option;
 }
开发者ID:alhenaconseil,项目名称:wordpress-sociallymap,代码行数:9,代码来源:EntityCollection.php

示例5: buildOptions

 private function buildOptions(&$select, $range)
 {
     foreach ($range as $value) {
         $option = new Option();
         $option->setValue($value, true);
         $option->setLabel($value);
         $select->addOption($option);
     }
 }
开发者ID:rgv151,项目名称:Formidable,代码行数:9,代码来源:DateField.php

示例6: db_autodefine

/** Automatically selects the right DB handler from options
 * 
 * @param Option $obj_OptionHandler
 * 
 * @return dbHandler
 */
function db_autodefine($obj_OptionHandler)
{
    $str_DbType = $obj_OptionHandler->get('db_type');
    switch ($str_DbType) {
        case 'MySQL':
            require_once PHP_CLASSES_DIR . 'database/MySqlHandler.php';
            return new MySqlHandler();
            break;
    }
}
开发者ID:steromano87,项目名称:Gawain,代码行数:16,代码来源:autodefiners.php

示例7: set2Db

 /**
  * 更新Option的值
  */
 private function set2Db($key, $value)
 {
     $item = Option::model()->find("option_name=:option_name", array("option_name" => $key));
     if (!isset($item)) {
         $item = new Option();
         $item->option_name = $key;
     }
     $item->option_value = $value;
     $item->save();
     return $item;
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:14,代码来源:MiniOption.php

示例8: up

 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //
     Schema::create('options', function ($table) {
         $table->increments('id');
         $table->boolean('activate_pn');
         $table->string('basic_name');
         $table->string('basic_pass');
         $table->timestamps();
     });
     $o = new Option();
     $o->activate_pn = 0;
     $o->save();
 }
开发者ID:dldude,项目名称:recurly-push-notification-example,代码行数:19,代码来源:2012_10_31_155222_options_table.php

示例9: load_modules

 /**
  *
  * Load Plugin modules.
  *
  */
 private function load_modules()
 {
     do_action('sptp_before_load_modules');
     $this->option = apply_filters('sptp_module_option', new Option(), $this);
     $this->admin = apply_filters('sptp_module_admin', new Admin($this->option), $this);
     $this->rewrite = apply_filters('sptp_module_rewrite', new Rewrite($this->option), $this);
     $this->permalink = apply_filters('sptp_module_permalink', new Permalink($this->option), $this);
     $this->option->add_hooks();
     $this->admin->add_hooks();
     $this->rewrite->add_hooks();
     $this->permalink->add_hooks();
     do_action('sptp_after_load_modules');
     do_action('sptp_modules_loaded');
 }
开发者ID:jaws-ug,项目名称:jawsdays2016,代码行数:19,代码来源:Bootstrap.php

示例10: addOption

 /**
  * @param string|Option $name
  * @param float|null $price
  * @param StockItem|null $item
  */
 public function addOption($name, $price = null, StockItem $item = null)
 {
     if (!$name instanceof Option) {
         $name = (string) $name;
         if (empty($name)) {
             throw new \InvalidArgumentException('option name cannot be empty');
         }
         $name = new Option($name, $price, $item);
         unset($price, $item);
     }
     if (null !== $this->_findOption($name->getName()) || in_array($name->getStockItem(), $this->_getStockItems(), true)) {
         throw new \InvalidArgumentException('cannot add option with the same name twice');
     }
     $this->options[] = $name;
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:20,代码来源:ConfigurableProduct.php

示例11: load

 public static function load($thing)
 {
     $product = new Product();
     $product->thing = $thing;
     //members
     $fields_raw = $product->thing->getData();
     $tmpFields = array();
     foreach ($fields_raw as $field) {
         $tmpFields[$field->getKey()] = $field;
     }
     $product->fields = $tmpFields;
     //variants
     $thingVariants = $product->thing->getChildThings("variant");
     $variants = array();
     foreach ($thingVariants as $thingVariant) {
         $variants[] = Variant::load($thingVariant);
     }
     $product->variants = $variants;
     //options
     $thingOptions = $product->thing->getChildThings("option");
     $options = array();
     foreach ($thingOptions as $thingOptions) {
         $options[] = Option::load($thingOptions);
     }
     $product->options = $options;
     return $product;
 }
开发者ID:rajtrivedi2001,项目名称:shopify_app,代码行数:27,代码来源:product.php

示例12: getCSSClasses

 /**
  * 
  * @return string
  */
 protected function getCSSClasses()
 {
     $classes = array();
     $classes[] = 'addthis_toolbox';
     $classes[] = 'addthis_default_style';
     if ($this->big->getValue()) {
         $classes[] = 'addthis_32x32_style';
     } else {
         $classes[] = 'addthis_16x16_style';
     }
     $classes[] = 'wfmk_block';
     if ($this->right->getValue()) {
         $classes[] = 'wfmk_right';
     } elseif ($this->left->getValue()) {
         $classes[] = 'wfmk_left';
     }
     if ($this->vertical->getValue()) {
         $classes[] = 'vertical ';
     } else {
         // not vertical, so accepting long and counter options
         if ($this->long->getValue()) {
             $classes[] = 'long';
         }
         if ($this->counter->getValue()) {
             $classes[] = 'counter';
         }
     }
     return Tools::ArrayToCSSClasses($classes);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:33,代码来源:AddThis.php

示例13: test_accessors

 public function test_accessors()
 {
     /** === Test Data === */
     $CURRENCY = 'CUR';
     /** === Call and asserts  === */
     $this->obj->setCurrency($CURRENCY);
     $this->assertEquals($CURRENCY, $this->obj->getCurrency());
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_odoo,代码行数:8,代码来源:Option_Test.php

示例14: add_inline_style

 /**
  * Add inline styles from options (only if has custom option).
  *
  * @since  0.1.0
  *
  * @return void
  */
 public function add_inline_style()
 {
     if ($this->option->has_option('color')) {
         $color = $this->option->get_value('color');
         $custom_css = '#wpadminbar:before { background-color: ' . $color . '}';
         wp_add_inline_style('contextbar', $custom_css);
     }
 }
开发者ID:hofmannsven,项目名称:contextbar,代码行数:15,代码来源:Style.php

示例15: post_type_archive_link

 /**
  * Filter the post type archive permalink.
  *
  * @since 3.1.0
  *
  * @param string $link The post type archive permalink.
  * @param string $post_type Post type name.
  *
  * @return string
  */
 public function post_type_archive_link($link, $post_type)
 {
     $post_type_obj = get_post_type_object($post_type);
     if (get_option('permalink_structure') && is_array($post_type_obj->rewrite)) {
         $struct = $this->option->get_front_struct($post_type);
         $link = home_url(user_trailingslashit($struct, 'post_type_archive'));
     }
     return $link;
 }
开发者ID:jaws-ug,项目名称:jawsdays2016,代码行数:19,代码来源:Permalink.php


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