Skip to content

Instantly share code, notes, and snippets.

@rgranadino
Forked from develpr/gist:815e67feb7438cf57680
Last active August 29, 2015 14:01
Show Gist options
  • Save rgranadino/7f7aea594f6ca6cd7e33 to your computer and use it in GitHub Desktop.
Save rgranadino/7f7aea594f6ca6cd7e33 to your computer and use it in GitHub Desktop.
<?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');
$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, true, true);
}
use Aws\Sqs\SqsClient;
class Develpr_Sqs_Helper_Data extends Mage_Core_Helper_Abstract {
public function getSqsClient()
{
$configs = $this->getConfigs();
$sqsClient = 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