Created
May 16, 2014 22:44
-
-
Save develpr/815e67feb7438cf57680 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* @package Develpr_Sqs | |
* @author Kevin Mitchell <kevin@develpr.com> | |
* @copyright Massachusetts Institute of Technology License (MITL) | |
* @license http://opensource.org/licenses/MIT | |
*/ | |
require(Mage::getBaseDir('lib') . '/develpr_sqs/aws.phar'); | |
class Develpr_Sqs_Helper_Data extends Mage_Core_Helper_Abstract { | |
public function __construct() | |
{ | |
$autoloadFuncs = spl_autoload_functions(); | |
$awsCallback = false; | |
foreach ($autoloadFuncs as $callback) { | |
if (is_array($callback) && get_class($callback[0]) == 'Symfony\Component\ClassLoader\UniversalClassLoader') { | |
$awsCallback = $callback; | |
break; | |
} | |
} | |
if ($awsCallback) { | |
spl_autoload_unregister($awsCallback); | |
spl_autoload_register($awsCallback, null, true); | |
} | |
} | |
public function getSqsClient() | |
{ | |
$configs = $this->getConfigs(); | |
$sqsClient = Aws\Sqs\SQSClient::factory(array( | |
'key' => $configs['key'], | |
'secret' => $configs['secret'], | |
)); | |
return $sqsClient; | |
} | |
/** | |
* Get configs from Magento Admin for the MQ module as an array | |
* | |
* @return array | |
*/ | |
public function getConfigs() { | |
$configs = array( | |
'active' => Mage::getStoreConfig('develprsqs/setup/active'), | |
'region' => Mage::getStoreConfig('develprsqs/setup/region'), | |
'key' => Mage::getStoreConfig('develprsqs/setup/key'), | |
'secret' => Mage::getStoreConfig('develprsqs/develprsqs/secret'), | |
'queueUrl' => Mage::getStoreConfig('develprsqs/develprsqs/queueUrl'), | |
'orderActive' => Mage::getStoreConfig('develprsqs/triggers/order_active'), | |
'customerActive' => Mage::getStoreConfig('develprsqs/triggers/customerActive'), | |
'customerAddressActive' => Mage::getStoreConfig('develprsqs/triggers/customer_address_active'), | |
'invoiceActive' => Mage::getStoreConfig('develprsqs/triggers/invoice_active'), | |
'shipmentActive' => Mage::getStoreConfig('develprsqs/triggers/shipment_active'), | |
'creditMemoActive' => Mage::getStoreConfig('develprsqs/triggers/credit_memo_active'), | |
'productActive' => Mage::getStoreConfig('develprsqs/triggers/product_active'), | |
); | |
return $configs; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment