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


PHP SessionManagerInterface::setRatingData方法代码示例

本文整理汇总了PHP中Magento\Framework\Session\SessionManagerInterface::setRatingData方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManagerInterface::setRatingData方法的具体用法?PHP SessionManagerInterface::setRatingData怎么用?PHP SessionManagerInterface::setRatingData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Session\SessionManagerInterface的用法示例。


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

示例1: _prepareForm

 /**
  * Prepare rating edit form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $this->setForm($form);
     $fieldset = $form->addFieldset('rating_form', array('legend' => __('Rating Title')));
     $fieldset->addField('rating_code', 'text', array('name' => 'rating_code', 'label' => __('Default Value'), 'class' => 'required-entry', 'required' => true));
     foreach ($this->_systemStore->getStoreCollection() as $store) {
         $fieldset->addField('rating_code_' . $store->getId(), 'text', array('label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']'));
     }
     if ($this->_session->getRatingData()) {
         $form->setValues($this->_session->getRatingData());
         $data = $this->_session->getRatingData();
         if (isset($data['rating_codes'])) {
             $this->_setRatingCodes($data['rating_codes']);
         }
         $this->_session->setRatingData(null);
     } elseif ($this->_coreRegistry->registry('rating_data')) {
         $form->setValues($this->_coreRegistry->registry('rating_data')->getData());
         if ($this->_coreRegistry->registry('rating_data')->getRatingCodes()) {
             $this->_setRatingCodes($this->_coreRegistry->registry('rating_data')->getRatingCodes());
         }
     }
     if ($this->_coreRegistry->registry('rating_data')) {
         $collection = $this->_optionFactory->create()->getResourceCollection()->addRatingFilter($this->_coreRegistry->registry('rating_data')->getId())->load();
         $i = 1;
         foreach ($collection->getItems() as $item) {
             $fieldset->addField('option_code_' . $item->getId(), 'hidden', array('required' => true, 'name' => 'option_title[' . $item->getId() . ']', 'value' => $item->getCode() ? $item->getCode() : $i));
             $i++;
         }
     } else {
         for ($i = 1; $i <= 5; $i++) {
             $fieldset->addField('option_code_' . $i, 'hidden', array('required' => true, 'name' => 'option_title[add_' . $i . ']', 'value' => $i));
         }
     }
     $fieldset = $form->addFieldset('visibility_form', array('legend' => __('Rating Visibility')));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('stores', 'multiselect', array('label' => __('Visible In'), 'name' => 'stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
         if ($this->_coreRegistry->registry('rating_data')) {
             $form->getElement('stores')->setValue($this->_coreRegistry->registry('rating_data')->getStores());
         }
     }
     $fieldset->addField('is_active', 'checkbox', array('label' => __('Is Active'), 'name' => 'is_active', 'value' => 1));
     $fieldset->addField('position', 'text', array('label' => __('Sort Order'), 'name' => 'position'));
     if ($this->_coreRegistry->registry('rating_data')) {
         $form->getElement('position')->setValue($this->_coreRegistry->registry('rating_data')->getPosition());
         $form->getElement('is_active')->setIsChecked($this->_coreRegistry->registry('rating_data')->getIsActive());
     }
     return parent::_prepareForm();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:57,代码来源:Form.php

示例2: setRatingData

 /**
  * Set rating data to form
  *
  * @return void
  */
 protected function setRatingData()
 {
     if ($this->session->getRatingData()) {
         $this->getForm()->setValues($this->session->getRatingData());
         $data = $this->session->getRatingData();
         if (isset($data['rating_codes'])) {
             $this->setRatingCodes($data['rating_codes']);
         }
         $this->session->setRatingData(null);
     } elseif ($this->_coreRegistry->registry('rating_data')) {
         $this->getForm()->setValues($this->_coreRegistry->registry('rating_data')->getData());
         if ($this->_coreRegistry->registry('rating_data')->getRatingCodes()) {
             $this->setRatingCodes($this->_coreRegistry->registry('rating_data')->getRatingCodes());
         }
     }
     $this->setRatingOptions();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:Form.php


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