Although the technique still works, various members of Magento’s engineering team have discouraged using Magento 1’s <action method="..."/>
syntax to call methods on blocks from layout update XML files.
<block ...>
<action method="addTab">
<argument name="name" xsi:type="string">info_section</argument>
<argument name="block" xsi:type="string">integration_edit_tab_info</argument>
</action>
</block>
Other members of the engineering team have suggested an <arguments/>
node as a replacement.
<referenceBlock name="block_name">
<arguments>
<argument name="field1" xsi:type="string">foo</argument>
<argument name="field_two" xsi:type="string">bar</argument>
</arguments>
</referenceBlock>
Whenever you see an <argument/>
or <arguments/>
node in a bit of Magento 2 XML, it’s usually to configure values that the object manager (or similar system) will pass into an object when it’s instantiated. How this works is dependent on what sort of XML file the nodes are in.
In layout update XML files, Magento will parse the values in these arguments and pass them into the block object’s constructor as the $data
parameter. This means you’ll be able to access the values via the block’s magic getter methods or via the getData
method
$this->getField1();
$this->getFieldTwo();
$this->getData('field1');
$this->getData('field_two');
While not a full replacement for the <action method="..."/>
nodes of Magento 1, these block data arguments will allow you to develop block features that are dependent on certain data being set.