Created
April 30, 2020 01:52
-
-
Save r-martins/c41ba053c50e0af2854de69bb17b07bf to your computer and use it in GitHub Desktop.
Exemplo de uso de helpers em layout xml
This file contains hidden or 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 | |
/** | |
* PagSeguro Transparente Magento | |
* Helper Class - responsible for helping on gathering config information | |
* | |
* @category RicardoMartins | |
* @package RicardoMartins_PagSeguro | |
* @author Ricardo Martins | |
* @copyright Copyright (c) 2015 Ricardo Martins (http://r-martins.github.io/PagSeguro-Magento-Transparente/) | |
* @license https://opensource.org/licenses/MIT MIT License | |
*/ | |
class RicardoMartins_PagSeguro_Helper_Data extends Mage_Core_Helper_Abstract | |
{ | |
// ... | |
/** | |
* Creates the dynamic parts on module's JS | |
* @author Ricardo Martins | |
* @return Mage_Core_Block_Text | |
*/ | |
public function getPagSeguroScriptBlock() | |
{ | |
$scriptBlock = Mage::app()->getLayout()->createBlock('core/text', 'js_pagseguro'); | |
$secure = Mage::getStoreConfigFlag('web/secure/use_in_frontend'); | |
$directPaymentBlock = ''; | |
if (Mage::app()->getLayout()->getArea() == 'adminhtml') { | |
$directPaymentBlock = Mage::app()->getLayout() | |
->createBlock('ricardomartins_pagseguro/form_directpayment') | |
->toHtml(); | |
} | |
$scriptBlock->setText( | |
sprintf( | |
' | |
<script type="text/javascript">var RMPagSeguroSiteBaseURL = "%s";</script> | |
<script type="text/javascript" src="%s"></script> | |
<script type="text/javascript" src="%s"></script> | |
%s | |
', | |
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure), | |
Mage::helper('ricardomartins_pagseguro')->getJsUrl(), | |
$this->getModuleJsUrl($secure), | |
$directPaymentBlock | |
) | |
); | |
return $scriptBlock; | |
} | |
// ... | |
} | |
This file contains hidden or 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"?> | |
<layout> | |
<adminhtml_sales_order_create_index> | |
<reference name="before_body_end"> | |
<action method="append"> | |
<block helper="ricardomartins_pagseguro/getPagSeguroScriptBlock"/> | |
</action> | |
</reference> | |
</adminhtml_sales_order_create_index> | |
</layout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment