Skip to content

Commit

Permalink
Use class aliases and constants instead of parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
iMattPro committed Oct 13, 2015
1 parent e726c3d commit 0691220
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 195 deletions.
4 changes: 0 additions & 4 deletions config/parameters.yml

This file was deleted.

12 changes: 0 additions & 12 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
imports:
- { resource: parameters.yml }

services:
vse.abbc3.bbcodes_parser:
class: vse\abbc3\core\bbcodes_parser
arguments:
- @user
- %vse.abbc3.bbvideo_default_width%
- %vse.abbc3.bbvideo_default_height%

vse.abbc3.bbcodes_display:
class: vse\abbc3\core\bbcodes_display
Expand All @@ -16,7 +11,6 @@ services:
- @ext.manager
- @user
- %core.root_path%
- %vse.abbc3.ext_root_path%

vse.abbc3.acp_manager:
class: vse\abbc3\core\acp_manager
Expand All @@ -36,9 +30,6 @@ services:
- @template
- @user
- %core.root_path%
- %vse.abbc3.ext_root_path%
- %vse.abbc3.bbvideo_default_width%
- %vse.abbc3.bbvideo_default_height%
tags:
- { name: event.listener }

Expand All @@ -58,6 +49,3 @@ services:
- @template
- @user
- %core.root_path%
- %vse.abbc3.ext_root_path%
- %vse.abbc3.bbvideo_default_width%
- %vse.abbc3.bbvideo_default_height%
69 changes: 30 additions & 39 deletions controller/wizard.php
Original file line number Diff line number Diff line change
@@ -1,70 +1,61 @@
<?php
/**
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace vse\abbc3\controller;

use phpbb\controller\helper;
use phpbb\request\request;
use phpbb\template\template;
use phpbb\user;
use vse\abbc3\ext;

/**
* ABBC3 BBCode Wizard class
*/
* ABBC3 BBCode Wizard class
*/
class wizard
{
/** @var string The default BBvideo site */
const BBVIDEO_DEFAULT = 'youtube.com';

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

/** @var \phpbb\request\request */
/** @var request */
protected $request;

/** @var \phpbb\template\template */
/** @var template */
protected $template;

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

/** @var string */
protected $root_path;

/** @var string */
protected $ext_root_path;

/** @var string */
protected $bbvideo_width;

/** @var string */
protected $bbvideo_height;

/**
* Constructor
*
* @param \phpbb\controller\helper $helper Controller helper object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param string $root_path phpBB root path
* @param string $ext_root_path Extension root path
* @param string $bbvideo_width Default width of bbvideo
* @param string $bbvideo_height Default height of bbvideo
* @param helper $helper Controller helper object
* @param request $request Request object
* @param template $template Template object
* @param user $user User object
* @param string $root_path phpBB root path
* @access public
*/
public function __construct(\phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, $root_path, $ext_root_path, $bbvideo_width, $bbvideo_height)
public function __construct(helper $helper, request $request, template $template, user $user, $root_path)
{
$this->helper = $helper;
$this->request = $request;
$this->template = $template;
$this->user = $user;
$this->root_path = $root_path;
$this->ext_root_path = $ext_root_path;
$this->bbvideo_width = $bbvideo_width;
$this->bbvideo_height = $bbvideo_height;
}

/**
Expand Down Expand Up @@ -132,15 +123,15 @@ protected function generate_bbvideo_wizard()
foreach ($bbvideo_size_presets_array as $preset)
{
$this->template->assign_block_vars('bbvideo_sizes', array(
'VALUE' => $preset,
'LABEL' => str_replace(',', ' ' . $this->user->lang('ABBC3_BBVIDEO_SEPARATOR') . ' ', $preset),
'VALUE' => $preset,
'LABEL' => str_replace(',', ' ' . $this->user->lang('ABBC3_BBVIDEO_SEPARATOR') . ' ', $preset),
));
}

$this->template->assign_vars(array(
'ABBC3_BBVIDEO_LINK_EX' => (isset($bbvideo_sites_array[self::BBVIDEO_DEFAULT])) ? $bbvideo_sites_array[self::BBVIDEO_DEFAULT] : '',
'ABBC3_BBVIDEO_HEIGHT' => $this->bbvideo_height,
'ABBC3_BBVIDEO_WIDTH' => $this->bbvideo_width,
'ABBC3_BBVIDEO_HEIGHT' => ext::BBVIDEO_HEIGHT,
'ABBC3_BBVIDEO_WIDTH' => ext::BBVIDEO_WIDTH,
));
}

Expand All @@ -154,7 +145,7 @@ protected function generate_bbvideo_wizard()
*/
protected function load_json_data($json_file)
{
$json_file = $this->root_path . $this->ext_root_path . 'assets/' . $json_file;
$json_file = $this->root_path . ext::ABBC3_ROOT_PATH . 'assets/' . $json_file;

if (!file_exists($json_file))
{
Expand Down
40 changes: 22 additions & 18 deletions core/acp_manager.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<?php
/**
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace vse\abbc3\core;

use phpbb\db\driver\driver_interface;
use phpbb\request\request;
use phpbb\user;

/**
* ABBC3 ACP manager class
*/
* ABBC3 ACP manager class
*/
class acp_manager
{
/** @var \phpbb\db\driver\driver_interface */
/** @var driver_interface */
protected $db;

/** @var \phpbb\request\request */
/** @var request */
protected $request;

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

/** @var string */
Expand All @@ -33,14 +37,14 @@ class acp_manager
/**
* Constructor
*
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\request\request $request
* @param \phpbb\user $user
* @param string $phpbb_root_path
* @param string $php_ext
* @param driver_interface $db
* @param request $request
* @param user $user
* @param string $phpbb_root_path
* @param string $php_ext
* @access public
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\request\request $request, \phpbb\user $user, $phpbb_root_path, $php_ext)
public function __construct(driver_interface $db, request $request, user $user, $phpbb_root_path, $php_ext)
{
$this->db = $db;
$this->request = $request;
Expand Down
46 changes: 23 additions & 23 deletions core/bbcodes_display.php
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
<?php
/**
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace vse\abbc3\core;

use phpbb\db\driver\driver_interface;
use phpbb\extension\manager;
use phpbb\user;
use vse\abbc3\ext;

/**
* ABBC3 core BBCodes display class
*/
* ABBC3 core BBCodes display class
*/
class bbcodes_display
{
/** @var \phpbb\db\driver\driver_interface */
/** @var driver_interface */
protected $db;

/** @var \phpbb\extension\manager */
/** @var manager */
protected $extension_manager;

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

/** @var string */
protected $root_path;

/** @var string */
protected $ext_root_path;

/** @var array */
protected $memberships;

/**
* Constructor
*
* @param \phpbb\db\driver\driver_interface $db Database connection
* @param \phpbb\extension\manager $extension_manager Extension manager object
* @param \phpbb\user $user User object
* @param string $root_path phpBB root path
* @param string $ext_root_path Extension root path
* @param driver_interface $db Database connection
* @param manager $extension_manager Extension manager object
* @param user $user User object
* @param string $root_path phpBB root path
* @access public
*/
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\extension\manager $extension_manager, \phpbb\user $user, $root_path, $ext_root_path)
public function __construct(driver_interface $db, manager $extension_manager, user $user, $root_path)
{
$this->db = $db;
$this->extension_manager = $extension_manager;
$this->user = $user;
$this->root_path = $root_path;
$this->ext_root_path = $ext_root_path;
}

/**
Expand Down Expand Up @@ -140,7 +140,7 @@ protected function get_images()
return $finder
->extension_suffix('.gif')
->extension_directory('/images/icons')
->find_from_extension('abbc3', $this->root_path . $this->ext_root_path);
->find_from_extension('abbc3', $this->root_path . ext::ABBC3_ROOT_PATH);
}

/**
Expand Down
41 changes: 18 additions & 23 deletions core/bbcodes_parser.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
<?php
/**
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
*
* Advanced BBCode Box
*
* @copyright (c) 2013 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace vse\abbc3\core;

use phpbb\user;
use vse\abbc3\ext;

/**
* ABBC3 core BBCodes parser class
*/
* ABBC3 core BBCodes parser class
*/
class bbcodes_parser
{
/** @var \phpbb\user */
/** @var user */
protected $user;

/** @var string */
protected $bbvideo_width;

/** @var string */
protected $bbvideo_height;

/**
* Constructor
*
* @param \phpbb\user $user User object
* @param string $bbvideo_width Default width of bbvideo
* @param string $bbvideo_height Default height of bbvideo
* @param user $user User object
* @access public
*/
public function __construct(\phpbb\user $user, $bbvideo_width, $bbvideo_height)
public function __construct(user $user)
{
$this->user = $user;
$this->bbvideo_width = $bbvideo_width;
$this->bbvideo_height = $bbvideo_height;
}

/**
Expand Down Expand Up @@ -79,7 +72,9 @@ public function post_parse_bbcodes($text)
*/
protected function bbvideo_pass($matches)
{
return (!empty($matches[2])) ? "[bbvideo=$matches[2]:$matches[3]]$matches[4][/bbvideo:$matches[3]]" : "[bbvideo={$this->bbvideo_width},{$this->bbvideo_height}:$matches[3]]$matches[4][/bbvideo:$matches[3]]";
return (!empty($matches[2])) ?
"[bbvideo=$matches[2]:$matches[3]]$matches[4][/bbvideo:$matches[3]]" :
'[bbvideo=' . ext::BBVIDEO_WIDTH . ',' . ext::BBVIDEO_HEIGHT . ":$matches[3]]$matches[4][/bbvideo:$matches[3]]";
}

/**
Expand Down
Loading

0 comments on commit 0691220

Please sign in to comment.