當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Scheduler::isAllowedToRequest方法代碼示例

本文整理匯總了PHP中Scheduler::isAllowedToRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Scheduler::isAllowedToRequest方法的具體用法?PHP Scheduler::isAllowedToRequest怎麽用?PHP Scheduler::isAllowedToRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Scheduler的用法示例。


在下文中一共展示了Scheduler::isAllowedToRequest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doPostSynch

function doPostSynch($wsName, $dateFrom, $dateTo)
{
    global $dao, $postOSIReq, $CONF_LastrequestLbl, $isOkResponses, $nbChildrenProducts, $nbResponse200, $nbResponseError, $nbResponse409, $nbNoReference;
    /* Check if allow to get this request */
    $isAllow = Scheduler::isAllowedToRequest($wsName);
    if (!ForceRequest::isForcedRequest() && !$isAllow) {
        return;
    }
    switch ($wsName) {
        /*
         * WSO-P005
         * POST /article
         */
        case "WSO-P005":
            Log::write("###### Do request " . $wsName . " - action=create_article ######", "info");
            $offset = 0;
            $limit = 1000;
            do {
                $newProducts = $dao->getLastCreateProducts($dateFrom, $dateTo, GlobalConfig::getDefaultLangId(), GlobalConfig::getDefaultCountryId(), $offset, $limit);
                $isOkResponses = true;
                $nbMainProducts = 0;
                $nbChildrenProducts = 0;
                $nbResponse200 = 0;
                $nbResponseError = 0;
                $nbResponse409 = 0;
                $nbNoReference = 0;
                if ($newProducts) {
                    $nbMainProducts = count($newProducts);
                    foreach ($newProducts as $product) {
                        /*
                         * Create main product
                         * @param $product => array
                         * @param create child products
                         * @param send publication
                         */
                        createMainProduct($product, true, true);
                    }
                    Log::write("Nb total main products = " . $nbMainProducts, "info");
                    Log::write("Nb total children products = " . $nbChildrenProducts, "info");
                    Log::write("Nb without reference = " . $nbNoReference, "info");
                    Log::write("Nb sent products = " . ($nbMainProducts + $nbChildrenProducts - $nbNoReference), "info");
                    Log::write("Nb response 200 (ok) = " . $nbResponse200, "info");
                    Log::write("Nb response 409 (duplicate) = " . $nbResponse409, "info");
                    Log::write("Nb response error = " . $nbResponseError, "info");
                } else {
                    Log::write("No request to send", "info");
                }
                $offset += $limit;
            } while (count($newProducts) == $limit);
            if ($isOkResponses && !ForceRequest::isForcedRequest()) {
                Configuration::updateValue($CONF_LastrequestLbl . $wsName, Scheduler::getTimeOnInit());
            }
            Log::write("End request  " . $wsName . " ------<br /><br />", "info");
            break;
            /*
             * WSO-P006
             * POST /article/$reference$
             */
        /*
         * WSO-P006
         * POST /article/$reference$
         */
        case "WSO-P006":
            Log::write("###### Do request " . $wsName . " - action=update_article ######", "info");
            $offset = 0;
            $limit = 1000;
            do {
                $updateProducts = $dao->getLastUpdateProducts($dateFrom, $dateTo, GlobalConfig::getDefaultLangId(), GlobalConfig::getDefaultCountryId(), $offset, $limit);
                $isOkResponses = true;
                $nbMainProducts = 0;
                $nbChildrenProducts = 0;
                $nbResponse200 = 0;
                $nbResponseError = 0;
                $nbResponse409 = 0;
                $nbNoReference = 0;
                if ($updateProducts) {
                    $nbMainProducts = count($updateProducts);
                    foreach ($updateProducts as $product) {
                        updateMainProduct($product);
                    }
                    Log::write("Nb total main products = " . $nbMainProducts, "info");
                    Log::write("Nb total children products = " . $nbChildrenProducts, "info");
                    Log::write("Nb without reference = " . $nbNoReference, "info");
                    Log::write("Nb sent products = " . ($nbMainProducts + $nbChildrenProducts - $nbNoReference), "info");
                    Log::write("Nb response 200 (ok) = " . $nbResponse200, "info");
                    Log::write("Nb response 409 (duplicate) = " . $nbResponse409, "info");
                    Log::write("Nb response error = " . $nbResponseError, "info");
                } else {
                    Log::write("No request to send", "info");
                }
                $offset += $limit;
            } while (count($updateProducts) == $limit);
            if ($isOkResponses && !ForceRequest::isForcedRequest()) {
                Configuration::updateValue($CONF_LastrequestLbl . $wsName, Scheduler::getTimeOnInit());
            }
            Log::write("End request  " . $wsName . " ------<br /><br />", "info");
            break;
            /*
             * WSO-P010
             * POST /client/web
//.........這裏部分代碼省略.........
開發者ID:rtajmahal,項目名稱:PrestaShop-modules,代碼行數:101,代碼來源:postSynchCtrl.php


注:本文中的Scheduler::isAllowedToRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。