src/Controller/CrudController.php
protected function lookUpResource($aData = [], $iSegment = 4)
    {
        $oUri        = Factory::service('Uri');
        $sIdentifier = $oUri->segment($iSegment);

        //  Handle requests for expansions
        $oInput      = Factory::service('Input');
        $aData       = array_merge(static::CONFIG_LOOKUP_DATA, $aData);
        $aExpansions = array_filter((array) $oInput->get('expand'));
        if ($aExpansions) {
            if (!array_key_exists('expand', $aData)) {
                $aData['expand'] = [];
            }

            $aData['expand'] = array_merge($aData['expand'], $aExpansions);
        }

        switch (static::CONFIG_LOOKUP_METHOD) {
            case 'ID':
                return $this->oModel->getById($sIdentifier, $aData);
                break;
            case 'SLUG':
                return $this->oModel->getBySlug($sIdentifier, $aData);
                break;
            case 'TOKEN':
                return $this->oModel->getByToken($sIdentifier, $aData);
                break;
        }
    }
protected function lookUpResource($aData = [], $iSegment = 4)
    {
        $oUri        = Factory::service('Uri');
        $sIdentifier = $oUri->segment($iSegment);

        //  Handle requests for expansions
        $oInput      = Factory::service('Input');
        $aData       = array_merge(static::CONFIG_LOOKUP_DATA, $aData);
        $aExpansions = array_filter((array) $oInput->get('expand'));
        if ($aExpansions) {
            if (!array_key_exists('expand', $aData)) {
                $aData['expand'] = [];
            }

            $aData['expand'] = array_merge($aData['expand'], $aExpansions);
        }

        switch (static::CONFIG_LOOKUP_METHOD) {
            case 'ID':
                return $this->oModel->getById($sIdentifier, $aData);
                break;
            case 'SLUG':
                return $this->oModel->getBySlug($sIdentifier, $aData);
                break;
            case 'TOKEN':
                return $this->oModel->getByToken($sIdentifier, $aData);
                break;
        }
    }
protected function lookUpResource ( $ aData = [ ] , $ iSegment = 4 ) { $ oUri = Factory :: service ( 'Uri' ) ; $ sIdentifier = $ oUri -> segment ( $ iSegment ) ; //  Handle requests for expansions $ oInput = Factory :: service ( 'Input' ) ; $ aData = array_merge ( static :: CONFIG_LOOKUP_DATA , $ aData ) ; $ aExpansions = array_filter ( ( array ) $ oInput -> get ( 'expand' ) ) ; if ( $ aExpansions ) { if ( ! array_key_exists ( 'expand' , $ aData ) ) { $ aData [ 'expand' ] = [ ] ; } $ aData [ 'expand' ] = array_merge ( $ aData [ 'expand' ] , $ aExpansions ) ; } switch ( static :: CONFIG_LOOKUP_METHOD ) { case 'ID' : return $ this -> oModel -> getById ( $ sIdentifier , $ aData ) ; break ; case 'SLUG' : return $ this -> oModel -> getBySlug ( $ sIdentifier , $ aData ) ; break ; case 'TOKEN' : return $ this -> oModel -> getByToken ( $ sIdentifier , $ aData ) ; break ; } }
Fetches an object by it's ID, SLUG, or TOKEN

@param array   $aData    Any data to pass to the lookup
@param integer $iSegment The segment containing the item's ID/Token/Slug

@return \stdClass|false
@throws FactoryException
Fetches an object by it s ID SLUG or TOKEN