Skip to content

Commit

Permalink
Reformat code so that the extension meets phpBB 3.2 coding guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusWME committed Jan 27, 2017
1 parent aee9d17 commit d52616a
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To install the extension you have to do the following steps:

## Requirements
* php 5.3.3 or newer
* phpBB 3.1.*
* phpBB 3.1.* or newer

## External links
[phpBB extension database](https://www.phpbb.com/customise/db/extension/pmnamesuggestions/ "Show extension entry on phpBB.com")
Expand Down
3 changes: 1 addition & 2 deletions pcgf/pmnamesuggestions/acp/pmnamesuggestions_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace pcgf\pmnamesuggestions\acp;

/** @version 1.1.0 */
/** @version 1.1.1 */
class pmnamesuggestions_info
{
/**
Expand All @@ -23,7 +23,6 @@ public function module()
return array(
'filename' => '\pcgf\pmnamesuggestions\acp\pmnamesuggestions_module',
'title' => 'ACP_PCGF_PMNAMESUGGESTIONS',
'version' => '1.1.0',
'modes' => array(
'settings' => array(
'title' => 'ACP_PCGF_PMNAMESUGGESTIONS',
Expand Down
4 changes: 1 addition & 3 deletions pcgf/pmnamesuggestions/acp/pmnamesuggestions_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class pmnamesuggestions_module
* @since 1.1.0
*
* @param int $id The module id
* @param string $mode The mode the module is beeing called with
*
* @return null
* @param string $mode The mode the module is being called with
*/
public function main($id, $mode)
{
Expand Down
4 changes: 2 additions & 2 deletions pcgf/pmnamesuggestions/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "An extension that suggests usernames when selecting a recipient of a private message",
"homepage": "https://github.com/MarkusWME/phpBB---PM-Name-Suggestions",
"version": "1.1.0",
"time": "2016-12-11",
"version": "1.1.1",
"time": "2017-01-27",
"keywords": ["pm", "private message", "recipient", "username", "suggestion"],
"license": "GPL-2.0",
"authors": [
Expand Down
18 changes: 9 additions & 9 deletions pcgf/pmnamesuggestions/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ services:
pcgf.pmnamesuggestions.listener:
class: pcgf\pmnamesuggestions\event\listener
arguments:
- @template
- @controller.helper
- @config
- '@template'
- '@controller.helper'
- '@config'
tags:
- { name: event.listener }
pcgf.pmnamesuggestions.controller:
class: pcgf\pmnamesuggestions\controller\controller
arguments:
- @request
- @dbal.conn
- @auth
- @user
- @config
- %core.root_path%
- '@request'
- '@dbal.conn'
- '@auth'
- '@user'
- '@config'
- '%core.root_path%'
38 changes: 20 additions & 18 deletions pcgf/pmnamesuggestions/controller/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,29 @@

namespace pcgf\pmnamesuggestions\controller;

use Symfony\Component\HttpFoundation\Response;
use phpbb\auth\auth;
use phpbb\config\config;
use phpbb\db\driver\factory;
use phpbb\json_response;
use phpbb\request\request;
use phpbb\user;

/** @version 1.1.0 */
/** @version 1.1.1 */
class controller
{
/** @var \phpbb\request\request $request Request object */
/** @var request $request Request object */
protected $request;

/** @var \phpbb\db\driver\factory $db Database object */
/** @var factory $db Database object */
protected $db;

/** @var \phpbb\auth\auth $auth Authenticator object */
/** @var auth $auth Authenticator object */
protected $auth;

/** @var \phpbb\user $user User object */
/** @var user $user User object */
protected $user;

/** @var \phpbb\config\config $config Configuration object */
/** @var config $config Configuration object */
protected $config;

/** @var string $phpbb_root_path The forum root path */
Expand All @@ -37,16 +42,14 @@ class controller
* @access public
* @since 1.0.0
*
* @param \phpbb\request\request\ $request Request object
* @param \phpbb\db\driver\factory $db Database object
* @param \phpbb\auth\auth $auth Authenticator object
* @param \phpbb\user $user User object
* @param \phpbb\config\config $config Configuration object
* @param string $phpbb_root_path The forum root path
*
* @return \pcgf\pmnamesuggestions\controller\controller The controller object of the extension
* @param request $request Request object
* @param factory $db Database object
* @param auth $auth Authenticator object
* @param user $user User object
* @param config $config Configuration object
* @param string $phpbb_root_path The forum root path
*/
public function __construct(\phpbb\request\request $request, \phpbb\db\driver\factory $db, \phpbb\auth\auth $auth, \phpbb\user $user, \phpbb\config\config $config, $phpbb_root_path)
public function __construct(request $request, factory $db, auth $auth, user $user, config $config, $phpbb_root_path)
{
$this->request = $request;
$this->db = $db;
Expand All @@ -61,11 +64,10 @@ public function __construct(\phpbb\request\request $request, \phpbb\db\driver\fa
*
* @access public
* @since 1.0.0
* @return null
*/
public function getNameSuggestions()
{
$response = new \phpbb\json_response();
$response = new json_response();
$users = array();
// Only allow JSON requests
if ($this->request->is_ajax())
Expand Down
26 changes: 13 additions & 13 deletions pcgf/pmnamesuggestions/event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@

namespace pcgf\pmnamesuggestions\event;

use phpbb\config\config;
use phpbb\controller\helper;
use phpbb\template\template;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/** @version 1.1.0 */
/** @version 1.1.1 */
class listener implements EventSubscriberInterface
{
/** @var \phpbb\template\template $template Template object */
/** @var template $template Template object */
protected $template;

/** @var \phpbb\controller\helper $helper Helper object */
/** @var helper $helper Helper object */
protected $helper;

/** @var \phpbb\config\config $config Configuration object */
/** @var config $config Configuration object */
protected $config;

/**
Expand All @@ -28,13 +31,11 @@ class listener implements EventSubscriberInterface
* @access public
* @since 1.0.0
*
* @param \phpbb\template\template $template Template object
* @param \phpbb\controller\helper $helper Helper object
* @param \phpbb\config\config $config Configuration object
*
* @return \pcgf\pmnamesuggestions\event\listener The listener object of the extension
* @param template $template Template object
* @param helper $helper Helper object
* @param config $config Configuration object
*/
public function __construct(\phpbb\template\template $template, \phpbb\controller\helper $helper, \phpbb\config\config $config)
public function __construct(template $template, helper $helper, config $config)
{
$this->template = $template;
$this->helper = $helper;
Expand All @@ -60,14 +61,13 @@ static public function getSubscribedEvents()
*
* @access public
* @since 1.0.0
* @return null
*/
public function add_pmnamesuggestion_css($event)
public function add_pmnamesuggestion_css()
{
$this->template->assign_vars(array(
'PM_NAME_SUGGESTIONS' => true,
'PCGF_PM_NAME_SUGGESTION_URL' => $this->helper->route('pcgf_pmnamesuggestions_controller'),
'PCGF_PM_NAME_SOGGESTION_IMAGE_SIZE' => $this->config['pcgf_pmnamesuggestions_avatar_image_size'],
'PCGF_PM_NAME_SUGGESTION_IMAGE_SIZE' => $this->config['pcgf_pmnamesuggestions_avatar_image_size'],
));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="pcgf_pmnamesuggestionlist" class="pcgf-hidden"></div>
<script type="text/javascript">
var pcgfPMNameSuggestionURL = '{PCGF_PM_NAME_SUGGESTION_URL}';
var pcgfPMNameSuggestionImageSize = '{PCGF_PM_NAME_SOGGESTION_IMAGE_SIZE}';
var pcgfPMNameSuggestionImageSize = '{PCGF_PM_NAME_SUGGESTION_IMAGE_SIZE}';
</script>
<!-- INCLUDEJS @pcgf_pmnamesuggestions/javascript/namesuggestions.js -->

0 comments on commit d52616a

Please sign in to comment.