Skip to content

URL API

URLService enables you to find, load and update external URLs used in RichText and URL Fields.

To view a list of all URLs, use URLService::findUrls

URLService::findUrls takes as argument a URLQuery, in which you need to specify:

  • query filter e.g. Section
  • Sort Clauses for URL queries
  • offset for search hits, used for paging the results
  • query limit. If value is 0, search query will not return any search hits
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
// ...
use eZ\Publish\API\Repository\Values\URL\URLQuery;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;

// ...
        $query->filter = new Criterion\LogicalAnd(
            [
                new Criterion\SectionIdentifier(['standard']),
                new Criterion\Validity(true),
            ]
        );
        $query->sortClauses = [
            new SortClause\URL(SortClause::SORT_DESC),
        ];
        $query->offset = 0;
        $query->limit = 25;

        $results = $this->urlService->findUrls($query);

        foreach ($results->items as $result) {

URL search reference

For the reference of Search Criteria and Sort Clauses you can use in URL search, see URL search reference.