Get First Item by params

@param $params array
@return BItemsItem
321679
public function itemsFilterFirst($params) {
		$params2 = $params;
		$params2['limit'] = 1;
		$list = $this->itemsFilter($params2);
		if (empty($list)) {
			return NULL;
		}
		$item = reset($list);
		return $item;
	}
219586
public function get($params = [])
    {
        $result = $this->connection()->get($this->getEndpoint(), $params);

        return $this->collectionFromResult($result);
    }
638689
public function get(array $params = [])
    {
        $this->getLogger()->info('Getting list of Playlists');
        if (isset($params['embed']))
            $embed = ($params['embed'] != null) ? explode(',', $params['embed']) : [];

        $hydratedWidgets = [];
        $entries = [];

        $response = $this->doGet('/playlist', $params);
        foreach ($response as $item) {
            /** @var XiboPlaylist $playlist */
            $playlist = new XiboPlaylist($this->getEntityProvider());
            $playlist->hydrate($item);
            if (in_array('widgets', $embed) === true) {
                foreach ($playlist->widgets as $widget) {
                    /** @var XiboWidget $widgetObject */
                    $widgetObject = new XiboWidget($this->getEntityProvider());
                    $widgetObject->hydrate($widget);
                    $hydratedWidgets[] = $widgetObject;
                }
                $playlist->widgets = $hydratedWidgets;
            }
            $entries[] = clone $playlist;
        }

        return $entries;
    }
1325351
public function getPaginator($params) 
	{
        $limit = isset($params['limit']) ? (int) $params['limit'] : 10;
        $offset = isset($params['offset']) ? (int) $params['offset'] : 0;
        
        // @todo (re)setting limit and offset, make it better...
        $params['limit'] = $limit;
        $params['offset'] = $offset;
		
		// must check for limit
		//$page = isset($params['page']) ? (int)$params['page'] : 1;
		
		$fields = isset($params['field']) ? array_values($params['field']) : array();
		$values = isset($params['value']) ? array_values($params['value']) : array();
		
		$page = $params['offset'] / $params['limit'] + 1;
		$isLoggedUserSearch = false;
		$isFullSearch = false;
		$userId = '';
		foreach($fields as $key => $field) {
			switch($field) {
				case 'account':
					$isLoggedUserSearch = true;
					$userId = $values[$key];
					break;
			}
		}
		if($isLoggedUserSearch) {
			    //throw new \Exception('WIP hashid');
			$qb = $this->_em->createQueryBuilder();
			$qb->select(array('a'));
			$qb->from($this->getEntityName(), 'a');
			//$qb->andWhere($qb->expr()->eq('a.user', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('SHA1(CONCAT_WS(\'\', \'neo\', a.user, \'bazaar\'))', ':paramUserId'));
			$qb->andWhere($qb->expr()->eq('a.documentType', ':paramDocumentType'));
			$qb->andWhere($qb->expr()->neq('a.state', ':paramDocumentState'));
			$qb->setParameter('paramUserId', $userId);
			$qb->setParameter('paramDocumentType', Document::DOCUMENT_TYPE_CLASSIFIED);
			$qb->setParameter('paramDocumentState', Document::DOCUMENT_STATE_DELETED);
			//$qb->addOrderBy('COALESCE(a.dateEdit, a.dateInsert)', 'DESC');
			//$qb->addOrderBy('a.documentId', 'DESC');
			$qb->addOrderBy('a.dateEdit', 'DESC');
			$query = $qb->getQuery();
			$query->setFirstResult($params['offset']);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
			
			
// 			$paginator = new DoctrinePaginator($query, $fetchJoinCollection = true);
// 			$result = array();
// 			foreach($paginator as $p) {
// 				$result[] = $p->getDocumentId();
// 			}
// 			$result = $query->getResult();
// 			$paginatorAdapter =  new RazorPaginator(
// 				$result,
// 				count($paginator)
// 			);
		} else {
			$query = $this->fetchGridData($params);
			$query->setFirstResult(0);
			$query->setMaxResults($params['limit']);
			$paginatorAdapter =  new RazorArrayAdapter(
				$query->getResult(),
				$this->getSphinxClient()->getLastSearchCount()
			);
			//$paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query));
		}
		
		
		$paginator = new Paginator($paginatorAdapter);
		$paginator->setCurrentPageNumber($page);
		$paginator->setDefaultItemCountPerPage($params['limit']);
		
		return $paginator;
	}
944755
public function deleteItems( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items' ) );
		$this->_setLocale( $params->site );

		$idList = array();
		$ids = (array) $params->items;
		$context = $this->_getContext();
		$manager = $this->_getManager();


		$search = $manager->createSearch();
		$search->setConditions( $search->compare( '==', 'attribute.id', $ids ) );
		$search->setSlice( 0, count( $ids ) );

		foreach( $manager->searchItems( $search ) as $id => $item ) {
			$idList[ $item->getDomain() ][] = $id;
		}

		$manager->deleteItems( $ids );


		foreach( $idList as $domain => $domainIds )
		{
			$manager = MShop_Factory::createManager( $context, $domain . '/list' );

			$search = $manager->createSearch();
			$expr = array(
				$search->compare( '==', $domain.'.list.refid', $domainIds ),
				$search->compare( '==', $domain.'.list.domain', 'attribute' )
			);
			$search->setConditions( $search->combine( '&&', $expr ) );
			$search->setSortations( array( $search->sort( '+', $domain.'.list.id' ) ) );

			$start = 0;

			do
			{
				$result = $manager->searchItems( $search );
				$manager->deleteItems( array_keys( $result ) );

				$count = count( $result );
				$start += $count;
				$search->setSlice( $start );
			}
			while( $count >= $search->getSliceSize() );
		}


		$this->_clearCache( $ids );

		return array(
				'items' => $params->items,
				'success' => true,
		);
	}
