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


PHP Attribute类代码示例

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


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

示例1: updateValue

 public function updateValue(Attribute &$attr)
 {
     if ($attr instanceof Classes) {
         $this->addClass($attr->getClassList());
     } else {
     }
 }
开发者ID:ivansky,项目名称:php-dom-query,代码行数:7,代码来源:Classes.php

示例2: save

 /**
  * 新商品
  */
 public function save()
 {
     $item = new Attribute();
     $item->cat_id = Input::get('cat_id');
     $item->name = Input::get('name');
     $item->save();
     return redirect()->route('admin.attribute.index');
 }
开发者ID:cdandy,项目名称:artup,代码行数:11,代码来源:ItemCatController.php

示例3: setAttribute

 public function setAttribute(Attribute $attribute)
 {
     if ($attribute->get('name') == 'class' && $attribute->get('name') == 'style') {
         return $this;
     }
     $this->attributes[$attribute->get('name')] = $attribute;
     return $this;
 }
开发者ID:agilesdesign,项目名称:Element,代码行数:8,代码来源:AbstractElement.php

示例4: setAttribute

 /**
  * @param Attribute $attribute
  */
 public function setAttribute(Attribute $attribute)
 {
     $this->attribute->removeValue($this);
     // Remove value from current attribute
     $attribute->addValue($this);
     // Add value to new attribute
     $this->attribute = $attribute;
 }
开发者ID:anhnt0212,项目名称:DesignPatternsPHP,代码行数:11,代码来源:Value.php

示例5: testGroupsToArray

 public function testGroupsToArray()
 {
     $array = array('BMI' => array('groups' => array('group1', 'group2')));
     $attr = new Attribute();
     $attr->setName('BMI');
     $attr->addGroup('group1');
     $attr->addGroup('group2');
     $this->assertEquals($array, $attr->toArray());
 }
开发者ID:KIZI,项目名称:sewebar-cms,代码行数:9,代码来源:AttributeTest.php

示例6: actionAdmin

 public function actionAdmin()
 {
     $model = new Attribute('search');
     $model->unsetAttributes();
     if (isset($_GET['Attribute'])) {
         $model->setAttributes($_GET['Attribute']);
     }
     $this->render('admin', array('model' => $model));
 }
开发者ID:hanihh,项目名称:vvs_v2,代码行数:9,代码来源:AttributeController.php

示例7: __construct

 public function __construct(Product $product, Attribute $attribute, AttributeValue $attributeValue)
 {
     $this->setId();
     $this->setCreated();
     $this->product = $product;
     $this->attribute = $attribute;
     $this->attributeValue = $attributeValue;
     $product->addProductAttribute($this);
     $attribute->addProductAttribute($this);
     $attributeValue->addProductAttribute($this);
 }
开发者ID:inklabs,项目名称:kommerce-core,代码行数:11,代码来源:ProductAttribute.php

