From b4748a5d1ee31084da7e78f8ffaf5b036f2e5314 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 Dec 2016 01:28:51 -0800 Subject: [ticket/14925] Set reparser names in service definitions PHPBB3-14925 --- phpBB/phpbb/textreparser/base.php | 27 ++++++++++++++++++++++++- phpBB/phpbb/textreparser/manager.php | 20 ++++++++++++++++++ phpBB/phpbb/textreparser/reparser_interface.php | 14 +++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/textreparser') diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php index afa5ccacad..ef97bc90d5 100644 --- a/phpBB/phpbb/textreparser/base.php +++ b/phpBB/phpbb/textreparser/base.php @@ -15,6 +15,11 @@ namespace phpbb\textreparser; abstract class base implements reparser_interface { + /** + * @var string The reparser name + */ + protected $name; + /** * @var bool Whether to save changes to the database */ @@ -89,6 +94,26 @@ abstract class base implements reparser_interface return $record; } + /** + * Returns the name of the reparser + * + * @return string Name of reparser + */ + public function get_name() + { + return $this->name; + } + + /** + * Sets the name of the reparser + * + * @param string $name The reparser name + */ + public function set_name($name) + { + $this->name = $name; + } + /** * Disable saving changes to the database */ @@ -231,7 +256,7 @@ abstract class base implements reparser_interface $unparsed['enable_flash_bbcode'], $unparsed['enable_quote_bbcode'], $unparsed['enable_url_bbcode'], - 'reparse' + $this->get_name() ); // Save the new text if it has changed and it's not a dry run diff --git a/phpBB/phpbb/textreparser/manager.php b/phpBB/phpbb/textreparser/manager.php index fddd867923..7ca65d708d 100644 --- a/phpBB/phpbb/textreparser/manager.php +++ b/phpBB/phpbb/textreparser/manager.php @@ -125,4 +125,24 @@ class manager $this->schedule($reparser, $interval); } } + + /** + * Finds a reparser by name. + * + * If there is no reparser with the specified name, null is returned. + * + * @param string $name Name of the reparser to look up. + * @return string A reparser service name, or null. + */ + public function find_reparser($name) + { + foreach ($this->reparsers as $service => $reparser) + { + if ($reparser->get_name() == $name) + { + return $service; + } + } + return null; + } } diff --git a/phpBB/phpbb/textreparser/reparser_interface.php b/phpBB/phpbb/textreparser/reparser_interface.php index 9ea1732870..912de10058 100644 --- a/phpBB/phpbb/textreparser/reparser_interface.php +++ b/phpBB/phpbb/textreparser/reparser_interface.php @@ -22,6 +22,20 @@ interface reparser_interface */ public function get_max_id(); + /** + * Returns the name of the reparser + * + * @return string Name of reparser + */ + public function get_name(); + + /** + * Sets the name of the reparser + * + * @param string $name The reparser name + */ + public function set_name($name); + /** * Reparse all records in given range * -- cgit v1.2.1 From 76e9f4dd2d45e8f128e59e1378dfd6778eec9d48 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 Dec 2016 09:12:26 -0800 Subject: [ticket/14925] Prefix modes from reparser with text_reparser PHPBB3-14925 --- phpBB/phpbb/textreparser/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/textreparser') diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php index ef97bc90d5..27d7bc1f27 100644 --- a/phpBB/phpbb/textreparser/base.php +++ b/phpBB/phpbb/textreparser/base.php @@ -256,7 +256,7 @@ abstract class base implements reparser_interface $unparsed['enable_flash_bbcode'], $unparsed['enable_quote_bbcode'], $unparsed['enable_url_bbcode'], - $this->get_name() + 'text_reparser.' . $this->get_name() ); // Save the new text if it has changed and it's not a dry run -- cgit v1.2.1