Skip to content

Instantly share code, notes, and snippets.

@enlacee
Created April 7, 2015 23:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enlacee/ef85f139784c68211d40 to your computer and use it in GitHub Desktop.
Save enlacee/ef85f139784c68211d40 to your computer and use it in GitHub Desktop.
ZF2 Configuration of helper for VIEW AND CONTROLLER : module.php
<?PHP
/*
* Return url purify (URL clean for SEO)
* This function is posible call for:
* // CONTROLLER
* $utilFunction = $this->helper->get('utilFunction');
*
* // VIEW
* $utilFunction = $this->plugin("utilFunction");
*/
public function getViewHelperConfig()
{
return array(
'factories' => array(
'urlify' => function($sm) {
$helper = new UrlifyHelper();
return $helper;
},
'hashids' => function($sm) {
$helper = new View\Helper\HashidsHelper();
return $helper;
},
'configItem' => function ($sm) {
$serviceLocator = $sm->getServiceLocator();
$viewHelper = new View\Helper\ConfigItem();
$viewHelper->setServiceLocator($serviceLocator);
return $viewHelper;
},
'utilFunction' => function ($sm) {
$helper = new View\Helper\UtilFunction();
return $helper;
}
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment