Skip to content

Commit

Permalink
Report workaround fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Nov 29, 2023
1 parent cd63b37 commit 7f012cc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/AbraFlexi/Report.php
Expand Up @@ -6,7 +6,7 @@
* AbraFlexi - Custom Report object.
*
* @author Vítězslav Dvořák <vitex@arachne.cz>
* @copyright (C) 2020 Spoje.Net
* @copyright (C) 2020-2023 Spoje.Net
*/

namespace AbraFlexi;
Expand Down Expand Up @@ -36,12 +36,15 @@ class Report extends RW
*/
public function loadFromAbraFlexi($id = null)
{
if (strstr($id, 'code:')) { //Dirty Hack ⚠ Error 400: Entita 'Report' neobsahuje kód nebo ho nelze použít jako ID (není unikátní)
$candidates = $this->getColumnsFromAbraFlexi(['id', 'kod'], null, 'kod');
if (array_key_exists(\AbraFlexi\RO::uncode($id), $candidates)) {
if (is_string($id) && strstr($id, 'code:')) { //Dirty Hack ⚠ Error 400: Entita 'Report' neobsahuje kód nebo ho nelze použít jako ID (není unikátní)
$kod = \AbraFlexi\RO::uncode($id);
$candidates = $this->getColumnsFromAbraFlexi(['id', 'kod'], ['kod' => $kod], 'kod');
if (array_key_exists($kod, $candidates)) {
$id = intval($candidates[\AbraFlexi\RO::uncode($id)]['id']);
} else {
$this->lastResponseCode = 404;
}
}
return parent::loadFromAbraFlexi($id);
return is_numeric($id) ? parent::loadFromAbraFlexi($id) : 0;
}
}

0 comments on commit 7f012cc

Please sign in to comment.