Gets a single object

@param type $callerClass
@param type $filter
@param type $cache
@param type $orderby
@return DataObject
653
public function getOne($callerClass, $filter = "", $cache = true, $orderby = "", $requiredPerm = 'View')
    {
        $items = $this->getAll($callerClass, $filter, $orderby, null, null, $requiredPerm);
        if ($items && count($items)) {
            return $items[0];
        }
    }
497317
public static function fromArray(array $data, $filter = false){
        $class = get_called_class();
        $object = new static();
        foreach($data as $key => $value){
            if(!$filter || property_exists($class, $key)){
                $object->$key = $value;
            }
        }
        return $object;
    }
315867
public function getActiveRecordObjects($class, $orderBy=NULL, $descOrder=FALSE) {

		if (!class_exists($class) or !is_subclass_of($class, 'Pair\ActiveRecord')) {
			return array();
		}
		
		// sets pagination count
		$this->db->setQuery('SELECT COUNT(*) FROM `' . $class::TABLE_NAME . '`');
		$this->pagination->count = $this->db->loadCount();
	
		$orderDir = $descOrder ? 'DESC' : 'ASC';
		
		$query =
			'SELECT *' .
			' FROM `' . $class::TABLE_NAME . '`' .
			($orderBy ? ' ORDER BY `' . $orderBy . '` ' . $orderDir : NULL) .
			' LIMIT ' . $this->pagination->start . ', ' . $this->pagination->limit;
	
		$this->db->setQuery($query);
		$list = $this->db->loadObjectList();
	
		$objects = array();
	
		foreach ($list as $item) {
			$objects[] = new $class($item);
		}

		return $objects;
	
	}
425292
public function filter($filter): ArrayObjectInterface
    {
        return \is_callable($filter, true) ? $this->filterCallback($filter) : $this->filterConditions($filter);
    }
908647
protected function getLoadVariantsQuery($blRemoveNotOrderables, $forceCoreTableUsage, $baseObject, $sArticleTable)
    {
        return "select " . $baseObject->getSelectFields($forceCoreTableUsage) . " from $sArticleTable where " .
                 $this->getActiveCheckQuery($forceCoreTableUsage) .
                 $this->getVariantsQuery($blRemoveNotOrderables, $forceCoreTableUsage) .
                 " order by $sArticleTable.oxsort";
    }
1350041
public function getOrder()
    {
        if ($this->oxorderarticles__oxorderid->value) {
            // checking if the object already exists in the cache
            if (isset($this->_aOrderCache[$this->oxorderarticles__oxorderid->value])) {
                // returning the cached object
                return $this->_aOrderCache[$this->oxorderarticles__oxorderid->value];
            }
            // creatina new order object and trying to load it
            $oOrder = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
            if ($oOrder->load($this->oxorderarticles__oxorderid->value)) {
                return $this->_aOrderCache[$this->oxorderarticles__oxorderid->value] = $oOrder;
            }
        }

        return null;
    }
676672
public function selectAllC($table, $where, $orderBy = null)
    {
        $this->cacheNext = true;

        return $this->selectAll($table, $where, $orderBy);
    }
434665
public static function get($id, $cache = true) {
        if (!$id) {
            return null;
        }
        $model = get_called_class();
        $db_cache = null;
        if ($cache) {
            /* @var $db_cache DBCache */
            $db_cache = Ioc::get(DBCache::class);
            $data = $db_cache->recordCache($model, $id);
            if ($data) {
                return $data;
            }
        }
        /* @var $model Record */
        $model = new $model;
        $pk = $model->getPkField();
        $where[ $pk ] = $id;
        $data = $model::find($where);
        if ($cache && $data) {
            $db_cache->recordCacheSave(get_called_class(), $id, $data->_db_data);
        }
        return $data;
    }
573359
public function getBatchObjects($class, ProxyQueryInterface $queryProxy)
    {
        $queryProxy->select('DISTINCT '.$queryProxy->getRootAlias());

        return $queryProxy->getQuery()->execute();
    }
700778
public function getFirstRecord($filter = '', $order = ['.id'], $page = 1, $count = null, $dataDimensions = null)
    {
        $records = $this->getRecords($filter, $order, $page, $count, $dataDimensions);
        if ($records) {
            return array_shift($records);
        }

        return false;
    }
