Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/wbs24.ozonapinew/lib/Agents/ |
Upload File : |
<?php namespace Wbs24\Ozonapinew\Agents; use Wbs24\Ozonapinew\Agents; use Wbs24\Ozonapinew\Controller\Main as MainController; class UpdateOrder extends Agents { protected $intervalMinutes = 5; public function setAccountIndex(int $accountIndex) { $dependencies = $this->getDependencies($accountIndex); $this->setDependences([], $dependencies, $accountIndex); } public function setDependences($objects = [], $dependencies, $accountIndex) { $this->MainController = $objects['MainController'] ?? new MainController(); } public function updatePackageLabelAgent($accounts = [1]) { $postfixAgentName = '::setPackageLabelAgent();'; foreach ($accounts as $accountIndex) { $this->wrappers->Option->setPrefix($accountIndex); $apiKey = $this->wrappers->Option->get($this->moduleId, 'apiKey'); if (!$apiKey) continue; $autoPackageLabel = $this->wrappers->Option->get($this->moduleId, 'autoPackageLabel') == 'Y'; if ($accountIndex > 1) { $postfixAgentName = str_replace("()", "(${accountIndex})", $postfixAgentName); } if ($autoPackageLabel) { $this->updateAgent($postfixAgentName); } } } public function updateAgent($postfixAgentName) { $agentName = $this->getNameAgent($postfixAgentName); $interval = $this->intervalMinutes; $this->addAgent($agentName, $interval); } public static function setPackageLabelAgent(int $accountIndex = 1): string { $UpdateOrder = new UpdateOrder(); $UpdateOrder->setAccountIndex($accountIndex); $UpdateOrder->MainController->process( [ 'action' => 'setPackageLabel', 'accountIndex' => $accountIndex, ] ); return '\\'.__CLASS__.'::'.__FUNCTION__.'('.$accountIndex.');'; } // вспомогательные функции public function getNameAgent($postfixAgentName): string { return "\\".__CLASS__.$postfixAgentName; } protected function agentCheckOn(): bool { return $this->wrappers->Option->get($this->moduleId, "priceUpdateFlag") == "Y" ? true : false; } public function setAgentsLock() { $this->wrappers->Option->set($this->moduleId, $this->lockOption, 'Y'); } public function unsetAgentsLock() { $this->wrappers->Option->set($this->moduleId, $this->lockOption, 'N'); } public function areAgentsLocked() { return ($this->wrappers->Option->get($this->moduleId, $this->lockOption) == 'Y'); } }