**Edited 4/19/14** see http://blog.philwinkle.com/updates-in-magento-2/ || [Quickcast] Magento Module creation part 4. Part 4 of our ongoing series. We dive into the new dependency injection pattern in Magento 2 by creating and then referring to a helper in the module we created in parts 1-3.Link: http://quick.as/bbpzf6e4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<type name="Magento\Backend\Model\Menu\Item"> | |
<plugin name="myname" type="Philwinkle\Module\Model\Plugin\Wrapper" sortOrder="100"></plugin> | |
</type> | |
</config> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<module name="Philwinkle_Module" version="0.0.1.0" active="true"></module> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Philwinkle\Module\Helper; | |
class Data extends \Magento\Core\Helper\Data | |
{ | |
public function l33t($string) | |
{ | |
return strtr($string, 'leto', '1370'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Philwinkle\Module\Model\Plugin; | |
class Wrapper | |
{ | |
protected $_helper; | |
public function __construct(\Philwinkle\Module\Helper\Data $helper) | |
{ | |
$this->_helper = $helper; | |
} | |
public function afterGetTitle(\Magento\Backend\Model\Menu\Item $subject, string $name) | |
{ | |
return '(' . $this->_helper->l33t($name) . ')'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment