public static function run($page = false, $db = false, $options = []) { ErrorHandler::$customHandler = function ($errno, $errstr, $errfile, $errline, $errcontext, $errorName) { $controller = new ApiController(); $controller->errorResponse("Unknown Error", "{$errorName} {$errstr}", "{$errfile} on line {$errline}"); }; parent::run($page, $db, $options); }
/** * Resource methods */ public function get($id = NULL) { $this->url->addCatalogLink('account/download/download'); $data = parent::getInternalRouteData('account/download'); $downloads = array('downloads' => $this->getDownloads($data)); $this->response->setOutput($downloads); }
/** * Resource methods */ public function get($id = NULL) { $this->setRequestParams(); $data = parent::getInternalRouteData('product/special'); $products = array('products' => $this->getProducts($data)); $this->response->setOutput($products); }
/** * Resource methods */ public function put($id = NULL) { $this->request->convertBoolToYesNoRadioValue('newsletter'); $this->request->server['REQUEST_METHOD'] = 'POST'; $data = parent::getInternalRouteData('account/newsletter'); ApiException::evaluateErrors($data); }
/** * Resource methods */ public function post() { // Just a dummy redirect to prevent errors in checkout/reward/reward. $this->request->post['redirect'] = 'checkout/cart'; $data = parent::getInternalRouteData('checkout/reward/reward', true); ApiException::evaluateErrors($data); }
function validate(&$data, $format, $strict = true) { global $ost; //Call parent to Validate the structure if (!parent::validate($data, $format, $strict) && $strict) { $this->exerr(400, __('Unexpected or invalid data received')); } // Use the settings on the thread entry on the ticket details // form to validate the attachments in the email $tform = TicketForm::objects()->one()->getForm(); $messageField = $tform->getField('message'); $fileField = $messageField->getWidget()->getAttachments(); // Nuke attachments IF API files are not allowed. if (!$messageField->isAttachmentsEnabled()) { $data['attachments'] = array(); } //Validate attachments: Do error checking... soft fail - set the error and pass on the request. if ($data['attachments'] && is_array($data['attachments'])) { foreach ($data['attachments'] as &$file) { if ($file['encoding'] && !strcasecmp($file['encoding'], 'base64')) { if (!($file['data'] = base64_decode($file['data'], true))) { $file['error'] = sprintf(__('%s: Poorly encoded base64 data'), Format::htmlchars($file['name'])); } } // Validate and save immediately try { $file['id'] = $fileField->uploadAttachment($file); } catch (FileUploadError $ex) { $file['error'] = $file['name'] . ': ' . $ex->getMessage(); } } unset($file); } return true; }
function validate(&$data, $format) { global $ost; //Call parent to Validate the structure if (!parent::validate($data, $format)) { $this->exerr(400, 'Unexpected or invalid data received'); } //Nuke attachments IF API files are not allowed. if (!$ost->getConfig()->allowAPIAttachments()) { $data['attachments'] = array(); } //Validate attachments: Do error checking... soft fail - set the error and pass on the request. if ($data['attachments'] && is_array($data['attachments'])) { foreach ($data['attachments'] as &$attachment) { if (!$ost->isFileTypeAllowed($attachment)) { $attachment['error'] = 'Invalid file type (ext) for ' . Format::htmlchars($attachment['name']); } elseif ($attachment['encoding'] && !strcasecmp($attachment['encoding'], 'base64')) { if (!($attachment['data'] = base64_decode($attachment['data'], true))) { $attachment['error'] = sprintf('%s: Poorly encoded base64 data', Format::htmlchars($attachment['name'])); } } } unset($attachment); } return true; }
public function __construct(UserValidator $userValidator, CandidateValidator $candidateValidator, AgencyValidator $agencyValidator) { parent::__construct(new League\Fractal\Manager()); $this->userValidator = $userValidator; $this->candidateValidator = $candidateValidator; $this->agencyValidator = $agencyValidator; }
/** * If Disqus comments are enabled, disable the entire API * @param CAction $action The action we are using * @return CAction */ public function beforeAction($action) { if (Cii::getConfig('useDisqusComments') == "1") { throw new CHttpException(403, Yii::t('Api.comment', 'The comment API is not available while Disqus comments are enabled.')); } return parent::beforeAction($action); }
/** * @param AgentValidator $validator * @param UserValidator $userValidator */ public function __construct(AgentValidator $validator, UserValidator $userValidator) { $this->validator = $validator; $this->userValidator = $userValidator; // call parent construct parent::__construct(new FractalManager()); }
public function getReorder($id = NULL) { if ($id != NULL) { $this->request->get['order_id'] = $id; $data = parent::getInternalRouteData('account/order/reorder'); } }
/** * Resource methods */ public function get() { $data = parent::getInternalRouteData('checkout/cart'); ApiException::evaluateErrors($data, false); $cart = array('cart' => $this->getCart($data)); $this->response->setOutput($cart); }
public function delete($id = NULL) { if ($id !== NULL) { $this->request->get['remove'] = $id; } $data = parent::getInternalRouteData('account/wishlist'); ApiException::evaluateErrors($data); }
/** * Resource methods */ public function post() { $this->request->setDefaultParameters($this->defaultParameters); $this->request->convertBoolToCheckbox('agree'); $this->request->convertBoolToYesNoRadioValue('newsletter'); $data = parent::getInternalRouteData('account/register'); ApiException::evaluateErrors($data); }
/** * Constructor */ function __construct() { parent::__construct(); // must be logged in if (!$this->user) { $this->output->set_output(json_encode($this->response)); } }
public function edit() { $app = JFactory::getApplication(); $view = $this->getEntityName(); $layout = 'default'; JRequest::setVar('view', $view); JRequest::setVar('layout', $layout); parent::display(); }
public function put() { $this->request->setDefaultParameters($this->defaultParameters); $this->request->server['REQUEST_METHOD'] = 'POST'; $data = parent::getInternalRouteData('account/edit'); ApiException::evaluateErrors($data); $account = array('account' => $this->getAccount($data)); $this->response->setOutput($account); }
public function post() { $this->request->setDefaultParameters($this->defaultParameters); $data = parent::getInternalRouteData('checkout/shipping_method/save', true); if (isset($data['redirect'])) { $this->redirect($data['redirect']); } ApiException::evaluateErrors($data); }
/** * Resource methods */ public function post() { $this->request->setDefaultParameters($this->defaultParameters); $this->request->convertBoolToCheckbox('shipping_address'); $data = parent::getInternalRouteData('checkout/guest/save', true); if (isset($data['redirect'])) { $this->redirect($data['redirect']); } ApiException::evaluateErrors($data); }
/** * Resource methods */ public function get() { $data = parent::getInternalRouteData('checkout/confirm'); if (isset($data['redirect'])) { $this->redirect($data['redirect']); } ApiException::evaluateErrors($data); $order = array('order' => $this->getOrder($data)); $this->response->setOutput($order); }
public function edit() { $app = JFactory::getApplication(); $view = $this->getEntityName(); $layout = 'default'; //$app->input->post->set('view',$view); //$app->input->post->set('layout',$layout); $app->input->set('view', $view); $app->input->set('layout', $layout); parent::display(); }
/** * Resource methods */ public function post() { // Validate if customer is logged in. This is needed because in the parent::validate the checkout/checkout route serves two purposes. if (!$this->customer->isLogged()) { throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN)); } $this->request->setDefaultParameters($this->defaultParameters); $data = parent::getInternalRouteData('checkout/shipping_address/save', true); if (isset($data['redirect'])) { $this->redirect($data['redirect']); } ApiException::evaluateErrors($data); }
protected function getVendorProducts($id) { $this->setRequestParams($id); $data = parent::getInternalRouteData('product/vendor/info'); if (isset($data['text_error'])) { throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_NOT_FOUND, ErrorCodes::ERRORCODE_VENDOR_NOT_FOUND, $data['text_error']); } $products = $data['products']; foreach ($products as &$product) { $product = $this->processProduct($product); } return $products; }
/** * Resource methods */ public function get($id = NULL) { if ($id != NULL) { $this->request->get['path'] = $id; $this->setRequestParams(); $data = parent::getInternalRouteData('product/category'); if (isset($data['text_error'])) { throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_NOT_FOUND, ErrorCodes::ERRORCODE_CATEGORY_NOT_FOUND, $data['text_error']); } $category = array('category' => $this->getCategory($id, $data)); $this->response->setOutput($category); } else { $categories = array('categories' => $this->getCategories()); $this->response->setOutput($categories); } }
/** * Resource methods */ public function get($id = NULL) { if ($id != NULL) { $this->request->get['manufacturer_id'] = $id; $this->setRequestParams(); $data = parent::getInternalRouteData('product/manufacturer/info'); if (isset($data['text_error'])) { throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_NOT_FOUND, ErrorCodes::ERRORCODE_MANUFACTURER_NOT_FOUND, $data['text_error']); } $manufacturer = array('manufacturer' => $this->getManufacturer($id, $data)); $this->response->setOutput($manufacturer); } else { $manufacturers = array('manufacturers' => $this->getManufacturers()); $this->response->setOutput($manufacturers); } }
public function getRecurringDescription($id = NULL) { $this->request->post['product_id'] = $id; $this->request->post['recurring_id'] = $this->request->get['recurring_id']; if (isset($this->request->get['quantity'])) { $this->request->post['quantity'] = $this->request->get['quantity']; } $data = parent::getInternalRouteData('product/product/getRecurringDescription', true); ApiException::evaluateErrors($data); if (isset($data['success'])) { $product = array('recurring_description' => $data['success']); $this->response->setOutput($product); } else { // No description found. throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_NOT_FOUND, ErrorCodes::ERRORCODE_RECURRING_DESCRIPTION_NOT_FOUND, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_RECURRING_DESCRIPTION_NOT_FOUND)); } }
/** * Resource methods */ public function get() { $include = null; $includes = array(); if (isset($this->request->get['include'])) { $include = $this->request->get['include']; $includes = explode(',', $include); } $output = array(); if ($include == null || in_array(self::INCLUDE_LANGUAGES_KEY, $includes)) { $languages = parent::getInternalApiRouteData('common/language'); $output = array_merge($output, $languages); } if ($include == null || in_array(self::INCLUDE_CURRENCIES_KEY, $includes)) { $currencies = parent::getInternalApiRouteData('common/currency'); $output = array_merge($output, $currencies); } if ($include == null || in_array(self::INCLUDE_COUNTRIES_KEY, $includes)) { $countries = parent::getInternalApiRouteData('common/country'); $output = array_merge($output, $countries); } if ($include == null || in_array(self::INCLUDE_SETTINGS_KEY, $includes)) { $settings = parent::getInternalApiRouteData('common/settings'); $output = array_merge($output, $settings); } if ($include == null || in_array(self::INCLUDE_CUSTOMER_GROUPS_KEY, $includes)) { $customerGroups = parent::getInternalApiRouteData('common/customer_group'); $output = array_merge($output, $customerGroups); } if ($include == null || in_array(self::INCLUDE_CART_KEY, $includes)) { $cart = parent::getInternalApiRouteData('cart/cart'); $output = array_merge($output, $cart); } if ($include == null || in_array(self::INCLUDE_WISHLIST_KEY, $includes)) { $wishlist['wishlist'] = null; if ($this->customer->isLogged()) { $wishlist = parent::getInternalApiRouteData('account/wishlist'); } $output = array_merge($output, $wishlist); } $this->response->setOutput($output); }
/** * Resource methods */ public function post() { $data = parent::getInternalRouteData('account/forgotten'); ApiException::evaluateErrors($data); }
/** * @param CandidateValidator $validator */ public function __construct(CandidateValidator $validator) { $this->validator = $validator; // call parent construct parent::__construct(new FractalManager()); }
/** * Constructor * @param Client $Client * @param Agency $agency * @param JobsValidator $validator */ public function __construct(JobsValidator $validator) { $this->validator = $validator; // call parent construct parent::__construct(new Manager()); }