XoopsModules25x /
oledrion
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace XoopsModules\Oledrion; |
||||||
| 4 | |||||||
| 5 | /* |
||||||
| 6 | You may not change or alter any portion of this comment or credits |
||||||
| 7 | of supporting developers from this source code or any supporting source code |
||||||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 9 | |||||||
| 10 | This program is distributed in the hope that it will be useful, |
||||||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 13 | */ |
||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * oledrion |
||||||
| 17 | * |
||||||
| 18 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||||
| 19 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||||||
| 20 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||||||
| 21 | */ |
||||||
| 22 | |||||||
| 23 | /** |
||||||
| 24 | * Classe chargée de faire la liaison entre les produits et les fabricants |
||||||
| 25 | */ |
||||||
| 26 | |||||||
| 27 | use XoopsModules\Oledrion; |
||||||
| 28 | |||||||
| 29 | /** |
||||||
| 30 | * Class ProductsmanuHandler |
||||||
| 31 | */ |
||||||
| 32 | class ProductsmanuHandler extends OledrionPersistableObjectHandler |
||||||
| 33 | { |
||||||
| 34 | /** |
||||||
| 35 | * ProductsmanuHandler constructor. |
||||||
| 36 | * @param \XoopsDatabase|null $db |
||||||
| 37 | */ |
||||||
| 38 | public function __construct(\XoopsDatabase $db = null) |
||||||
| 39 | { |
||||||
| 40 | // Table Classe Id |
||||||
| 41 | parent::__construct($db, 'oledrion_productsmanu', Productsmanu::class, 'pm_id'); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 42 | } |
||||||
| 43 | |||||||
| 44 | /** |
||||||
| 45 | * Retourne le nombre de produits associé à un fabricant |
||||||
| 46 | * |
||||||
| 47 | * @param int $pm_manu_id L'identifiant du fabricant |
||||||
| 48 | * @return int Le nombre de fabricants |
||||||
| 49 | */ |
||||||
| 50 | public function getManufacturerProductsCount($pm_manu_id) |
||||||
| 51 | { |
||||||
| 52 | $criteria = new \Criteria('pm_manu_id', $pm_manu_id, '='); |
||||||
| 53 | |||||||
| 54 | return $this->getCount($criteria); |
||||||
| 55 | } |
||||||
| 56 | |||||||
| 57 | /** |
||||||
| 58 | * Retourne des fabricants de produits en fonction de leur IDs |
||||||
| 59 | * |
||||||
| 60 | * @param array $ids Les identifiants des produits |
||||||
| 61 | * @return array Tableau d'objets de type Productsmanu |
||||||
| 62 | */ |
||||||
| 63 | public function getFromProductsIds($ids) |
||||||
| 64 | { |
||||||
| 65 | $ret = []; |
||||||
| 66 | if (is_array($ids)) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 67 | $criteria = new \Criteria('pm_product_id', '(' . implode(',', $ids) . ')', 'IN'); |
||||||
| 68 | $ret = $this->getObjects($criteria, true, true, '*', false); |
||||||
|
0 ignored issues
–
show
The call to
XoopsPersistableObjectHandler::getObjects() has too many arguments starting with '*'.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||||
| 69 | } |
||||||
| 70 | |||||||
| 71 | return $ret; |
||||||
| 72 | } |
||||||
| 73 | |||||||
| 74 | /** |
||||||
| 75 | * Retourne les identifiants des produits d'un fabricant |
||||||
| 76 | * |
||||||
| 77 | * @param int $pm_manu_id L'identifiant du fabricant |
||||||
| 78 | * @param int $start |
||||||
| 79 | * @param int $limit |
||||||
| 80 | * @return array Les ID des produits |
||||||
| 81 | */ |
||||||
| 82 | public function getProductsIdsFromManufacturer($pm_manu_id, $start = 0, $limit = 0) |
||||||
| 83 | { |
||||||
| 84 | $ret = []; |
||||||
| 85 | $criteria = new \Criteria('pm_manu_id', $pm_manu_id, '='); |
||||||
| 86 | $criteria->setStart($start); |
||||||
| 87 | $criteria->setLimit($limit); |
||||||
| 88 | $items = $this->getObjects($criteria, false, false, 'pm_product_id', false); |
||||||
|
0 ignored issues
–
show
The call to
XoopsPersistableObjectHandler::getObjects() has too many arguments starting with 'pm_product_id'.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||||
| 89 | if (count($items) > 0) { |
||||||
| 90 | foreach ($items as $item) { |
||||||
| 91 | $ret[] = $item['pm_product_id']; |
||||||
| 92 | } |
||||||
| 93 | } |
||||||
| 94 | |||||||
| 95 | return $ret; |
||||||
| 96 | } |
||||||
| 97 | |||||||
| 98 | /** |
||||||
| 99 | * Supprime un produit d'un fabricant |
||||||
| 100 | * |
||||||
| 101 | * @param int $pm_product_id |
||||||
| 102 | * @return bool |
||||||
| 103 | */ |
||||||
| 104 | public function removeManufacturerProduct($pm_product_id) |
||||||
| 105 | { |
||||||
| 106 | $pm_product_id = (int)$pm_product_id; |
||||||
| 107 | |||||||
| 108 | return $this->deleteAll(new \Criteria('pm_product_id', $pm_product_id, '=')); |
||||||
| 109 | } |
||||||
| 110 | } |
||||||
| 111 |