protected static function parseCriteria(array $criteria): array
    {
        $columns = [];
        $values = [];
        $options = ['order' => 'name'];

        // Find by source
        if ($criteria['source']) {
            $columns[] = 'source=?';
            $values[] = $criteria['source'];
        }

        // Find by alias
        if ($criteria['alias']) {
            $columns[] = 'alias=?';
            $values[] = $criteria['alias'];
        }

        // Find only the used tags
        if ($criteria['usedOnly']) {
            $ids = \Haste\Model\Model::getRelatedValues($criteria['sourceTable'], $criteria['sourceField']);

            if (\count($ids) < 1) {
                throw new NoTagsException();
            }

            $columns[] = 'id IN ('.\implode(',', \array_map('intval', \array_unique($ids))).')';
        }

        // Find the tags by values/IDs
        if (\is_array($criteria['values'])) {
            if (\count($criteria['values']) < 1) {
                throw new NoTagsException();
            }

            $columns[] = 'id IN ('.\implode(',', \array_map('intval', $criteria['values'])).')';
        }

        // Find the tags by aliases
        if (\is_array($criteria['aliases'])) {
            if (\count($criteria['aliases']) < 1) {
                throw new NoTagsException();
            }

            $columns[] = "alias IN ('".\implode("','", $criteria['values'])."')'";
        }

        return [$columns, $values, $options];
    }