Skip to content

Commit

Permalink
const refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Dec 27, 2020
1 parent b83f7b2 commit 961c3b5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
8 changes: 7 additions & 1 deletion class/CategoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
*/
class CategoryHandler extends \XoopsPersistableObjectHandler
{
private const TABLE = 'publisher_categories';
private const ENTITY = Category::class;
private const ENTITYNAME = 'Category';
private const KEYNAME = 'categoryid';
private const IDENTIFIER = 'name';

/**
* @var Helper
*/
Expand All @@ -45,7 +51,7 @@ public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
$this->helper = $helper ?? Helper::getInstance();
$this->db = $db;
$this->publisherIsAdmin = $this->helper->isUserAdmin();
parent::__construct($db, 'publisher_categories', Category::class, 'categoryid', 'name');
parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions class/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
*/
class FileHandler extends \XoopsPersistableObjectHandler
{
private const TABLE = 'publisher_files';
private const ENTITY = File::class;
private const ENTITYNAME = 'File';
private const KEYNAME = 'fileid';
private const IDENTIFIER = 'name';

public $table_link = '';
/**
* @var Helper
Expand All @@ -47,9 +53,9 @@ class FileHandler extends \XoopsPersistableObjectHandler
public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
{
/** @var Helper $this->helper */
$this->helper = $helper ?? Helper::getInstance();
$this->helper = $helper ?? Helper::getInstance();
$this->db = $db;
parent::__construct($db, 'publisher_files', File::class, 'fileid', 'name');
parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER);
}

/**
Expand Down
8 changes: 7 additions & 1 deletion class/ItemHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
*/
class ItemHandler extends \XoopsPersistableObjectHandler
{
private const TABLE = 'publisher_items';
private const ENTITY = Item::class;
private const ENTITYNAME = 'Item';
private const KEYNAME = 'itemid';
private const IDENTIFIER = 'title';

/**
* @var Helper
*/
Expand All @@ -48,7 +54,7 @@ public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
$this->helper = $helper ?? Helper::getInstance();
$this->db = $db;
$this->publisherIsAdmin = $this->helper->isUserAdmin();
parent::__construct($db, 'publisher_items', Item::class, 'itemid', 'title');
parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion class/RatingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@
*/
class RatingHandler extends \XoopsPersistableObjectHandler
{
private const TABLE = 'publisher_rating';
private const ENTITY = Rating::class;
private const KEYNAME = 'ratingid';
private const IDENTIFIER = 'itemid';

/**
* RatingHandler constructor.
* @param \XoopsDatabase|null $db
*/
public function __construct(\XoopsDatabase $db = null)
{
$this->db = $db;
parent::__construct($db, 'publisher_rating', Rating::class, 'ratingid', 'itemid');
parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER);
}
}
8 changes: 7 additions & 1 deletion class/RatingsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@
*/
class RatingsHandler extends \XoopsPersistableObjectHandler
{
private const TABLE = 'publisher_liking';
private const ENTITY = Ratings::class;
private const ENTITYNAME = 'Ratings';
private const KEYNAME = 'rate_id';
private const IDENTIFIER = 'rate_itemid';

/**
* Constructor
* @param \XoopsDatabase $db
*/
public function __construct(\XoopsDatabase $db)
{
$this->db = $db;
parent::__construct($db, 'publisher_liking', Ratings::class, 'rate_id', 'rate_itemid');
parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER);
}

/**
Expand Down

0 comments on commit 961c3b5

Please sign in to comment.