[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Console; 11 12 use Joomla\CMS\Session\MetadataManager; 13 use Joomla\Console\Command\AbstractCommand; 14 use Joomla\Session\SessionInterface; 15 use Symfony\Component\Console\Command\Command; 16 use Symfony\Component\Console\Input\InputInterface; 17 use Symfony\Component\Console\Output\OutputInterface; 18 use Symfony\Component\Console\Style\SymfonyStyle; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('JPATH_PLATFORM') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * Console command for performing session metadata garbage collection 26 * 27 * @since 4.0.0 28 */ 29 class SessionMetadataGcCommand extends AbstractCommand 30 { 31 /** 32 * The default command name 33 * 34 * @var string 35 * @since 4.0.0 36 */ 37 protected static $defaultName = 'session:metadata:gc'; 38 39 /** 40 * The session metadata manager. 41 * 42 * @var MetadataManager 43 * @since 4.0.0 44 */ 45 private $metadataManager; 46 47 /** 48 * The session object. 49 * 50 * @var SessionInterface 51 * @since 4.0.0 52 */ 53 private $session; 54 55 /** 56 * Instantiate the command. 57 * 58 * @param SessionInterface $session The session object. 59 * @param MetadataManager $metadataManager The session metadata manager. 60 * 61 * @since 4.0.0 62 */ 63 public function __construct(SessionInterface $session, MetadataManager $metadataManager) 64 { 65 $this->session = $session; 66 $this->metadataManager = $metadataManager; 67 68 parent::__construct(); 69 } 70 71 /** 72 * Internal function to execute the command. 73 * 74 * @param InputInterface $input The input to inject into the command. 75 * @param OutputInterface $output The output to inject into the command. 76 * 77 * @return integer The command exit code 78 * 79 * @since 4.0.0 80 */ 81 protected function doExecute(InputInterface $input, OutputInterface $output): int 82 { 83 $symfonyStyle = new SymfonyStyle($input, $output); 84 85 $symfonyStyle->title('Running Session Metadata Garbage Collection'); 86 87 $sessionExpire = $this->session->getExpire(); 88 89 $this->metadataManager->deletePriorTo(time() - $sessionExpire); 90 91 $symfonyStyle->success('Metadata garbage collection completed.'); 92 93 return Command::FAILURE; 94 } 95 96 /** 97 * Configure the command. 98 * 99 * @return void 100 * 101 * @since 4.0.0 102 */ 103 protected function configure(): void 104 { 105 $help = "<info>%command.name%</info> runs the garbage collection operation for Joomla session metadata 106 \nUsage: <info>php %command.full_name%</info>"; 107 108 $this->setDescription('Perform session metadata garbage collection'); 109 $this->setHelp($help); 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |