src/Controller/DefaultController.php
protected function getItem(array $aData = [], int $iSegment = null, bool $bIncludeDeleted = false, bool $b404 = true)
    {
        $iSegment = $iSegment ?? 5;
        $oUri     = Factory::service('Uri');
        $oModel   = $this->getModel();
        $iItemId  = (int) $oUri->segment($iSegment);

        if (classUses($oModel, Localised::class) && $oUri->segment($iSegment + 1)) {
            $aData['USE_LOCALE'] = $oUri->segment($iSegment + 1);
        }

        if (!array_key_exists('where', $aData)) {
            $aData['where'] = [];
        }

        $aData['where'][] = ['id', $iItemId];

        $aItems = $oModel->getAll(
            null,
            null,
            $aData,
            $bIncludeDeleted
        );

        $oItem = reset($aItems);

        if ($b404 && empty($oItem)) {
            show404();
        }

        return $oItem;
    }
protected function getItem(array $aData = [], int $iSegment = null, bool $bIncludeDeleted = false, bool $b404 = true)
    {
        $iSegment = $iSegment ?? 5;
        $oUri     = Factory::service('Uri');
        $oModel   = $this->getModel();
        $iItemId  = (int) $oUri->segment($iSegment);

        if (classUses($oModel, Localised::class) && $oUri->segment($iSegment + 1)) {
            $aData['USE_LOCALE'] = $oUri->segment($iSegment + 1);
        }

        if (!array_key_exists('where', $aData)) {
            $aData['where'] = [];
        }

        $aData['where'][] = ['id', $iItemId];

        $aItems = $oModel->getAll(
            null,
            null,
            $aData,
            $bIncludeDeleted
        );

        $oItem = reset($aItems);

        if ($b404 && empty($oItem)) {
            show404();
        }

        return $oItem;
    }
Returns the item being requested, thorwing a 404 if it's not found

@param array   $aData    Data to pass to the getById method
@param integer $iSegment The URL segment contianing the ID

@return mixed
@throws FactoryException