1247133
public function queryRow($params = [])
    {
        $this->setLimit(1);
        return $this->getDb()
            ->createCommand()
            ->setText($this->buildSql())
            ->queryRow(array_merge($this->getParams(), $params));
    }
668601
public function request($params)
  {
    $query = array_merge($params, [
      'key' => $this->key
    ]);

    try {

      $response = $this->client->get(self::API_ENDPOINT, [
        'query' => $query
      ]);

    } catch (ClientException $exception) {

      return collect([]);

    }

    $results = json_decode($response->getBody(), true);

    $output = [];

    for($i = 0; $i < count($results['itemListElement']); $i++) {
      $output[] = new SearchResult($results['itemListElement'][$i]);
    }

    return collect($output);
  }
832269
public function setParamsSort(array $params) {
        if (is_numeric(key($params)) && key($params) == 0) {
            $tmp = [];
            foreach ($params as $key => $value) {
                $tmp[$key + 1] = $value;
            }
            $params = $tmp;
        }

        return $params;
    }
707395
public function params($params = null)
    {
        if (null !== $params) {
            $this->params = $params;

            return $this;
        }

        return $this->params;
    }
1198253
public function getTree( \stdClass $params )
	{
		$this->checkParams( $params, array( 'items' ) );

		$manager = $this->getManager();

		$result = [];
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			if( $entry == 'root' )
			{
				$search = $this->manager->createSearch();
				$search->setConditions( $search->compare( '==', 'locale.site.level', 0 ) );

				$item = $this->manager->createItem();
				$item->setLabel( 'Root' );

				foreach( $this->manager->searchItems( $search ) as $siteItem ) {
					$item->addChild( $siteItem );
				}
			}
			else
			{
				$item = $manager->getTree( $entry, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST );
			}

			$result[] = $this->createNodeArray( $item );
		}

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $result ) : $result ),
			'success' => true,
		);
	}
729009
public function withDictParams($params)
    {
        foreach ($params as $key => $value) {
            $this->withParam($key, $value);
        }

        return $this;
    }
431657
public function searchItems( stdClass $params )
	{
		$total = 0;
		$search = $this->_initCriteria( $this->_getManager()->createSearch(), $params );

		$sort = $search->getSortations();
		$sort[] = $search->sort( '+', 'locale.currency.label' );
		$search->setSortations( $sort );

		$items = $this->_getManager()->searchItems( $search, array(), $total );

		return array(
			'items' => $this->_toArray( $items ),
			'total' => $total,
			'success' => true,
		);
	}
341591
public function getAliases($params = [])
    {
        return $this->getClient()->indices()->getAliases(array_merge(['index' => $this->getIndexName()], $params));
    }
838347
public function get($params = null)
    {
        $curlHandle = $this->prepareGet($params);
        return $this->curlGetResponse($curlHandle);
    }
708897
public function fetchAll($params = [])
    {
        return $this->table->select(
            function (Select $select) {
                $select->columns([]);
                $select->join(
                    $this->roleTableName,
                    sprintf('%s.role_id=%s.role_id', $this->roleTableName, $this->table->getTable())
                );
                $select->where(['user_id' => $this->getUserId()]);
            }
        );

//        $adapter = new DbSelect($select, $this->table->getAdapter());
//        return new $this->collectionClass($adapter);
    }
221137
public function get(array $params = [])
    {
        $this->getLogger()->info('Getting list of layouts ');
        $entries = [];
        $hydratedRegions = [];
        $hydratedWidgets = [];
        $response = $this->doGet($this->url, $params);
        if (isset($params['embed']))
            $embed = ($params['embed'] != null) ? explode(',', $params['embed']) : [];

        foreach ($response as $item) {
            /** @var XiboLayout $layout */
            $layout = new XiboLayout($this->getEntityProvider());
            $layout->hydrate($item);
            foreach ($layout->regions as $reg) {
                /** @var XiboRegion $region */
                $region = new XiboRegion($this->getEntityProvider());
                $region->hydrate($reg);
                if (in_array('playlists', $embed) === true) {
                    /** @var XiboPlaylist $playlist */
                    $playlist = new XiboPlaylist($this->getEntityProvider());
                    $playlist->hydrate($reg['regionPlaylist']);
                    foreach ($playlist->widgets as $widget) {
                        /** @var XiboWidget $widgetObject */
                        $widgetObject = new XiboWidget($this->getEntityProvider());
                        $widgetObject->hydrate($widget);
                        $hydratedWidgets[] = $widgetObject;
                    }
                    $playlist->widgets = $hydratedWidgets;
                    $region->regionPlaylist = $playlist;
                }
                // Add to parent object
                $hydratedRegions[] = $region;
            }
            $layout->regions = $hydratedRegions;

            $entries[] = clone $layout;
        }

        return $entries;
    }
507998
public function getRows(array $params = [])
    {
        $query = $this->createQueryBuilder('pc');

        if (array_key_exists('idPlayer', $params)) {
            $query->where('pc.idPlayer= :idPlayer')
                ->setParameter('idPlayer', $params['idPlayer']);
        }

        if (array_key_exists('limit', $params)) {
            $query->setMaxResults($params['limit']);
        }

        if (array_key_exists('orderBy', $params)) {
            $query->orderBy($params['orderBy']['column'], $params['orderBy']['order']);
        }

        return $query->getQuery()->getResult();
    }