1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/16752] Add methods for exporting events to rst by script

PHPBB3-16752
This commit is contained in:
Marc Alexander
2021-04-08 20:14:18 +02:00
parent bcc75099ab
commit 1ecc2e042b
4 changed files with 251 additions and 15 deletions

View File

@@ -184,6 +184,28 @@ class php_exporter
return $wiki_page;
}
/**
* Format the PHP events as a rst table
*
* @param string $action
* @return string
*/
public function export_events_for_rst(string $action = ''): string
{
$rst_exporter = new rst_exporter();
$rst_exporter->add_section_header($action === 'diff' ? 'h3' : 'h2', 'PHP Events');
$rst_exporter->set_columns([
'event' => 'Identifier',
'file' => 'Placement',
'arguments' => 'Arguments',
'since' => 'Added in Release',
'description' => 'Explanation',
]);
$rst_exporter->generate_events_table($this->events);
return $rst_exporter->get_rst_output();
}
/**
* @param string $file
* @return int Number of events found in this file
@@ -287,24 +309,32 @@ class php_exporter
array_pop($description_lines);
}
$description = trim(implode('<br/>', $description_lines));
$description = trim(implode('<br>', $description_lines));
sort($arguments);
if (isset($this->events[$this->current_event]))
{
throw new \LogicException("The event '{$this->current_event}' from file "
. "'{$this->current_file}:{$event_line_num}' already exists in file "
. "'{$this->events[$this->current_event]['file']}'", 10);
}
if ($this->events[$this->current_event]['arguments'] != $arguments ||
$this->events[$this->current_event]['since'] != $since)
{
throw new \LogicException("The event '{$this->current_event}' from file "
. "'{$this->current_file}:{$event_line_num}' already exists in file "
. "'{$this->events[$this->current_event]['file']}'", 10);
}
sort($arguments);
$this->events[$this->current_event] = array(
'event' => $this->current_event,
'file' => $this->current_file,
'arguments' => $arguments,
'since' => $since,
'description' => $description,
);
$num_events_found++;
$this->events[$this->current_event]['file'] .= '<br>' . $this->current_file;
}
else
{
$this->events[$this->current_event] = array(
'event' => $this->current_event,
'file' => $this->current_file,
'arguments' => $arguments,
'since' => $since,
'description' => $description,
);
$num_events_found++;
}
}
}
}