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


PHP Admin::activateMaintenanceMode方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param string $name The name of the application
  * @param string $version The version of the application
  *
  * @api
  */
 public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
 {
     parent::__construct('Pimcore CLI', Version::getVersion());
     // init default autoload namespaces
     $this->initDefaultAutoloadNamespaces();
     // allow to register commands here (e.g. through plugins)
     \Pimcore::getEventManager()->trigger('system.console.init', $this);
     $dispatcher = new EventDispatcher();
     $this->setDispatcher($dispatcher);
     $dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
         if ($event->getInput()->getOption("maintenance-mode")) {
             // enable maintenance mode if requested
             $maintenanceModeId = 'cache-warming-dummy-session-id';
             $event->getOutput()->writeln('Activating maintenance mode with ID <comment>' . $maintenanceModeId . '</comment> ...');
             Admin::activateMaintenanceMode($maintenanceModeId);
         }
     });
     $dispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) {
         if ($event->getInput()->getOption("maintenance-mode")) {
             $event->getOutput()->writeln('Deactivating maintenance mode...');
             Admin::deactivateMaintenanceMode();
         }
     });
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:32,代码来源:Application.php

示例2: enableMaintenanceMode

 /**
  * Enable maintenance mode if --maintenanceMode option was passed
  */
 protected function enableMaintenanceMode()
 {
     // enable maintenance mode if requested
     if ($this->input->getOption('maintenanceMode')) {
         $maintenanceModeId = 'cache-warming-dummy-session-id';
         $this->output->writeln('Activating maintenance mode with ID <comment>%s</comment>...', $maintenanceModeId);
         Admin::activateMaintenanceMode($maintenanceModeId);
         // set the timeout between each iteration to 0 if maintenance mode is on, because
         // we don't have to care about the load on the server
         Warming::setTimoutBetweenIteration(0);
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:15,代码来源:CacheWarmingCommand.php

示例3: maintenanceAction

 public function maintenanceAction()
 {
     $this->checkPermission("maintenance_mode");
     if ($this->getParam("activate")) {
         Tool\Admin::activateMaintenanceMode();
     }
     if ($this->getParam("deactivate")) {
         Tool\Admin::deactivateMaintenanceMode();
     }
     $this->_helper->json(["success" => true]);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:11,代码来源:MiscController.php

示例4: chdir

chdir(__DIR__);
include_once "startup.php";
use Pimcore\Cache\Tool\Warming as Warmer;
try {
    $opts = new \Zend_Console_Getopt(array('types|t=s' => 'perform warming only for this types of elements (comma separated), valid arguments: document,asset,object (default: all types)', "documentTypes|dt=s" => "only for these types of documents (comma separated), valid arguments: page,snippet,folder,link (default: all types)", "assetTypes|at=s" => "only for these types of assets (comma separated), valid arguments: folder,image,text,audio,video,document,archive,unknown (default: all types)", "objectTypes|ot=s" => "only for these types of objects (comma separated), valid arguments: object,folder,variant (default: all types)", "classes|c=s" => "this is only for objects! filter by class (comma separated), valid arguments: class-names of your classes defined in pimcore", "maintenanceMode|m" => "enable maintenance mode during cache warming", 'verbose|v' => 'show detailed information during the maintenance (for debug, ...)', 'help|h' => 'display this help'));
} catch (Exception $e) {
    echo $e->getMessage();
}
// display help message
if ($opts->getOption("help")) {
    echo $opts->getUsageMessage();
    exit;
}
// enable maintenance mode if requested
if ($opts->getOption("maintenanceMode")) {
    \Pimcore\Tool\Admin::activateMaintenanceMode("cache-warming-dummy-session-id");
    // set the timeout between each iteration to 0 if maintenance mode is on, because we don't have to care about the load on the server
    Warmer::setTimoutBetweenIteration(0);
}
if ($opts->getOption("verbose")) {
    $writer = new \Zend_Log_Writer_Stream('php://output');
    $logger = new \Zend_Log($writer);
    \Logger::addLogger($logger);
    // set all priorities
    \Logger::setVerbosePriorities();
}
// get valid types (default all types)
$types = array("document", "asset", "object");
if ($opts->getOption("types")) {
    $types = explode(",", $opts->getOption("types"));
}
开发者ID:Gerhard13,项目名称:pimcore,代码行数:31,代码来源:cache-warming.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $currentRevision = null;
     if ($input->getOption("source-build")) {
         $currentRevision = $input->getOption("source-build");
     }
     $availableUpdates = Update::getAvailableUpdates($currentRevision);
     if ($input->getOption("list")) {
         if (count($availableUpdates["releases"])) {
             $rows = [];
             foreach ($availableUpdates["releases"] as $release) {
                 $rows[] = [$release["version"], date("Y-m-d", $release["date"]), $release["id"]];
             }
             $table = new Table($output);
             $table->setHeaders(['Version', 'Date', 'Build'])->setRows($rows);
             $table->render();
         }
         if (count($availableUpdates["revisions"])) {
             $this->output->writeln("The latest available build is: <comment>" . $availableUpdates["revisions"][0]["id"] . "</comment> (" . date("Y-m-d", $availableUpdates["revisions"][0]["date"]) . ")");
         }
         if (!count($availableUpdates["releases"]) && !count($availableUpdates["revisions"])) {
             $this->output->writeln("<info>No updates available</info>");
         }
     }
     if ($input->getOption("update")) {
         $returnMessages = [];
         $build = null;
         $updateInfo = trim($input->getOption("update"));
         if (is_numeric($updateInfo)) {
             $build = $updateInfo;
         } else {
             // get build nr. by version number
             foreach ($availableUpdates["releases"] as $release) {
                 if ($release["version"] == $updateInfo) {
                     $build = $release["id"];
                     break;
                 }
             }
         }
         if (!$build) {
             $this->writeError("Update with build / version " . $updateInfo . " not found.");
             exit;
         }
         if (!Update::isWriteable()) {
             $this->writeError(PIMCORE_PATH . " is not recursivly writable, please check!");
             exit;
         }
         if (!Update::isComposerAvailable()) {
             $this->writeError("Composer is not installed properly, please ensure composer is in your PATH variable.");
             exit;
         }
         $helper = $this->getHelper('question');
         $question = new ConfirmationQuestion("You are going to update to build {$build}! Continue with this action? (y/n)", false);
         if (!$helper->ask($input, $output, $question)) {
             return;
         }
         $this->output->writeln("Starting the update process ...");
         if ($input->getOption("dry-run")) {
             $this->output->writeln("<info>---------- DRY-RUN ----------</info>");
         }
         $jobs = Update::getJobs($build, $currentRevision);
         $steps = count($jobs["parallel"]) + count($jobs["procedural"]);
         $progress = new ProgressBar($output, $steps);
         $progress->start();
         foreach ($jobs["parallel"] as $job) {
             if ($job["type"] == "download") {
                 Update::downloadData($job["revision"], $job["url"]);
             }
             $progress->advance();
         }
         $maintenanceModeId = 'cache-warming-dummy-session-id';
         Admin::activateMaintenanceMode($maintenanceModeId);
         $stoppedByError = false;
         foreach ($jobs["procedural"] as $job) {
             if ($input->getOption("dry-run")) {
                 $job["dry-run"] = true;
             }
             $script = realpath(PIMCORE_PATH . DIRECTORY_SEPARATOR . "cli" . DIRECTORY_SEPARATOR . "console.php");
             $return = Console::runPhpScript($script, "internal:update-processor " . escapeshellarg(json_encode($job)));
             $return = trim($return);
             $returnData = @json_decode($return, true);
             if (is_array($returnData)) {
                 if (trim($returnData["message"])) {
                     $returnMessages[] = [$job["revision"], strip_tags($returnData["message"])];
                 }
                 if (!$returnData["success"]) {
                     $stoppedByError = true;
                     break;
                 }
             } else {
                 $stoppedByError = true;
                 break;
             }
             $progress->advance();
         }
         $progress->finish();
         Update::composerDumpAutoload();
         Admin::deactivateMaintenanceMode();
         $this->output->writeln("\n");
         if ($stoppedByError) {
//.........这里部分代码省略.........
开发者ID:solverat,项目名称:pimcore,代码行数:101,代码来源:UpdateCommand.php


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