本文整理汇总了PHP中FrontController::init方法的典型用法代码示例。如果您正苦于以下问题:PHP FrontController::init方法的具体用法?PHP FrontController::init怎么用?PHP FrontController::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrontController
的用法示例。
在下文中一共展示了FrontController::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize addresses controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
if (!Validate::isLoadedObject($this->context->customer)) {
die(Tools::displayError('The customer could not be found.'));
}
}
示例2: init
public function init()
{
parent::init();
AuthController::requireLogin();
AuthController::requireShopSession();
$this->setSmarty();
}
示例3: init
/**
* Initialize order confirmation controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
$this->id_cart = (int) Tools::getValue('id_cart', 0);
$is_guest = false;
/* check if the cart has been made by a Guest customer, for redirect link */
if (Cart::isGuestCartByCartId($this->id_cart)) {
$is_guest = true;
$redirectLink = 'index.php?controller=guest-tracking';
} else {
$redirectLink = 'index.php?controller=history';
}
$this->id_module = (int) Tools::getValue('id_module', 0);
$this->id_order = Order::getOrderByCartId((int) $this->id_cart);
$this->secure_key = Tools::getValue('key', false);
$order = new Order((int) $this->id_order);
if ($is_guest) {
$customer = new Customer((int) $order->id_customer);
$redirectLink .= '&id_order=' . $order->reference . '&email=' . urlencode($customer->email);
}
if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) {
Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '&slowvalidation' : ''));
}
$this->reference = $order->reference;
if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) {
Tools::redirect($redirectLink);
}
$module = Module::getInstanceById((int) $this->id_module);
if ($order->payment != $module->displayName) {
Tools::redirect($redirectLink);
}
}
示例4: init
/**
* Initialize guest tracking controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
if ($this->context->customer->isLogged()) {
Tools::redirect('history.php');
}
}
示例5: init
/**
* Initialize order return controller.
*
* @see FrontController::init()
*/
public function init()
{
parent::init();
$id_order_return = (int) Tools::getValue('id_order_return');
if (!isset($id_order_return) || !Validate::isUnsignedId($id_order_return)) {
$this->redirect_after = '404';
$this->redirect();
} else {
$order_return = new OrderReturn((int) $id_order_return);
if (Validate::isLoadedObject($order_return) && $order_return->id_customer == $this->context->cookie->id_customer) {
$order = new Order((int) $order_return->id_order);
if (Validate::isLoadedObject($order)) {
if ($order_return->state == 1) {
$this->warning[] = $this->trans('You must wait for confirmation before returning any merchandise.', array(), 'Shop.Notifications.Warning');
}
// StarterTheme: Use presenters!
$this->context->smarty->assign(array('return' => $this->getTemplateVarOrderReturn($order_return), 'products' => $this->getTemplateVarProducts((int) $order_return->id, $order)));
} else {
$this->redirect_after = '404';
$this->redirect();
}
} else {
$this->redirect_after = '404';
$this->redirect();
}
}
}
示例6: init
/**
* Initialize category controller
* @see FrontController::init()
*/
public function init()
{
// Get category ID
$id_category = (int) Tools::getValue('id_category');
if (!$id_category || !Validate::isUnsignedId($id_category)) {
$this->errors[] = Tools::displayError('Missing category ID');
}
// Instantiate category
$this->category = new Category($id_category, $this->context->language->id);
parent::init();
if (!$this->ajax) {
//check if the category is active and return 404 error if is disable.
if (!$this->category->active) {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
}
//check if category can be accessible by current customer and return 403 if not
if (!$this->category->checkAccess($this->context->customer->id)) {
header('HTTP/1.1 403 Forbidden');
header('Status: 403 Forbidden');
$this->errors[] = Tools::displayError('You do not have access to this category.');
$this->customer_access = false;
}
}
}
示例7: init
public function init()
{
parent::init();
AuthController::getInstance()->requireLogin();
ErrorHandler::getInstance()->getUrlErrorMessage();
$this->setSmarty();
}
示例8: init
public function init()
{
$this->attachBehavior('breadcrumbs', new CrumbsBehaviour());
$this->breadcrumbs->setEnabled(true);
$this->initProfile();
parent::init();
}
示例9: init
/**
* Initialize cms controller
* @see FrontController::init()
*/
public function init()
{
if ($id_cms = (int) Tools::getValue('id_cms')) {
$this->cms = new CMS($id_cms, $this->context->language->id);
} elseif ($id_cms_category = (int) Tools::getValue('id_cms_category')) {
$this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id);
}
if (Configuration::get('PS_SSL_ENABLED') && Tools::getValue('content_only') && Tools::getValue('id_cms') == (int) Configuration::get('PS_CONDITIONS_CMS_ID') && Validate::isLoadedObject($this->cms)) {
$this->ssl = true;
}
parent::init();
$this->canonicalRedirection();
// assignCase (1 = CMS page, 2 = CMS category)
if (Validate::isLoadedObject($this->cms)) {
$adtoken = Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) Tools::getValue('id_employee'));
if (!$this->cms->isAssociatedToShop() || !$this->cms->active && Tools::getValue('adtoken') != $adtoken) {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
} else {
$this->assignCase = 1;
}
} elseif (Validate::isLoadedObject($this->cms_category)) {
$this->assignCase = 2;
} else {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
}
}
示例10: init
/**
* Initialize stores controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
if (!extension_loaded('Dom')) {
$this->errors[] = Tools::displayError('PHP "Dom" extension has not been loaded.');
$this->context->smarty->assign('errors', $this->errors);
}
}
示例11: init
public function init()
{
parent::init();
AuthController::requireLogin();
AuthController::requireShopSession();
Shop::getInstance()->requireOpenShop();
$this->setSmarty();
}
示例12: init
/**
* Initialize guest tracking controller
* @see FrontController::init()
*/
public function init()
{
$this->display_column_left = false;
parent::init();
if ($this->context->customer->isLogged()) {
Tools::redirect('history.php');
}
}
示例13: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->module = Module::getInstanceByName(Tools::getValue('module'));
if (!$this->module->active) {
Tools::redirect('index.php');
}
$this->initContent();
}
示例14: init
/**
* Initialize cart controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
// Get page main parameters
$this->id_product = (int) Tools::getValue('id_product', null);
$this->id_product_attribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
$this->customization_id = (int) Tools::getValue('id_customization');
$this->qty = abs(Tools::getValue('qty', 1));
$this->id_address_delivery = (int) Tools::getValue('id_address_delivery');
}
示例15: init
/**
* Initialize search controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
$this->instant_search = Tools::getValue('instantSearch');
$this->ajax_search = Tools::getValue('ajaxSearch');
if ($this->instant_search || $this->ajax_search) {
$this->display_header = false;
$this->display_footer = false;
}
}