mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/13713] Create source interface
PHPBB3-13713
This commit is contained in:
parent
b6e2d1f48c
commit
f6c9f4fb13
4 changed files with 44 additions and 1 deletions
|
@ -32,6 +32,9 @@ class friend extends user
|
|||
parent::__construct($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function query($keyword, $topic_id)
|
||||
{
|
||||
$query = $this->db->sql_build_query('SELECT', [
|
||||
|
|
27
phpbb/phpbb/mention/source/source_interface.php
Normal file
27
phpbb/phpbb/mention/source/source_interface.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?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\mention\source;
|
||||
|
||||
interface source_interface
|
||||
{
|
||||
/**
|
||||
* Searches database for names to mention
|
||||
* and returns and array of found items
|
||||
*
|
||||
* @param string $keyword Search string
|
||||
* @param int $topic_id Current topic ID
|
||||
* @return array Array of names
|
||||
*/
|
||||
public function get($keyword, $topic_id);
|
||||
}
|
|
@ -15,6 +15,9 @@ namespace phpbb\mention\source;
|
|||
|
||||
class topic extends user
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function query($keyword, $topic_id)
|
||||
{
|
||||
$query = $this->db->sql_build_query('SELECT', [
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace phpbb\mention\source;
|
||||
|
||||
abstract class user
|
||||
abstract class user implements source_interface
|
||||
{
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
@ -26,8 +26,18 @@ abstract class user
|
|||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a query based on user input
|
||||
*
|
||||
* @param string $keyword Search string
|
||||
* @param int $topic_id Current topic ID
|
||||
* @return string Query ready for execution
|
||||
*/
|
||||
abstract protected function query($keyword, $topic_id);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($keyword, $topic_id)
|
||||
{
|
||||
$keyword = utf8_clean_string($keyword);
|
||||
|
|
Loading…
Add table
Reference in a new issue