Search repositories

@link https://developer.github.com/v3/search/#search-repositories

@param string $q
@param string $sort
@param string $order

@return array
@throws \Exception
328718
public function searchRepositories(string $q, string $sort = null,
                                       string $order = AbstractApi::DIRECTION_DESC): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/search/repositories?:args',
            http_build_query(['q' => $q, 'sort' => $sort, 'order' => $order])));
    }
1297120
public function actionAll($sort = '')
    {
        $order = ExtHelpers::getOrder($sort, [
            'url_id',
            'route',
            'method',
            'host',
            'enable_rule',
            'note',
            'status'
        ], [], 'url_id DESC');
        $list = DpAdminMenuUrl::find()->orderBy($order)->all();

        return [
            'total' => count($list),
            'list' => $list,
        ];
    }
754919
public function searchVideos($q, $maxResults = 10, $order = null)
    {
        $params = array(
            'q' => $q,
            'type' => 'video',
            'part' => 'id, snippet',
            'maxResults' => $maxResults
        );
        if (!empty($order)) {
            $params['order'] = $order;
        }

        return $this->searchAdvanced($params);
    }
521939
public function listForks(string $sort = AbstractApi::SORT_NEWEST): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/forks?:arg',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(),
            http_build_query(['sort' => $sort])));
    }
1293065
public function findNewsletterSubscription($search, $sortColumn, $sortDirection)
    {
        $em = $this->getEntityManager();
        $repository = $em->getRepository('CoreBundle:NewsletterSubscription');
        $qb = $repository->createQueryBuilder('n');
            
        // select
        $qb->select('n.id, n.email, n.name, n.role');

        // search
        if (!empty($search)) {
            // where('u.email LIKE :search')
            $qb->andWhere('n.name LIKE :search')
                ->setParameter('search', '%'.$search.'%');
        }

        // sort by column
        switch($sortColumn) {
            case 0:
                $qb->orderBy('n.id', $sortDirection);
                break;
            case 2:
                $qb->orderBy('n.email', $sortDirection);
                break;
            case 3:
                $qb->orderBy('n.name', $sortDirection);
                break;
            case 4:
                $qb->orderBy('n.role', $sortDirection);
                break;
        }

        return $qb->getQuery();
    }
831246
public function prepareOrder($order = null, $sort = null)
    {
        if ($order == null or $sort == null) {
            $this->setOrderBy = '';

            return $this;
        }

        if (!in_array($sort, ['ASC', 'DESC'])) {
            $sort = 'DESC';
        }

        $this->setOrderBy = ' ORDER BY ' . $order . ' ' . $sort;

        return $this;
    }
424493
protected function _sort(QueryBuilder $qb, array $sorts = [])
    {
        foreach ($sorts as $field => $direction) {
            $qb->addOrderBy('e.'.$field, $direction);
        }
        return $qb;
    }
791180
public function findAll($executeQuery = true, $orderedBy = 'id', $order = null)
    {
        if (!$executeQuery) {
            $dql = "
                SELECT u, pws, g, r, rws
                FROM Claroline\CoreBundle\Entity\User u
                LEFT JOIN u.personalWorkspace pws
                LEFT JOIN u.groups g
                LEFT JOIN u.roles r
                LEFT JOIN r.workspace rws
                WHERE u.isRemoved = false
                ORDER BY u.{$orderedBy} {$order}
            ";

            return $this->_em->createQuery($dql);
        }

        return parent::findAll();
    }
184633
public function getOrderName(Order $order): string
    {
        if (preg_match_all('/{{(.*)}}/U', $scheme = $this->getNameScheme(), $matches)) {
            foreach ($matches[1] as $index => $foundSnippet) {
                $foundSnippetName = trim($foundSnippet);
                $usedSnippet = $order->hasField($foundSnippetName)
                    ? $order->get($foundSnippetName)
                    : date($foundSnippetName);

                $scheme = str_replace($matches[0][$index], $usedSnippet, $scheme);
            }
        }

        return $scheme;
    }
1287373
protected function buildOrderJoin(string $order): array
    {
        list($column, $direction) = $this->formatOrderDirection($order);

        $lookupBuilder = $this->getLookupBuilder();

        $column = $lookupBuilder->fetchColumnName($column);
        $newOrder = $lookupBuilder->buildJoin($this, $column);
        if (false === $newOrder) {
            return [$column, $direction];
        }

        list($alias, $column) = $newOrder;

        return [
            $alias.'.'.$column,
            $direction,
        ];
    }
300487
public function sortKeys($order = SORT_ASC, $strategy = SORT_REGULAR)
    {
        $this->sortingKeys($this->elements, $order, $strategy);

        return $this;
    }
424885
public function getResults($sort = null)
    {
        $results = $this->results;

        if ($sort) {
            (strtolower($sort) == static::SORT_DESC) ? arsort($results) : asort($results);
        }

        return $results;
    }
943770
protected function recode_choice_order($order) {
        $neworder = array();
        foreach (explode(',', $order) as $id) {
            if ($newid = $this->get_mappingid('question_answer', $id)) {
                $neworder[] = $newid;
            }
        }
        return implode(',', $neworder);
    }
657932
public function createOrder($order = array())
    {
        $myOrder = new Order($order);
        $response = OrderService::createOrder($myOrder);

        if (isset($response["orderCode"])) {
            //success
            return $response;
        } else {
            Error::throwError("apierror");
        }
    }
494023
protected function applySort(AbstractSearch $search, array $sort = null)
    {
        $sort = $sort ?: $search->getDefaultSort();

        if (is_callable($sort)) {
            $sort($search->getQuery());
        } else {
            foreach ($sort as $field => $order) {
                if (is_array($order)) {
                    foreach ($order as $value) {
                        $search->getQuery()->orderByRaw(snake_case($field).' != ?', [$value]);
                    }
                } else {
                    $search->getQuery()->orderBy(snake_case($field), $order);
                }
            }
        }
    }
544300
public function findOrderCouponsByOrder(OrderInterface $order)
    {
        return $this
            ->createQueryBuilder('oc')
            ->where('oc.order = :order')
            ->setParameter('order', $order)
            ->getQuery()
            ->getResult();
    }
1243154
public function getFileErrors($order = 'error.counter', $direction = 'DESC')
    {
        $this->getAll(true);

        /** @var QueryBuilder $qb */
        $qb = $this->qb;

        return $qb
            ->andWhere('error.type = :type')
            ->setParameter('type', HttpError::TYPE_FILE)
            ->orderBy($order, $direction);
    }