src/DcGeneral/Data/Driver.php
public function fetch(ConfigInterface $objConfig)
    {
        $backupLanguage = $this->setLanguage($this->getCurrentLanguage());

        if ($objConfig->getId() !== null) {
            $modelId = $objConfig->getId();
        } else {
            $filter  = $this->prepareFilter($objConfig);
            $ids     = $this->getIdsFromFilter($filter, $objConfig);
            $modelId = reset($ids);
        }

        $objItem = $modelId ? $this->getMetaModel()->findById($modelId, $objConfig->getFields() ?: array()) : null;

        $this->setLanguage($backupLanguage);

        if (!$objItem) {
            return null;
        }

        return new Model($objItem);
    }
public function fetch(ConfigInterface $objConfig)
    {
        $backupLanguage = $this->setLanguage($this->getCurrentLanguage());

        if ($objConfig->getId() !== null) {
            $modelId = $objConfig->getId();
        } else {
            $filter  = $this->prepareFilter($objConfig);
            $ids     = $this->getIdsFromFilter($filter, $objConfig);
            $modelId = reset($ids);
        }

        $objItem = $modelId ? $this->getMetaModel()->findById($modelId, $objConfig->getFields() ?: array()) : null;

        $this->setLanguage($backupLanguage);

        if (!$objItem) {
            return null;
        }

        return new Model($objItem);
    }
public function fetch ( ConfigInterface $ objConfig ) { $ backupLanguage = $ this -> setLanguage ( $ this -> getCurrentLanguage ( ) ) ; if ( $ objConfig -> getId ( ) !== null ) { $ modelId = $ objConfig -> getId ( ) ; } else { $ filter = $ this -> prepareFilter ( $ objConfig ) ; $ ids = $ this -> getIdsFromFilter ( $ filter , $ objConfig ) ; $ modelId = reset ( $ ids ) ; } $ objItem = $ modelId ? $ this -> getMetaModel ( ) -> findById ( $ modelId , $ objConfig -> getFields ( ) ? : array ( ) ) : null ; $ this -> setLanguage ( $ backupLanguage ) ; if ( ! $ objItem ) { return null ; } return new Model ( $ objItem ) ; }
Fetch a single or first record by id or filter.

If the model shall be retrieved by id, use $objConfig->setId() to populate the config with an Id.

If the model shall be retrieved by filter, use $objConfig->setFilter() to populate the config with a filter.

@param ConfigInterface $objConfig The config to use.

@return null|ModelInterface
Fetch a single or first record by id or filter .