Finds files from within the media library based on supplied criteria,
returns an array of MediaLibraryItem objects.
@param string $searchTerm
@param string $filter
@param string $sortBy
@param array[System\Classes\MediaLibraryItem]
193668
protected function findFiles($searchTerm, $filter, $sortBy)
    {
        $filter = $filter !== self::FILTER_EVERYTHING ? $filter : null;

        return MediaLibrary::instance()->findFiles($searchTerm, $sortBy, $filter);
    }
42693
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        return $this->contentRepository->findBy($criteria, $orderBy, $limit, $offset);
    }
341298
public function &getCustomRoleRefs( $filter = array(), $sort = true )
	{
		// Make sure the filter is initialized and contains lowercase values
		if ( ! is_array( $filter ) ) $filter = array();
		$filter = array_flip( array_map( 'strtolower', $filter ) );

		$refs = $this->customRoles;

		/**
		 * @var array $result
		 */
		$result = array();

		foreach ( $refs as $refKey => $ref )
		{
			// Apply the filter if one is provided
			if ( count( $filter ) && ! isset( $filter[ strtolower( $refKey ) ] ) ) continue;

			$result[ $refKey ] = $this->customRoles[ $refKey ];

			$linkElement = null;

			// Look for the corresponding link element
			foreach ( $this->roleTypes as $link => $role )
			{
				if ( ! isset( $role[ $refKey ] ) )
				{
					continue;
				}

				$linkElement = $link;
				break;
			}

			if ( is_null( $linkElement ) )
			{
				continue;
			}

			$description = $this->getCustomLinkRoleDescription( $ref, $linkElement, "Custom link role" );
			$result[ $refKey ]['text'] = $description ? $description : "";

			// Remove any prohibited arcs
			if ( isset( $result[ $refKey ]['arcs'] ) && count( $result[ $refKey ]['arcs'] ) )
			{
				$arcs =& $result[ $refKey ]['arcs'];
				foreach ( $arcs as $from => $targets )
				{
					foreach ( $targets as $to => $node )
					{
						if ( $node['use'] == XBRL_Constants::$xlinkUseOptional ) continue;
						unset( $arcs[ $from ][ $to ] );
					}

					if ( count( $arcs[ $from ] ) ) continue;
					unset( $arcs[ $from ] );
				}
			}
		}

		if ( $sort )
		{
			$this->sortRoleRefs( $result );
		}

		return $result;
	}
682464
public function search(SearchCondition\SearchConditionInterface $filter, SelectOrder\SelectOrderInterface $order = null)
	{
		$qb = $this->createSearchQueryBuilder($filter, $order);

		$result = $qb->getQuery()
				->getResult();
		
		return $result;
	}
333220
public function findByFilter(Filter $filter, $limit = null, $offset = 0, $order = null)
    {
        return $this->findByCriteria($filter->getCriteria(), $limit, $offset, $order);
    }
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;
    }
42949
public function listFiles($regexFilter = null)
    {
        $filesList = [];
        if ($regexFilter) {
            $filter = function ($file) use (&$filesList, $regexFilter) {
                // push/pop an error handler here to to make sure no error/exception thrown if $expected is not a regex
                set_error_handler(function () {
                });
                $match = preg_match($regexFilter, $file);
                restore_error_handler();

                if ($match === 1) {
                    $filesList[] = $file;
                } elseif ($match === false) {
                    throw new \RuntimeException("regular expression match on '$file' failed with error. Please check if pattern is valid regular expression.");
                }
            };
        } else {
            $filter = function ($file) use (&$filesList) {
                $filesList[] = $file;
            };
        }
        $this->repository->each($filter);

        return $filesList;
    }
146265
public function sortByKeyFilter($input, $filter, $direction = SORT_ASC, $sort_flags = SORT_REGULAR)
    {
        return Utils::sortArrayByKey($input, $filter, $direction, $sort_flags);
    }
218035
public function findBy($filters, $pageOpts = array(), $sort = array(), $inDeleted = false)
    {
        $qb = $this->db->createQueryBuilder();

        $qb->select($this->getSelect($this->profile))
            ->from($this->table, 't')
            ->where('1 = 1');

        $this->addJoins($qb, $this->getJoins($this->profile));
        $params = $this->addFilters($qb, $this->getFilters($this->profile));
        $params = array_merge($params, $this->addFilters($qb, $filters));
        $this->addGrouping($qb, $this->getGroupings($this->profile));
        $this->addSort($qb, $sort);

        return $this->getAll($qb, $params, $pageOpts, $inDeleted);
    }
1198052
public void sortCategories(String sortParams, String filter) {

        List<CmsCategoryBean> categories;
        SortParams sort = SortParams.valueOf(sortParams);
        switch (sort) {
            case tree:
                m_handler.onUpdateCategoriesTree(m_dialogBean.getCategories(), m_searchObject.getCategories());
                break;
            case title_asc:
                categories = getFilteredCategories(filter);
                Collections.sort(categories, new CmsComparatorTitle(true));
                m_handler.onUpdateCategoriesList(categories, m_searchObject.getCategories());
                break;
            case title_desc:
                categories = getFilteredCategories(filter);
                Collections.sort(categories, new CmsComparatorTitle(false));
                m_handler.onUpdateCategoriesList(categories, m_searchObject.getCategories());
                break;
            case type_asc:
            case type_desc:
            case path_asc:
            case path_desc:
            case dateLastModified_asc:
            case dateLastModified_desc:

            default:
        }
    }
740928
public function getSearchRequest($filter, $limit = 1, $conditions = [])
    {
        
        return $this->sourceDataAdapter->getSearchRequest($filter, $limit, $conditions);
    }
164370
public function findBy(array $criteria, ?array $sort = null, $limit = null, $skip = null) : array
    {
        return $this->getDocumentPersister()->loadAll($criteria, $sort, $limit, $skip)->toArray();
    }
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;
    }
6250
public function listContents($depth = 0, $filter = null, $type = 'all', $asHandlers = false)
	{
		$pattern = $this->path.'/*';

		if (is_array($filter))
		{
			$filters = $filter;
			$filter = new Filter;

			foreach ($filters as $f => $type)
			{
				if ( ! is_int($f))
				{
					$f = $type;
					$type = null;
				}

				$expected = true;

				if (strpos($f, '!') === 0)
				{
					$f = substr($f, 1);
					$expected = false;
				}

				$filter->addFilter($f, $expected, $type);
			}
		}

		if ($filter instanceof \Closure)
		{
			$callback = $filter;
			$filter = new Filter();
			$callback($filter);
		}

		if ( ! $filter)
		{
			$filter = new Filter;
		}

		$flags = GLOB_MARK;

		if ($type === 'file' and ! pathinfo($pattern, PATHINFO_EXTENSION))
		{
			// Add an extension wildcard
			$pattern .= '.*';
		}
		elseif ($type === 'dir')
		{
			$flags = GLOB_MARK | GLOB_ONLYDIR;
		}

		$contents = glob($pattern, $flags);

		// Filter the content.
		$contents = $filter->filter($contents);

		// Lower the depth for a recursive call
		if ($depth and $depth !== true)
		{
			$depth--;
		}

		$formatted = array();

		foreach ($contents as $item)
		{
			if ($filter->isCorrectType('dir', $item))
			{
				$_contents = array();

				if (($depth === true or $depth === 0) and ! $asHandlers)
				{
					$dir = new Directory($item);

					$_contents = $dir->listContents($item, $filter, $depth, $type);
				}

				if ($asHandlers)
				{
					$formatted[] = new Directory($item);
				}
				else
				{
					$formatted[$item] = $_contents;
				}
			}
			elseif ($filter->isCorrectType('file', $item))
			{
				if ($asHandlers)
				{
					$item = new File($item);
				}

				$formatted[] = $item;
			}
		}

		return $formatted;
	}
939095
public function getResults($searchParams, $sort = false, $limit = false)
    {
        $searchParams = array_filter((array)$searchParams, array($this, 'clearEmptySearchFields'));

        // getQuery actually returns a DataList
        return $this->getQuery($searchParams, $sort, $limit);
    }
1115612
public function getMediaData($currentId, $dateComparator, $sortOrder, $thumbnail)
    {
        /**
         * @var $current \Drupal\media_entity\Entity\Media
         */
        $current = $this->entityTypeManager
            ->getStorage('media')
            ->load($currentId);

        if(!$current)
        {
            return null;
        }

        $prev_or_next = \Drupal::entityQuery('media')
            ->condition('bundle', $current->bundle())
            ->condition('status', 1)
            ->condition('created', $current->getCreatedTime(), $dateComparator)
            ->sort('created', $sortOrder)
            ->range(0, 1)
            ->execute();

        if(!$prev_or_next)
        {
            return null;
        }

        $gallery = $this->entityTypeManager
            ->getStorage('media')
            ->load(array_values($prev_or_next)[0]);

        $all = $gallery->get('field_media_images');
        if(isset($all[0]))
        {
            $file   = $all[0]->entity->field_image->entity->getFileUri();

            return [
                'id'        => $gallery->id(),
                'title'     => $gallery->label(),
                'path'      => $gallery->toUrl()->toString(),
                'images'    => $all,
                'thumb'     => ImageStyle::load($thumbnail)->buildUrl($file)
            ];
        }


        return null;
    }
963536
protected function getContentInfoList(
        Criterion $filter,
        $sort,
        $offset,
        $limit,
        array $languageFilter
    ) {
        $query = $this->handler->createSelectQuery();
        $query->selectDistinct(
            'ezcontentobject.*',
            $this->handler->aliasedColumn($query, 'main_node_id', 'main_tree')
        );

        if ($sort !== null) {
            $this->sortClauseConverter->applySelect($query, $sort);
        }

        $query->from(
            $this->handler->quoteTable('ezcontentobject')
        )->innerJoin(
            'ezcontentobject_version',
            'ezcontentobject.id',
            'ezcontentobject_version.contentobject_id'
        )->leftJoin(
            $this->handler->alias(
                $this->handler->quoteTable('ezcontentobject_tree'),
                $this->handler->quoteIdentifier('main_tree')
            ),
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->handler->quoteColumn('contentobject_id', 'main_tree'),
                    $this->handler->quoteColumn('id', 'ezcontentobject')
                ),
                $query->expr->eq(
                    $this->handler->quoteColumn('main_node_id', 'main_tree'),
                    $this->handler->quoteColumn('node_id', 'main_tree')
                )
            )
        );

        if ($sort !== null) {
            $this->sortClauseConverter->applyJoin($query, $sort, $languageFilter);
        }

        $query->where(
            $this->getQueryCondition($filter, $query, $languageFilter)
        );

        if ($sort !== null) {
            $this->sortClauseConverter->applyOrderBy($query);
        }

        $query->limit($limit, $offset);

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(PDO::FETCH_ASSOC);
    }