1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-31 11:39:37 +02:00
php-phpbb/phpBB/phpbb/search/search_backend_factory.php
rubencm 6ae68baa2e [ticket/15540] Code changes
PHPBB3-15540
2021-03-23 22:23:10 +01:00

66 lines
1.2 KiB
PHP

<?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\search;
use phpbb\config\config;
use phpbb\di\service_collection;
use phpbb\search\backend\search_backend_interface;
class search_backend_factory
{
/**
* @var config
*/
protected $config;
/**
* @var service_collection
*/
protected $search_backends;
/**
* Constructor
*
* @param config $config
* @param service_collection $search_backends
*/
public function __construct(config $config, service_collection $search_backends)
{
$this->config = $config;
$this->search_backends = $search_backends;
}
/**
* Obtains a specified search backend
*
* @param string $class
*
* @return search_backend_interface
*/
public function get(string $class): search_backend_interface
{
return $this->search_backends->get_by_class($class);
}
/**
* Obtains active search backend
*
* @return search_backend_interface
*/
public function get_active(): search_backend_interface
{
return $this->get($this->config['search_type']);
}
}