当前位置: 首页>>代码示例>>PHP>>正文


PHP validate::isLoadedObject方法代码示例

本文整理汇总了PHP中validate::isLoadedObject方法的典型用法代码示例。如果您正苦于以下问题:PHP validate::isLoadedObject方法的具体用法?PHP validate::isLoadedObject怎么用?PHP validate::isLoadedObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validate的用法示例。


在下文中一共展示了validate::isLoadedObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteProduct

 public function deleteProduct($order, $orderDetail, $quantity)
 {
     if (!(int) $this->getCurrentState() || !validate::isLoadedObject($orderDetail)) {
         return false;
     }
     if ($this->hasBeenDelivered()) {
         if (!Configuration::get('PS_ORDER_RETURN', null, null, $this->id_shop)) {
             throw new PrestaShopException('PS_ORDER_RETURN is not defined in table configuration');
         }
         $orderDetail->product_quantity_return += (int) $quantity;
         return $orderDetail->update();
     } elseif ($this->hasBeenPaid()) {
         $orderDetail->product_quantity_refunded += (int) $quantity;
         return $orderDetail->update();
     }
     return $this->_deleteProduct($orderDetail, (int) $quantity);
 }
开发者ID:TheTypoMaster,项目名称:neotienda,代码行数:17,代码来源:NeoExchanges.php

示例2: postload_configure

 public function postload_configure()
 {
     $context = Context::getContext();
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     //store PS version for later use
     $this->psVersion = _PS_VERSION_;
     // language to use
     if ($lng = $arguments->getOpt('lang', false)) {
         if (Validate::isLanguageIsoCode($lng)) {
             $this->lang = Language::getIdByIso($lng);
             $language = new Language($this->lang);
             if (validate::isLoadedObject($language)) {
                 $context->lang = $language;
             } else {
                 echo "Could not load language {$lng}\n";
                 exit(1);
             }
         } else {
             echo "Warning: {$lng} is not a valid iso code\n";
             echo "Using default lang\n";
             $this->lang = Configuration::get('PS_LANG_DEFAULT');
             $language = new Language($this->lang);
             $context->lang = $language;
         }
     } else {
         $this->lang = Configuration::get('PS_LANG_DEFAULT');
         $language = new Language($this->lang);
         if (!Validate::isLoadedObject($language)) {
             echo "Fatal error: could not load default language !\n";
             exit(1);
         }
         $context->lang = $language;
     }
     // do we set global ?
     if ($arguments->getOpt('global', false)) {
         $context->shop->id_shop_group = Shop::CONTEXT_ALL;
         Shop::setContext(Shop::CONTEXT_ALL);
         $this->global = true;
     }
     if ($opt = $arguments->getOpt('groupid', false)) {
         //Check if we have set global before as it is non sense
         if ($context->shop->id_shop_group === Shop::CONTEXT_ALL) {
             echo "You can not specify --global with --groupid !\n";
             exit(1);
         }
         if (Validate::isUnsignedInt($opt)) {
             Shop::setContext(Shop::CONTEXT_GROUP);
             $context->shop->shop_group_id = $opt;
         } else {
             echo "{$opt} is not a valid shop id\n";
             exit(1);
         }
     }
     if ($opt = $arguments->getOpt('shopid')) {
         if ($context->shop->id_shop_group === Shop::CONTEXT_ALL) {
             echo "You can not specify --shopid with --global";
             exit(1);
         }
         //todo: check if we are on group context
         self::set_current_shop_context($opt);
     }
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:62,代码来源:ps-cli_configure.php

示例3: init

 /**
  * Initializes front controller: sets smarty variables,
  * class properties, redirects depending on context, etc.
  *
  * @global bool     $useSSL           SSL connection flag
  * @global Cookie   $cookie           Visitor's cookie
  * @global Smarty   $smarty
  * @global Cart     $cart             Visitor's cart
  * @global string   $iso              Language ISO
  * @global Country  $defaultCountry   Visitor's country object
  * @global string   $protocol_link
  * @global string   $protocol_content
  * @global Link     $link
  * @global array    $css_files
  * @global array    $js_files
  * @global Currency $currency         Visitor's selected currency
  *
  * @throws PrestaShopException
  */
 public function init()
 {
     /**
      * Globals are DEPRECATED as of version 1.5.0.1
      * Use the Context object to access objects instead.
      * Example: $this->context->cart
      */
     global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     parent::init();
     // If current URL use SSL, set it true (used a lot for module redirect)
     if (Tools::usingSecureMode()) {
         $useSSL = true;
     }
     // For compatibility with globals, DEPRECATED as of version 1.5.0.1
     $css_files = $this->css_files;
     $js_files = $this->js_files;
     $this->sslRedirection();
     if ($this->ajax) {
         $this->display_header = false;
         $this->display_footer = false;
     }
     // If account created with the 2 steps register process, remove 'account_created' from cookie
     if (isset($this->context->cookie->account_created)) {
         $this->context->smarty->assign('account_created', 1);
         unset($this->context->cookie->account_created);
     }
     ob_start();
     // Init cookie language
     // @TODO This method must be moved into switchLanguage
     Tools::setCookieLanguage($this->context->cookie);
     $protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
     $useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
     $protocol_content = $useSSL ? 'https://' : 'http://';
     $link = new Link($protocol_link, $protocol_content);
     $this->context->link = $link;
     if ($id_cart = (int) $this->recoverCart()) {
         $this->context->cookie->id_cart = (int) $id_cart;
     }
     if ($this->auth && !$this->context->customer->isLogged($this->guestAllowed)) {
         Tools::redirect('index.php?controller=authentication' . ($this->authRedirection ? '&back=' . $this->authRedirection : ''));
     }
     /* Theme is missing */
     if (!is_dir(_PS_THEME_DIR_)) {
         throw new PrestaShopException(sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\'))));
     }
     if (Configuration::get('PS_GEOLOCATION_ENABLED')) {
         if (($new_default = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($new_default)) {
             $this->context->country = $new_default;
         }
     } elseif (Configuration::get('PS_DETECT_COUNTRY')) {
         $has_currency = isset($this->context->cookie->id_currency) && (int) $this->context->cookie->id_currency;
         $has_country = isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country;
         $has_address_type = false;
         if ((int) $this->context->cookie->id_cart && ($cart = new Cart($this->context->cookie->id_cart)) && Validate::isLoadedObject($cart)) {
             $has_address_type = isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
         }
         if ((!$has_currency || $has_country) && !$has_address_type) {
             $id_country = $has_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country) ? (int) Country::getByIso(strtoupper($this->context->cookie->iso_code_country)) : (int) Tools::getCountry();
             $country = new Country($id_country, (int) $this->context->cookie->id_lang);
             if (validate::isLoadedObject($country) && $this->context->country->id !== $country->id) {
                 $this->context->country = $country;
                 $this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($country->id_currency ? (int) $country->id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT'))->id;
                 $this->context->cookie->iso_code_country = strtoupper($country->iso_code);
             }
         }
     }
     $currency = Tools::setCurrency($this->context->cookie);
     if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) {
         $this->context->customer->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     } elseif (isset($_GET['mylogout'])) {
         $this->context->customer->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     }
     /* Cart already exists */
     if ((int) $this->context->cookie->id_cart) {
         if (!isset($cart)) {
//.........这里部分代码省略.........
开发者ID:ekachandrasetiawan,项目名称:BeltcareCom,代码行数:101,代码来源:FrontController.php

示例4: init

 /**
  * Initializes front controller: sets smarty variables,
  * class properties, redirects depending on context, etc.
  *
  * @global bool     $useSSL           SSL connection flag
  * @global Cookie   $cookie           Visitor's cookie
  * @global Smarty   $smarty
  * @global Cart     $cart             Visitor's cart
  * @global string   $iso              Language ISO
  * @global Country  $defaultCountry   Visitor's country object
  * @global string   $protocol_link
  * @global string   $protocol_content
  * @global Link     $link
  * @global array    $css_files
  * @global array    $js_files
  * @global Currency $currency         Visitor's selected currency
  *
  * @throws PrestaShopException
  */
 public function init()
 {
     /*
      * Globals are DEPRECATED as of version 1.5.0.1
      * Use the Context object to access objects instead.
      * Example: $this->context->cart
      */
     global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     parent::init();
     // enable Symfony error handler if debug mode enabled
     $this->initDebugguer();
     // If current URL use SSL, set it true (used a lot for module redirect)
     if (Tools::usingSecureMode()) {
         $useSSL = true;
     }
     // For compatibility with globals, DEPRECATED as of version 1.5.0.1
     $css_files = $this->css_files;
     $js_files = $this->js_files;
     $this->sslRedirection();
     if ($this->ajax) {
         $this->display_header = false;
         $this->display_footer = false;
     }
     // If account created with the 2 steps register process, remove 'account_created' from cookie
     if (isset($this->context->cookie->account_created)) {
         unset($this->context->cookie->account_created);
     }
     ob_start();
     // Init cookie language
     // @TODO This method must be moved into switchLanguage
     Tools::setCookieLanguage($this->context->cookie);
     $protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
     $useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
     $protocol_content = $useSSL ? 'https://' : 'http://';
     $link = new Link($protocol_link, $protocol_content);
     $this->context->link = $link;
     if ($id_cart = (int) $this->recoverCart()) {
         $this->context->cookie->id_cart = (int) $id_cart;
     }
     if ($this->auth && !$this->context->customer->isLogged()) {
         Tools::redirect('index.php?controller=authentication' . ($this->authRedirection ? '&back=' . $this->authRedirection : ''));
     }
     /* Theme is missing */
     if (!is_dir(_PS_THEME_DIR_)) {
         throw new PrestaShopException(sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\'))));
     }
     if (Configuration::get('PS_GEOLOCATION_ENABLED')) {
         if (($new_default = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($new_default)) {
             $this->context->country = $new_default;
         }
     } elseif (Configuration::get('PS_DETECT_COUNTRY')) {
         $has_currency = isset($this->context->cookie->id_currency) && (int) $this->context->cookie->id_currency;
         $has_country = isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country;
         $has_address_type = false;
         if ((int) $this->context->cookie->id_cart && ($cart = new Cart($this->context->cookie->id_cart)) && Validate::isLoadedObject($cart)) {
             $has_address_type = isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
         }
         if ((!$has_currency || $has_country) && !$has_address_type) {
             $id_country = $has_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country) ? (int) Country::getByIso(strtoupper($this->context->cookie->iso_code_country)) : (int) Tools::getCountry();
             $country = new Country($id_country, (int) $this->context->cookie->id_lang);
             if (!$has_currency && validate::isLoadedObject($country) && $this->context->country->id !== $country->id) {
                 $this->context->country = $country;
                 $this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($country->id_currency ? (int) $country->id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT'))->id;
                 $this->context->cookie->iso_code_country = strtoupper($country->iso_code);
             }
         }
     }
     $currency = Tools::setCurrency($this->context->cookie);
     if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) {
         $this->context->customer->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     } elseif (isset($_GET['mylogout'])) {
         $this->context->customer->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     }
     /* Cart already exists */
     if ((int) $this->context->cookie->id_cart) {
//.........这里部分代码省略.........
开发者ID:M03G,项目名称:PrestaShop,代码行数:101,代码来源:FrontController.php


注:本文中的validate::isLoadedObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。