示例8: delete

 public function delete()
 {
     if (parent::delete()) {
         $ret = true;
         $attributes = $this->getAttributes();
         foreach ($attributes as $attribute) {
             $attr = new Attribute((int) $attribute['id_attribute']);
             $ret &= $attr->delete();
         }
         return $ret;
     }
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:12,代码来源:AttributeGroup.php

示例9: listAction

 public function listAction()
 {
     $limit = 10;
     //查询数据
     $attribute = new \Attribute();
     $list = $attribute->getList();
     //数据
     $page_html = $this->pageHtml($list);
     //分页html
     //加载js
     $this->assets->addJs('backend/mt/attribute-list.js');
     $this->view->setVars(['list' => $list, 'page_html' => $page_html]);
 }
开发者ID:xw716825,项目名称:git_back,代码行数:13,代码来源:AttributeController.php

示例10: _attributeExists

 private function _attributeExists($v)
 {
     $v = explode(":", $v);
     $result = Db::getInstance()->getRow('SELECT `id_attribute` FROM ' . DB_PREFIX . 'attribute WHERE `name`="' . pSQL($v[1]) . '"');
     if (isset($result['id_attribute'])) {
         return $result['id_attribute'];
     } else {
         $attribute = new Attribute();
         $attribute->id_attribute_group = $v[0];
         $attribute->name = $v[1];
         $attribute->add();
         return $attribute->id;
     }
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:14,代码来源:Import.php

示例11: run

 public function run()
 {
     $this->trancate();
     $faker = Faker\Factory::create();
     $languages = Language::all();
     $products = Product::all();
     $attributes = Attribute::all();
     $attributes_options = array();
     foreach ($languages as $language) {
         $options = DB::table('attributes_options')->whereLanguageId($language->id)->get();
         $options = new Illuminate\Database\Eloquent\Collection($options);
         $options = $options->lists("options", 'attribute_id');
         $attributes_options[$language->id] = $options;
     }
     $attributes_key = $attributes->modelKeys();
     $products->each(function ($product) use($attributes_key, $languages, $faker, $attributes_options) {
         $count_to_insert = rand(0, rand(0, count($attributes_key) - 1));
         for ($i = 1; $i <= $count_to_insert; $i++) {
             foreach ($languages as $language) {
                 $attribute_id = $attributes_key[rand(0, count($attributes_key) - 1)];
                 $options = $attributes_options[$language->id][$attribute_id];
                 $tokens = explode("|", $options);
                 try {
                     DB::table('products_to_attributes')->insert(array('product_id' => $product->id, 'language_id' => $language->id, 'attribute_id' => $attribute_id, 'value' => $tokens[rand(0, count($tokens) - 1)]));
                 } catch (Exception $x) {
                     var_dump($x);
                 }
             }
         }
     });
 }
开发者ID:pda-code,项目名称:eshop-angular-laravel,代码行数:31,代码来源:Products_Attributes_Seeder.php

示例12: toArray

 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['LegacyCartItemAttributeCombination'][serialize($this->getPrimaryKey())])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['LegacyCartItemAttributeCombination'][serialize($this->getPrimaryKey())] = true;
     $keys = LegacyCartItemAttributeCombinationTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getCartItemId(), $keys[1] => $this->getAttributeId(), $keys[2] => $this->getAttributeAvId());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aCartItem) {
             $result['CartItem'] = $this->aCartItem->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aAttribute) {
             $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aAttributeAv) {
             $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
开发者ID:bcbrr,项目名称:LegacyProductAttributes,代码行数:40,代码来源:LegacyCartItemAttributeCombination.php

示例13: safeUp

 public function safeUp()
 {
     $this->createTable('{{store_product_attribute_value}}', ['id' => 'pk', 'product_id' => 'INTEGER NOT NULL', 'attribute_id' => 'INTEGER NOT NULL', 'number_value' => 'REAL', 'string_value' => 'VARCHAR(250)', 'text_value' => 'TEXT', 'option_value' => 'INTEGER', 'create_time' => 'DATETIME'], $this->getOptions());
     //fk
     $this->addForeignKey('{{fk_product_attribute_product}}', '{{store_product_attribute_value}}', 'product_id', '{{store_product}}', 'id', 'CASCADE');
     $this->addForeignKey('{{fk_product_attribute_attribute}}', '{{store_product_attribute_value}}', 'attribute_id', '{{store_attribute}}', 'id', 'CASCADE');
     $this->addForeignKey('{{fk_product_attribute_option}}', '{{store_product_attribute_value}}', 'option_value', '{{store_attribute_option}}', 'id', 'CASCADE');
     //ix
     $this->createIndex('{{ix_product_attribute_number_value}}', '{{store_product_attribute_value}}', 'number_value');
     $this->createIndex('{{ix_product_attribute_string_value}}', '{{store_product_attribute_value}}', 'string_value');
     //перенести аттрибуты
     $attributes = Yii::app()->getDb()->createCommand('SELECT * FROM {{store_product_attribute_eav}}')->queryAll();
     $modelsAttr = [];
     foreach ($attributes as $attribute) {
         $product = Product::model()->findByPk($attribute['product_id']);
         if (null === $product) {
             continue;
         }
         if (!isset($modelsAttr[$attribute['attribute']])) {
             $model = Attribute::model()->find('name = :name', [':name' => $attribute['attribute']]);
             if (null === $model) {
                 continue;
             }
             $modelsAttr[$attribute['attribute']] = $model;
         }
         $value = new AttributeValue();
         $value->store($modelsAttr[$attribute['attribute']]->id, $attribute['value'], $product);
     }
     $this->dropTable('{{store_product_attribute_eav}}');
 }
开发者ID:alextravin,项目名称:yupe,代码行数:30,代码来源:m150907_084604_new_attributes.php

示例14: run

 /**
  * @throws Exception
  */
 public function run()
 {
     if ('*' === $this->attributes) {
         $this->attributes = Attribute::model()->with(['options.parent'])->cache($this->cacheTime)->findAll(['condition' => 't.is_filter = 1', 'order' => 't.sort DESC']);
     }
     foreach ($this->attributes as $attribute) {
         $model = is_string($attribute) ? Attribute::model()->findByAttributes(['name' => $attribute]) : $attribute;
         if ($model) {
             switch ($model->type) {
                 case Attribute::TYPE_DROPDOWN:
                     $this->widget('application.modules.store.widgets.filters.DropdownFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_CHECKBOX_LIST:
                     $this->widget('application.modules.store.widgets.filters.DropdownFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_CHECKBOX:
                     $this->widget('application.modules.store.widgets.filters.CheckboxFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_NUMBER:
                     $this->widget('application.modules.store.widgets.filters.NumberFilterWidget', ['attribute' => $model]);
                     break;
                 case Attribute::TYPE_SHORT_TEXT:
                     $this->widget('application.modules.store.widgets.filters.TextFilterWidget', ['attribute' => $model]);
                     break;
             }
         }
     }
 }
开发者ID:syrexby,项目名称:domovoishop.by,代码行数:31,代码来源:AttributesFilterWidget.php

示例15: renderForm

 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $shops = Shop::getShops();
     if (count($this->context->employee->getAssociatedShops()) > 1) {
         $shops = array_merge(array(0 => array('id_shop' => 0, 'name' => $this->l('All shops'))), $shops);
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Specific price rules')), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 33, 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop:'), 'name' => 'id_shop', 'options' => array('query' => $shops, 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency:'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country:'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group:'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity:'), 'name' => 'from_quantity', 'size' => 6, 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.):'), 'name' => 'price', 'size' => 6, 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'date', 'label' => $this->l('From:'), 'name' => 'from', 'size' => 12), array('type' => 'date', 'label' => $this->l('To:'), 'name' => 'to', 'size' => 12), array('type' => 'select', 'label' => $this->l('Reduction type:'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Reduction:'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 2);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 2), 'leave_bprice_on' => $price ? 0 : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:31,代码来源:AdminSpecificPriceRuleController.php


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