1321169
public function findBy(FamilyInterface $family, array $filterBy, array $orderBy = [])
    {
        $qb = $this->getQb($family, $filterBy, $orderBy);
        $results = $qb->getQuery()->getResult();
        $this->dataLoader->load($results);

        return $results;
    }
716724
public function getRecords($filter = '', $order = ['.id'], $page = 1, $count = null, $dataDimensions = null)
    {
        if ($dataDimensions == null) {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        if (!is_array($order))
        {
            $order = [$order];
        }

        if ($this->readConnection instanceof FilteringConnection) {
            $records = $this->readConnection->getRecords($this->getCurrentContentTypeName(), $dataDimensions, $filter,
                $page, $count, $order);
        } else {

            $records = $this->getAllRecords($dataDimensions);

            if ($filter != '') {
                $records = RecordsFilter::filterRecords($records, $filter);
            }

            $records = RecordsSorter::orderRecords($records, $order);

            if ($count != null) {
                $records = RecordsPager::sliceRecords($records, $page, $count);
            }
        }

        foreach ($records as $record) {
            $record->setRepository($this);
        }

        return $records;
    }
65398
private ObjectCache getCachePerClass(Class objectClass, int methodCall)
    {
        ObjectCache cache = (ObjectCache) cachesByClass.get(objectClass.getName());
        if (cache == null && AbstractMetaCache.METHOD_CACHE == methodCall
                && !cachesByClass.containsKey(objectClass.getName()))
        {
            cache = new ObjectCacheDefaultImpl(null, null);
            setClassCache(objectClass.getName(), cache);
        }
        return cache;
    }
1270891
public function getCachingDependency($parentObject)
    {
        //$primaryModel = $this->primaryModel;
        //$alias = $primaryModel::tableName();
        $baseQuery = $this->getBaseStatsQuery($parentObject);
        $baseQuery->select(['innerQuery.modified']);
        $baseQuery->addOrderBy(['innerQuery.modified' => SORT_DESC]);
        $baseQuery->limit(1);
        $cacheSql = $baseQuery->createCommand()->rawSql;

        return new DbDependency(['sql' => $cacheSql]);
    }
721344
final public static function getInstance($calledClass = null)
    {
        $calledClass = $calledClass ?: get_called_class();

        if (!isset(self::$instances[ $calledClass ])) {
            self::$instances[ $calledClass ] = new $calledClass();
        }

        return self::$instances[ $calledClass ];
    }
1067947
public function get($id, array $data, $className, callable $findOneCallable, callable $update)
    {
        try {
            DataObject::assertPut($data, $this->serializer, $className, $this->errorBag);

            $model = $findOneCallable();

            if (empty($model)) {
                $mapping = $this->serializer->getTransformer()->getMappingByClassName($className);

                return $this->resourceNotFound(new ErrorBag([new NotFoundError($mapping->getClassAlias(), $id)]));
            }
            $values = DataObject::getAttributes($data, $this->serializer);
            $update($model, $data, $values, $this->errorBag);

            $response = $this->resourceUpdated($this->serializer->serialize($model));
        } catch (Exception $e) {
            $response = $this->getErrorResponse($e);
        }

        return $response;
    }
879876
public function getByCallable($callable)
    {
        if(!is_array($callable))
        {
            return null;
        }
        list($object, $methodName) = $callable;
        if($object instanceof IBean)
        {
            $className = get_parent_class($object);
        }
        else
        {
            $className = get_class($object);
        }
        $shortClassName = Imi::getClassShortName($className);
        
        $isClassView = false;
        $view = AnnotationManager::getMethodAnnotations($className, $methodName, View::class)[0] ?? null;
        if(null === $view)
        {
            $view = AnnotationManager::getClassAnnotations($className, View::class)[0] ?? null;
            if(null === $view)
            {
                $view = new View([
                    'template' => File::path($shortClassName, $methodName),
                ]);
            }
            else
            {
                $isClassView = true;
            }
        }

        // baseDir
        if(null === $view->baseDir && !$isClassView)
        {
            $classView = AnnotationManager::getClassAnnotations($className, View::class)[0] ?? null;
            if($classView)
            {
                $view->baseDir = $classView->baseDir;
            }
        }
        return $view;
    }