• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 3904303394

pending completion
3904303394

Pull #5332

github

GitHub
Merge 2e0a3ceae into 965332bc8
Pull Request #5332: Revert "chore(deprecation): Only use ValueResolverInterface if it exists"

2 of 2 new or added lines in 1 file covered. (100.0%)

7939 of 12085 relevant lines covered (65.69%)

81.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Api/UrlGeneratorInterface.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Api;
15

16
use Symfony\Component\Routing\Exception\InvalidParameterException;
17
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
18
use Symfony\Component\Routing\Exception\RouteNotFoundException;
19

20
/**
21
 * UrlGeneratorInterface is the interface that all URL generator classes must implement.
22
 *
23
 * This interface has been imported and adapted from the Symfony project.
24
 *
25
 * The constants in this interface define the different types of resource references that
26
 * are declared in RFC 3986: http://tools.ietf.org/html/rfc3986
27
 * We are using the term "URL" instead of "URI" as this is more common in web applications
28
 * and we do not need to distinguish them as the difference is mostly semantical and
29
 * less technical. Generating URIs, i.e. representation-independent resource identifiers,
30
 * is also possible.
31
 *
32
 * @author Fabien Potencier <fabien@symfony.com>
33
 * @author Tobias Schultze <http://tobion.de>
34
 * @copyright Fabien Potencier
35
 */
36
interface UrlGeneratorInterface
37
{
38
    /**
39
     * Generates an absolute URL, e.g. "http://example.com/dir/file".
40
     */
41
    public const ABS_URL = 0;
42

43
    /**
44
     * Generates an absolute path, e.g. "/dir/file".
45
     */
46
    public const ABS_PATH = 1;
47

48
    /**
49
     * Generates a relative path based on the current request path, e.g. "../parent-file".
50
     *
51
     * @see UrlGenerator::getRelativePath()
52
     */
53
    public const REL_PATH = 2;
54

55
    /**
56
     * Generates a network path, e.g. "//example.com/dir/file".
57
     * Such reference reuses the current scheme but specifies the host.
58
     */
59
    public const NET_PATH = 3;
60

61
    /**
62
     * Generates a URL or path for a specific route based on the given parameters.
63
     *
64
     * Parameters that reference placeholders in the route pattern will substitute them in the
65
     * path or host. Extra params are added as query string to the URL.
66
     *
67
     * When the passed reference type cannot be generated for the route because it requires a different
68
     * host or scheme than the current one, the method will return a more comprehensive reference
69
     * that includes the required params. For example, when you call this method with $referenceType = ABSOLUTE_PATH
70
     * but the route requires the https scheme whereas the current scheme is http, it will instead return an
71
     * ABSOLUTE_URL with the https scheme and the current host. This makes sure the generated URL matches
72
     * the route in any case.
73
     *
74
     * If there is no route with the given name, the generator must throw the RouteNotFoundException.
75
     *
76
     * The special parameter _fragment will be used as the document fragment suffixed to the final URL.
77
     *
78
     * @throws RouteNotFoundException              If the named route doesn't exist
79
     * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
80
     * @throws InvalidParameterException           When a parameter value for a placeholder is not correct because
81
     *                                             it does not match the requirement
82
     */
83
    public function generate(string $name, array $parameters = [], int $referenceType = self::ABS_PATH): string;
×
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc