0
    <?php

class Excellence_Manager_Adminhtml_ManagerController extends Mage_Adminhtml_Controller_action
{

    public function customerAction(){
        $this->loadLayout();
        $this->getLayout()->getBlock('customer.grid')
        ->setCustomers($this->getRequest()->getPost('customers', null));
        $this->renderLayout();
    }

我正在关注这个网格序列化器 tute 。我只是不明白这个 setCustomers 来自哪里?

即使在其他教程中,我也看到了 setClent()、setDog() 等。但是 get 是在哪里,或者它也不是来自数据库。我认为也不在布局中。请帮忙谢谢。

    <manager_adminhtml_manager_customer>
   <block type="core/text_list" name="root" output="toHtml">
       <block type="manager/adminhtml_manager_edit_tab_grid" name="customer.grid"/>
       <block type="adminhtml/widget_grid_serializer" name="grid_serializer">
           <reference name="grid_serializer">
               <action method="initSerializerBlock">
                   <grid_block_name>customer.grid</grid_block_name>
                   <data_callback>getSelectedCustomers</data_callback>
                   <hidden_input_name>links[customers]</hidden_input_name>
                   <reload_param_name>customers</reload_param_name>
               </action>
               <action method="addColumnInputName">
                   <input_name>position</input_name>
               </action>
           </reference>
       </block>
   </block>

我发现它不是来自 hidden_​​input_name 或 reload_param_name。

4

1 回答 1

0
__set() is run when writing data to inaccessible properties.

__get() is utilized for reading data from inaccessible properties.

Magento 实现了所谓的“魔术方法”来在对象中设置数据。当没有找到例如 setCustomers() 的方法时,它们实现__set并被__get调用,并使用这些方法来做setData('customers', "YOUR_VALUE");

于 2013-07-10T09:52:05.637 回答