[ Index ]

PHP Cross Reference of Documentation Magento

title

Body

[close]

/ -> api.php (source)

   1  <?php
   2  /**
   3   * Magento
   4   *
   5   * NOTICE OF LICENSE
   6   *
   7   * This source file is subject to the Open Software License (OSL 3.0)
   8   * that is bundled with this package in the file LICENSE.txt.
   9   * It is also available through the world-wide-web at this URL:
  10   * http://opensource.org/licenses/osl-3.0.php
  11   * If you did not receive a copy of the license and are unable to
  12   * obtain it through the world-wide-web, please send an email
  13   * to license@magentocommerce.com so we can send you a copy immediately.
  14   *
  15   * DISCLAIMER
  16   *
  17   * Do not edit or add to this file if you wish to upgrade Magento to newer
  18   * versions in the future. If you wish to customize Magento for your
  19   * needs please refer to http://www.magentocommerce.com for more information.
  20   *
  21   * @category    Mage
  22   * @package     Mage_Api2
  23   * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
  24   * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  25   */
  26  
  27  if (version_compare(phpversion(), '5.2.0', '<')) {
  28      echo 'It looks like you have an invalid PHP version. Magento supports PHP 5.2.0 or newer';
  29      exit;
  30  }
  31  error_reporting(E_ALL | E_STRICT);
  32  
  33  $mageFilename = getcwd() . '/app/Mage.php';
  34  
  35  if (!file_exists($mageFilename)) {
  36      echo 'Mage file not found';
  37      exit;
  38  }
  39  require $mageFilename;
  40  
  41  if (!Mage::isInstalled()) {
  42      echo 'Application is not installed yet, please complete install wizard first.';
  43      exit;
  44  }
  45  
  46  if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
  47      Mage::setIsDeveloperMode(true);
  48  }
  49  
  50  #ini_set('display_errors', 1);
  51  
  52  // emulate index.php entry point for correct URLs generation in API
  53  Mage::register('custom_entry_point', true);
  54  Mage::$headersSentThrowsException = false;
  55  Mage::init('admin');
  56  Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
  57  Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_EVENTS);
  58  
  59  // query parameter "type" is set by .htaccess rewrite rule
  60  $apiAlias = Mage::app()->getRequest()->getParam('type');
  61  
  62  // check request could be processed by API2
  63  if (in_array($apiAlias, Mage_Api2_Model_Server::getApiTypes())) {
  64      /** @var $server Mage_Api2_Model_Server */
  65      $server = Mage::getSingleton('api2/server');
  66  
  67      $server->run();
  68  } else {
  69      /* @var $server Mage_Api_Model_Server */
  70      $server = Mage::getSingleton('api/server');
  71      $adapterCode = $server->getAdapterCodeByAlias($apiAlias);
  72  
  73      // if no adapters found in aliases - find it by default, by code
  74      if (null === $adapterCode) {
  75          $adapterCode = $apiAlias;
  76      }
  77      try {
  78          $server->initialize($adapterCode);
  79          $server->run();
  80  
  81          Mage::app()->getResponse()->sendResponse();
  82      } catch (Exception $e) {
  83          Mage::logException($e);
  84  
  85          echo $e->getMessage();
  86          exit;
  87      }
  88  }


Développement Magento e-commerce Montréal
Generated: Thu Feb 21 16:42:07 2013 Cross-referenced by PHPXref 0.7.1