Skip to content

Instantly share code, notes, and snippets.

@mathewka
mathewka / crossdoamin.php
Created April 15, 2014 05:40
Allow cross domain access
$method = $_SERVER['REQUEST_METHOD'];
if (isset($_SERVER['HTTP_ORIGIN'])) {
drupal_add_http_header('Access-Control-Allow-Origin', $_SERVER['HTTP_ORIGIN']);
}
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
drupal_add_http_header('Access-Control-Allow-Headers', $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
}
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
@mathewka
mathewka / TestFile.php
Created April 15, 2014 05:26
Zend Jon Table , ZF2 Join table example.
<?php
namespace '''''';
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Sql\Select;
class TestFile extends AbstractTableGateway
{
public function __construct($adapter)
@mathewka
mathewka / IndexController.php
Created April 15, 2014 05:20
Magento Rest api call from controller with using Oauth
<?php
class Namespace_modulename_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction() {
//Basic parameters that need to be provided for oAuth authentication
//on Magento
$params = array(
'siteUrl' => 'http://localhost/magento/oauth',
'requestTokenUrl' => 'http://localhost/magento/oauth/initiate',
'accessTokenUrl' => 'http://localhost/magento/oauth/token',
'authorizeUrl' => 'http://localhost/magento/admin/oAuth_authorize',//This URL is used only if we authenticate as Admin user type
<?php
namespace Api\Factory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Api\Controller\DbResolver;
use Zend\Authentication\Adapter\DbTable as AuthAdapter;
class AuthAdapterFactory implements FactoryInterface