[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\cron\event; 15 16 use phpbb\cron\manager; 17 use phpbb\lock\db; 18 use phpbb\request\request_interface; 19 use Symfony\Component\EventDispatcher\EventSubscriberInterface; 20 use Symfony\Component\HttpKernel\KernelEvents; 21 use Symfony\Component\HttpKernel\Event\PostResponseEvent; 22 23 /** 24 * Event listener that executes cron tasks, after the response was served 25 */ 26 class cron_runner_listener implements EventSubscriberInterface 27 { 28 /** 29 * @var db 30 */ 31 private $cron_lock; 32 33 /** 34 * @var manager 35 */ 36 private $cron_manager; 37 38 /** 39 * @var request_interface 40 */ 41 private $request; 42 43 /** 44 * Constructor 45 * 46 * @param db $lock 47 * @param manager $manager 48 * @param request_interface $request 49 */ 50 public function __construct(db $lock, manager $manager, request_interface $request) 51 { 52 $this->cron_lock = $lock; 53 $this->cron_manager = $manager; 54 $this->request = $request; 55 } 56 57 /** 58 * Runs the cron job after the response was sent 59 * 60 * @param PostResponseEvent $event The event 61 */ 62 public function on_kernel_terminate(PostResponseEvent $event) 63 { 64 $request = $event->getRequest(); 65 $controller_name = $request->get('_route'); 66 67 if ($controller_name !== 'phpbb_cron_run') 68 { 69 return; 70 } 71 72 $cron_type = $request->get('cron_type'); 73 74 if ($this->cron_lock->acquire()) 75 { 76 $task = $this->cron_manager->find_task($cron_type); 77 if ($task) 78 { 79 if ($task->is_parametrized()) 80 { 81 $task->parse_parameters($this->request); 82 } 83 84 if ($task->is_ready()) 85 { 86 $task->run(); 87 } 88 } 89 $this->cron_lock->release(); 90 } 91 } 92 93 /** 94 * {@inheritdoc} 95 */ 96 static public function getSubscribedEvents() 97 { 98 return array( 99 KernelEvents::TERMINATE => 'on_kernel_terminate', 100 ); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |