mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/16204] Remove hook finder and services file
PHPBB3-16204
This commit is contained in:
parent
d66960f4d5
commit
6c5fa362dd
4 changed files with 0 additions and 107 deletions
|
@ -143,14 +143,6 @@ if (@is_file($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload
|
|||
require_once($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload.php');
|
||||
}
|
||||
|
||||
/* @var $phpbb_hook_finder \phpbb\hook\finder */
|
||||
$phpbb_hook_finder = $phpbb_container->get('hook_finder');
|
||||
|
||||
foreach ($phpbb_hook_finder->find() as $hook)
|
||||
{
|
||||
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main event which is triggered on every page
|
||||
*
|
||||
|
|
|
@ -13,7 +13,6 @@ imports:
|
|||
- { resource: services_files.yml }
|
||||
- { resource: services_filesystem.yml }
|
||||
- { resource: services_help.yml }
|
||||
- { resource: services_hook.yml }
|
||||
- { resource: services_http.yml }
|
||||
- { resource: services_language.yml }
|
||||
- { resource: services_migrator.yml }
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
services:
|
||||
hook_finder:
|
||||
class: phpbb\hook\finder
|
||||
arguments:
|
||||
- '%core.root_path%'
|
||||
- '%core.php_ext%'
|
||||
- '@cache.driver'
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\hook;
|
||||
|
||||
/**
|
||||
* The hook finder locates installed hooks.
|
||||
*/
|
||||
class finder
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\cache\driver\driver_interface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Creates a new finder instance.
|
||||
*
|
||||
* @param string $phpbb_root_path Path to the phpbb root directory
|
||||
* @param string $php_ext php file extension
|
||||
* @param \phpbb\cache\driver\driver_interface $cache A cache instance or null
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, \phpbb\cache\driver\driver_interface $cache = null)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->cache = $cache;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all hook files.
|
||||
*
|
||||
* @param bool $cache Whether the result should be cached
|
||||
* @return array An array of paths to found hook files
|
||||
*/
|
||||
public function find($cache = true)
|
||||
{
|
||||
if (!defined('DEBUG') && $cache && $this->cache)
|
||||
{
|
||||
$hook_files = $this->cache->get('_hooks');
|
||||
if ($hook_files !== false)
|
||||
{
|
||||
return $hook_files;
|
||||
}
|
||||
}
|
||||
|
||||
$hook_files = array();
|
||||
|
||||
// Now search for hooks...
|
||||
$dh = @opendir($this->phpbb_root_path . 'includes/hooks/');
|
||||
|
||||
if ($dh)
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if (strpos($file, 'hook_') === 0 && substr($file, -strlen('.' . $this->php_ext)) === '.' . $this->php_ext)
|
||||
{
|
||||
$hook_files[] = substr($file, 0, -(strlen($this->php_ext) + 1));
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
|
||||
if ($cache && $this->cache)
|
||||
{
|
||||
$this->cache->put('_hooks', $hook_files);
|
||||
}
|
||||
|
||||
return $hook_files;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue