Skip to content

Instantly share code, notes, and snippets.

@philwinkle
Last active December 28, 2015 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philwinkle/7570921 to your computer and use it in GitHub Desktop.
Save philwinkle/7570921 to your computer and use it in GitHub Desktop.
**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
<?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>
<?xml version="1.0"?>
<config>
<module name="Philwinkle_Module" version="0.0.1.0" active="true"></module>
</config>
<?php
namespace Philwinkle\Module\Helper;
class Data extends \Magento\Core\Helper\Data
{
public function l33t($string)
{
return strtr($string, 'leto', '1370');
}
}
<?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