Esempio n. 1
0
 /**
  * Represents the "get_items" action.
  *
  * @throws ShopgateLibraryException
  * @see http://wiki.shopgate.com/Shopgate_Plugin_API_get_items
  */
 protected function getItems()
 {
     $limit = isset($this->params['limit']) ? (int) $this->params['limit'] : null;
     $offset = isset($this->params['offset']) ? (int) $this->params['offset'] : null;
     $uids = isset($this->params['uids']) ? (array) $this->params['uids'] : array();
     $responseType = isset($this->params['response_type']) ? $this->params['response_type'] : false;
     $supportedResponseTypes = $this->config->getSupportedResponseTypes();
     if (!empty($responseType) && !in_array($responseType, $supportedResponseTypes['get_items'])) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_UNSUPPORTED_RESPONSE_TYPE, 'Requested type: "' . $responseType . '"');
     }
     $this->plugin->startGetItems($limit, $offset, $uids, $responseType);
     switch ($responseType) {
         default:
         case 'xml':
             $response = new ShopgatePluginApiResponseAppXmlExport($this->trace_id);
             $responseData = $this->config->getItemsXmlPath();
             break;
         case 'json':
             $response = new ShopgatePluginApiResponseAppJsonExport($this->trace_id);
             $responseData = $this->config->getItemsJsonPath();
             break;
     }
     if (empty($this->response)) {
         $this->response = $response;
     }
     $this->responseData = $responseData;
 }
Esempio n. 2
0
 /**
  * Takes care of buffer and file handlers and calls ShopgatePlugin::createPagesCsv().
  *
  * @param int $limit
  * @param int $offset
  * @param array $uids
  * @param string $responseType
  */
 public final function startGetItems($limit = null, $offset = null, array $uids = array(), $responseType = 'xml')
 {
     switch ($responseType) {
         default:
         case 'xml':
             $this->buffer->setFile($this->config->getItemsXmlPath());
             break;
         case 'json':
             $this->buffer->setFile($this->config->getItemsJsonPath());
             break;
     }
     $this->createItems($limit, $offset, $uids);
     $this->buffer->finish();
 }