本文整理汇总了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);
}
示例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;
}
示例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);
}
示例4: deleteRowsByID
public function deleteRowsByID($id)
{
global $wpdb;
$entity = new Entity();
$option = new Option();
$entity->deleteById($id);
$option->deleteByOwnerId($id);
return $entity && $option;
}
示例5: buildOptions
private function buildOptions(&$select, $range)
{
foreach ($range as $value) {
$option = new Option();
$option->setValue($value, true);
$option->setLabel($value);
$select->addOption($option);
}
}
示例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;
}
}
示例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;
}
示例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');
}
示例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;
}
示例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;
}
示例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);
}
示例13: test_accessors
public function test_accessors()
{
/** === Test Data === */
$CURRENCY = 'CUR';
/** === Call and asserts === */
$this->obj->setCurrency($CURRENCY);
$this->assertEquals($CURRENCY, $this->obj->getCurrency());
}
示例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);
}
}
示例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;
}