Skip to content

Commit

Permalink
coalescing operator
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Dec 26, 2020
1 parent 0c768c0 commit 908d55b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 35 deletions.
11 changes: 4 additions & 7 deletions class/CategoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ class CategoryHandler extends \XoopsPersistableObjectHandler

public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
{
/** @var Helper $this- >helper */
if (null === $helper) {
$this->helper = Helper::getInstance();
} else {
$this->helper = $helper;
}
$publisherIsAdmin = $this->helper->isUserAdmin();
/** @var Helper $this->helper */
$this->helper = $helper ?? Helper::getInstance();
$this->db = $db;
$this->publisherIsAdmin = $this->helper->isUserAdmin();
parent::__construct($db, 'publisher_categories', Category::class, 'categoryid', 'name');
}

Expand Down
11 changes: 4 additions & 7 deletions class/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,16 @@ class FileHandler extends \XoopsPersistableObjectHandler

public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
{
/** @var Helper $this- >helper */
if (null === $helper) {
$this->helper = Helper::getInstance();
} else {
$this->helper = $helper;
}
/** @var Helper $this->helper */
$this->helper = $helper ?? Helper::getInstance();
$this->db = $db;
parent::__construct($db, 'publisher_files', File::class, 'fileid', 'name');
}

/**
* delete a file from the database
*
* @param \XoopsObject $file reference to the file to delete
* @param \XoopsObject|File $file reference to the file to delete
* @param bool $force
*
* @return bool FALSE if failed.
Expand Down
17 changes: 8 additions & 9 deletions class/ItemHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/

use XoopsModules\Publisher;
/** @var Helper $this->helper */
/** @var Item $obj */

require_once \dirname(__DIR__) . '/include/common.php';

Expand All @@ -44,13 +46,8 @@ class ItemHandler extends \XoopsPersistableObjectHandler

public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
{
/** @var Helper $this- >helper */
if (null === $helper) {
$this->helper = Helper::getInstance();
} else {
$this->helper = $helper;
}

$this->helper = $helper ?? Helper::getInstance();
$this->db = $db;
$this->publisherIsAdmin = $this->helper->isUserAdmin();
parent::__construct($db, 'publisher_items', Item::class, 'itemid', 'title');
}
Expand All @@ -62,6 +59,7 @@ public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
*/
public function create($isNew = true)
{
/** @var Item $obj */
$obj = parent::create($isNew);
if ($isNew) {
$obj->setDefaultPermissions();
Expand Down Expand Up @@ -90,6 +88,7 @@ public function get($id = null, $fields = null)
return $obj;
}


/**
* insert a new item in the database
*
Expand Down Expand Up @@ -122,7 +121,7 @@ public function insert(\XoopsObject $item, $force = false) //insert(&$item, $fo
// Storing tags information
/** @var \XoopsModules\Tag\Helper $tagHandler */
$tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); // xoops_getModuleHandler('tag', 'tag');
$tagHandler->updateByItem($item->getVar('item_tag'), $item->getVar('itemid'), PUBLISHER_DIRNAME, 0);
$tagHandler->updateByItem($item->getVar('item_tag'), $item->getVar('itemid'), $this->helper->getDirname(), 0);
}

return true;
Expand Down Expand Up @@ -151,7 +150,7 @@ public function delete(\XoopsObject $item, $force = false)
if (\xoops_isActiveModule('tag')) {
/** @var \XoopsModules\Tag\Helper $tagHandler */
$tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); // xoops_getModuleHandler('tag', 'tag');
$tagHandler->updateByItem('', $item->getVar('itemid'), PUBLISHER_DIRNAME, 0);
$tagHandler->updateByItem('', $item->getVar('itemid'), $this->helper->getDirname(), 0);
}

return true;
Expand Down
8 changes: 2 additions & 6 deletions class/MimetypeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ class MimetypeHandler extends BaseObjectHandler
*/
public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
{
/** @var Helper $this- >helper */
if (null === $helper) {
$this->helper = Helper::getInstance();
} else {
$this->helper = $helper;
}
/** @var Helper $this->helper */
$this->helper = $helper ?? Helper::getInstance();

$this->publisherIsAdmin = $this->helper->isUserAdmin();
$this->db = $db;
Expand Down
8 changes: 2 additions & 6 deletions class/PermissionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author The SmartFactory <www.smartfactory.ca>
*/

/** @var Helper $this- >helper */
/** @var Helper $this->helper */

//require_once \dirname(__DIR__) . '/include/common.php';

Expand All @@ -40,11 +40,7 @@ class PermissionHandler extends \XoopsObjectHandler

public function __construct(\XoopsDatabase $db = null, Helper $helper = null)
{
if (null === $helper) {
$this->helper = Helper::getInstance();
} else {
$this->helper = $helper;
}
$this->helper = $helper ?? Helper::getInstance();
}

/**
Expand Down

0 comments on commit 908d55b

Please sign in to comment.