[ Index ] |
PHP Cross Reference of phpBB-3.1.12-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\hook; 15 16 /** 17 * The hook finder locates installed hooks. 18 */ 19 class finder 20 { 21 protected $phpbb_root_path; 22 protected $cache; 23 protected $php_ext; 24 25 /** 26 * Creates a new finder instance. 27 * 28 * @param string $phpbb_root_path Path to the phpbb root directory 29 * @param string $php_ext php file extension 30 * @param \phpbb\cache\driver\driver_interface $cache A cache instance or null 31 */ 32 public function __construct($phpbb_root_path, $php_ext, \phpbb\cache\driver\driver_interface $cache = null) 33 { 34 $this->phpbb_root_path = $phpbb_root_path; 35 $this->cache = $cache; 36 $this->php_ext = $php_ext; 37 } 38 39 /** 40 * Finds all hook files. 41 * 42 * @param bool $cache Whether the result should be cached 43 * @return array An array of paths to found hook files 44 */ 45 public function find($cache = true) 46 { 47 if (!defined('DEBUG') && $cache && $this->cache) 48 { 49 $hook_files = $this->cache->get('_hooks'); 50 if ($hook_files !== false) 51 { 52 return $hook_files; 53 } 54 } 55 56 $hook_files = array(); 57 58 // Now search for hooks... 59 $dh = @opendir($this->phpbb_root_path . 'includes/hooks/'); 60 61 if ($dh) 62 { 63 while (($file = readdir($dh)) !== false) 64 { 65 if (strpos($file, 'hook_') === 0 && substr($file, -strlen('.' . $this->php_ext)) === '.' . $this->php_ext) 66 { 67 $hook_files[] = substr($file, 0, -(strlen($this->php_ext) + 1)); 68 } 69 } 70 closedir($dh); 71 } 72 73 if ($cache && $this->cache) 74 { 75 $this->cache->put('_hooks', $hook_files); 76 } 77 78 return $hook_files; 79 } 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |