Skip to content

Commit aa1081d

Browse files
committed
[FEATURE] Delegate URL Handling to UrlGenerators
1 parent a97701c commit aa1081d

File tree

78 files changed

+1523
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1523
-577
lines changed

.ddev/config.yaml

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
name: guides
2+
type: php
3+
docroot: output
4+
php_version: "8.1"
5+
webserver_type: nginx-fpm
6+
router_http_port: "80"
7+
router_https_port: "443"
8+
xdebug_enabled: false
9+
additional_hostnames: []
10+
additional_fqdns: []
11+
nfs_mount_enabled: false
12+
mutagen_enabled: false
13+
use_dns_when_possible: true
14+
composer_version: "2"
15+
web_environment: []
16+
nodejs_version: "16"
17+
omit_containers: [db, ddev-ssh-agent]
18+
19+
# Key features of ddev's config.yaml:
20+
21+
# name: <projectname> # Name of the project, automatically provides
22+
# http://projectname.ddev.site and https://projectname.ddev.site
23+
24+
# type: <projecttype> # drupal6/7/8, backdrop, typo3, wordpress, php
25+
26+
# docroot: <relative_path> # Relative path to the directory containing index.php.
27+
28+
# php_version: "7.4" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1"
29+
30+
# You can explicitly specify the webimage but this
31+
# is not recommended, as the images are often closely tied to ddev's' behavior,
32+
# so this can break upgrades.
33+
34+
# webimage: <docker_image> # nginx/php docker image.
35+
36+
# database:
37+
# type: <dbtype> # mysql, mariadb
38+
# version: <version> # database version, like "10.3" or "8.0"
39+
# Note that mariadb_version or mysql_version from v1.18 and earlier
40+
# will automatically be converted to this notation with just a "ddev config --auto"
41+
42+
# router_http_port: <port> # Port to be used for http (defaults to port 80)
43+
# router_https_port: <port> # Port for https (defaults to 443)
44+
45+
# xdebug_enabled: false # Set to true to enable xdebug and "ddev start" or "ddev restart"
46+
# Note that for most people the commands
47+
# "ddev xdebug" to enable xdebug and "ddev xdebug off" to disable it work better,
48+
# as leaving xdebug enabled all the time is a big performance hit.
49+
50+
# xhprof_enabled: false # Set to true to enable xhprof and "ddev start" or "ddev restart"
51+
# Note that for most people the commands
52+
# "ddev xhprof" to enable xhprof and "ddev xhprof off" to disable it work better,
53+
# as leaving xhprof enabled all the time is a big performance hit.
54+
55+
# webserver_type: nginx-fpm # or apache-fpm
56+
57+
# timezone: Europe/Berlin
58+
# This is the timezone used in the containers and by PHP;
59+
# it can be set to any valid timezone,
60+
# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
61+
# For example Europe/Dublin or MST7MDT
62+
63+
# composer_root: <relative_path>
64+
# Relative path to the composer root directory from the project root. This is
65+
# the directory which contains the composer.json and where all Composer related
66+
# commands are executed.
67+
68+
# composer_version: "2"
69+
# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1
70+
# to use the latest major version available at the time your container is built.
71+
# It is also possible to select a minor version for example "2.2" which will
72+
# install the latest release of that branch. Alternatively, an explicit Composer
73+
# version may be specified, for example "1.0.22". Finally, it is also possible
74+
# to use one of the key words "stable", "preview" or "snapshot" see Composer
75+
# documentation.
76+
# To reinstall Composer after the image was built, run "ddev debug refresh".
77+
78+
# nodejs_version: "16"
79+
# change from the default system Node.js version to another supported version, like 12, 14, 17, 18.
80+
# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any
81+
# Node.js version, including v6, etc.
82+
83+
# additional_hostnames:
84+
# - somename
85+
# - someothername
86+
# would provide http and https URLs for "somename.ddev.site"
87+
# and "someothername.ddev.site".
88+
89+
# additional_fqdns:
90+
# - example.com
91+
# - sub1.example.com
92+
# would provide http and https URLs for "example.com" and "sub1.example.com"
93+
# Please take care with this because it can cause great confusion.
94+
95+
# upload_dir: custom/upload/dir
96+
# would set the destination path for ddev import-files to <docroot>/custom/upload/dir
97+
# When mutagen is enabled this path is bind-mounted so that all the files
98+
# in the upload_dir don't have to be synced into mutagen
99+
100+
# working_dir:
101+
# web: /var/www/html
102+
# db: /home
103+
# would set the default working directory for the web and db services.
104+
# These values specify the destination directory for ddev ssh and the
105+
# directory in which commands passed into ddev exec are run.
106+
107+
# omit_containers: [db, dba, ddev-ssh-agent]
108+
# Currently only these containers are supported. Some containers can also be
109+
# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit
110+
# the "db" container, several standard features of ddev that access the
111+
# database container will be unusable. In the global configuration it is also
112+
# possible to omit ddev-router, but not here.
113+
114+
# nfs_mount_enabled: false
115+
# Great performance improvement but requires host configuration first.
116+
# See https://ddev.readthedocs.io/en/stable/users/performance/#using-nfs-to-mount-the-project-into-the-container
117+
118+
# mutagen_enabled: false
119+
# Performance improvement using mutagen asynchronous updates.
120+
# See https://ddev.readthedocs.io/en/latest/users/performance/#using-mutagen
121+
122+
# fail_on_hook_fail: False
123+
# Decide whether 'ddev start' should be interrupted by a failing hook
124+
125+
# host_https_port: "59002"
126+
# The host port binding for https can be explicitly specified. It is
127+
# dynamic unless otherwise specified.
128+
# This is not used by most people, most people use the *router* instead
129+
# of the localhost port.
130+
131+
# host_webserver_port: "59001"
132+
# The host port binding for the ddev-webserver can be explicitly specified. It is
133+
# dynamic unless otherwise specified.
134+
# This is not used by most people, most people use the *router* instead
135+
# of the localhost port.
136+
137+
# host_db_port: "59002"
138+
# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic
139+
# unless explicitly specified.
140+
141+
# phpmyadmin_port: "8036"
142+
# phpmyadmin_https_port: "8037"
143+
# The PHPMyAdmin ports can be changed from the default 8036 and 8037
144+
145+
# host_phpmyadmin_port: "8036"
146+
# The phpmyadmin (dba) port is not normally bound on the host at all, instead being routed
147+
# through ddev-router, but it can be specified and bound.
148+
149+
# mailhog_port: "8025"
150+
# mailhog_https_port: "8026"
151+
# The MailHog ports can be changed from the default 8025 and 8026
152+
153+
# host_mailhog_port: "8025"
154+
# The mailhog port is not normally bound on the host at all, instead being routed
155+
# through ddev-router, but it can be bound directly to localhost if specified here.
156+
157+
# webimage_extra_packages: [php7.4-tidy, php-bcmath]
158+
# Extra Debian packages that are needed in the webimage can be added here
159+
160+
# dbimage_extra_packages: [telnet,netcat]
161+
# Extra Debian packages that are needed in the dbimage can be added here
162+
163+
# use_dns_when_possible: true
164+
# If the host has internet access and the domain configured can
165+
# successfully be looked up, DNS will be used for hostname resolution
166+
# instead of editing /etc/hosts
167+
# Defaults to true
168+
169+
# project_tld: ddev.site
170+
# The top-level domain used for project URLs
171+
# The default "ddev.site" allows DNS lookup via a wildcard
172+
# If you prefer you can change this to "ddev.local" to preserve
173+
# pre-v1.9 behavior.
174+
175+
# ngrok_args: --basic-auth username:pass1234
176+
# Provide extra flags to the "ngrok http" command, see
177+
# https://ngrok.com/docs#http or run "ngrok http -h"
178+
179+
# disable_settings_management: false
180+
# If true, ddev will not create CMS-specific settings files like
181+
# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php
182+
# In this case the user must provide all such settings.
183+
184+
# You can inject environment variables into the web container with:
185+
# web_environment:
186+
# - SOMEENV=somevalue
187+
# - SOMEOTHERENV=someothervalue
188+
189+
# no_project_mount: false
190+
# (Experimental) If true, ddev will not mount the project into the web container;
191+
# the user is responsible for mounting it manually or via a script.
192+
# This is to enable experimentation with alternate file mounting strategies.
193+
# For advanced users only!
194+
195+
# bind_all_interfaces: false
196+
# If true, host ports will be bound on all network interfaces,
197+
# not just the localhost interface. This means that ports
198+
# will be available on the local network if the host firewall
199+
# allows it.
200+
201+
# default_container_timeout: 120
202+
# The default time that ddev waits for all containers to become ready can be increased from
203+
# the default 120. This helps in importing huge databases, for example.
204+
205+
#web_extra_exposed_ports:
206+
#- name: nodejs
207+
# container_port: 3000
208+
# http_port: 2999
209+
# https_port: 3000
210+
#- name: something
211+
# container_port: 4000
212+
# https_port: 4000
213+
# http_port: 3999
214+
# Allows a set of extra ports to be exposed via ddev-router
215+
# The port behavior on the ddev-webserver must be arranged separately, for example
216+
# using web_extra_daemons.
217+
# For example, with a web app on port 3000 inside the container, this config would
218+
# expose that web app on https://<project>.ddev.site:9999 and http://<project>.ddev.site:9998
219+
# web_extra_exposed_ports:
220+
# - container_port: 3000
221+
# http_port: 9998
222+
# https_port: 9999
223+
224+
#web_extra_daemons:
225+
#- name: "http-1"
226+
# command: "/var/www/html/node_modules/.bin/http-server -p 3000"
227+
# directory: /var/www/html
228+
#- name: "http-2"
229+
# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000"
230+
# directory: /var/www/html
231+
232+
# override_config: false
233+
# By default, config.*.yaml files are *merged* into the configuration
234+
# But this means that some things can't be overridden
235+
# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge
236+
# and you can't erase existing hooks or all environment variables.
237+
# However, with "override_config: true" in a particular config.*.yaml file,
238+
# 'nfs_mount_enabled: false' can override the existing values, and
239+
# hooks:
240+
# post_start: []
241+
# or
242+
# web_environment: []
243+
# or
244+
# additional_hostnames: []
245+
# can have their intended affect. 'override_config' affects only behavior of the
246+
# config.*.yaml file it exists in.
247+
248+
# Many ddev commands can be extended to run tasks before or after the
249+
# ddev command is executed, for example "post-start", "post-import-db",
250+
# "pre-composer", "post-composer"
251+
# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more
252+
# information on the commands that can be extended and the tasks you can define
253+
# for them. Example:
254+
#hooks:

packages/guides-restructured-text/resources/config/guides-restructured-text.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use phpDocumentor\Guides\Graphs\Directives\UmlDirective;
66
use phpDocumentor\Guides\NodeRenderers\NodeRenderer;
7+
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolverInterface;
78
use phpDocumentor\Guides\RestructuredText\Directives\AdmonitionDirective;
89
use phpDocumentor\Guides\RestructuredText\Directives\AttentionDirective;
910
use phpDocumentor\Guides\RestructuredText\Directives\BaseDirective;
@@ -105,7 +106,6 @@
105106
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRoleFactory;
106107
use phpDocumentor\Guides\RestructuredText\Toc\GlobSearcher;
107108
use phpDocumentor\Guides\RestructuredText\Toc\ToctreeBuilder;
108-
use phpDocumentor\Guides\UrlGeneratorInterface;
109109
use Psr\Log\LoggerInterface;
110110
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
111111

@@ -165,7 +165,7 @@
165165
])
166166
->set(ContainerDirective::class)
167167
->set(ContentsDirective::class)
168-
->arg('$urlGenerator', service(UrlGeneratorInterface::class))
168+
->arg('$documentNameResolver', service(DocumentNameResolverInterface::class))
169169
->set(CsvTableDirective::class)
170170
->arg('$productions', service('phpdoc.guides.parser.rst.body_elements'))
171171
->set(DangerDirective::class)

packages/guides-restructured-text/src/RestructuredText/Directives/ContentsDirective.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
use phpDocumentor\Guides\Nodes\Menu\ContentMenuNode;
88
use phpDocumentor\Guides\Nodes\Node;
9+
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolverInterface;
910
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
1011
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
11-
use phpDocumentor\Guides\UrlGeneratorInterface;
1212

1313
/**
1414
* Standarad rst `contents` directive
@@ -17,8 +17,9 @@
1717
*/
1818
class ContentsDirective extends BaseDirective
1919
{
20-
public function __construct(private readonly UrlGeneratorInterface $urlGenerator)
21-
{
20+
public function __construct(
21+
private readonly DocumentNameResolverInterface $documentNameResolver,
22+
) {
2223
}
2324

2425
public function getName(): string
@@ -32,7 +33,7 @@ public function process(
3233
Directive $directive,
3334
): Node|null {
3435
$options = $directive->getOptions();
35-
$absoluteUrl = $this->urlGenerator->absoluteUrl(
36+
$absoluteUrl = $this->documentNameResolver->absoluteUrl(
3637
$blockContext->getDocumentParserContext()->getContext()->getDirName(),
3738
$blockContext->getDocumentParserContext()->getContext()->getCurrentFileName(),
3839
);

packages/guides-restructured-text/src/RestructuredText/Directives/ImageDirective.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
use phpDocumentor\Guides\Nodes\ImageNode;
88
use phpDocumentor\Guides\Nodes\Node;
9+
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolverInterface;
910
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
1011
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
11-
use phpDocumentor\Guides\UrlGeneratorInterface;
1212

1313
use function dirname;
1414

@@ -21,8 +21,9 @@
2121
*/
2222
class ImageDirective extends BaseDirective
2323
{
24-
public function __construct(private readonly UrlGeneratorInterface $urlGenerator)
25-
{
24+
public function __construct(
25+
private readonly DocumentNameResolverInterface $documentNameResolver,
26+
) {
2627
}
2728

2829
public function getName(): string
@@ -36,7 +37,7 @@ public function processNode(
3637
Directive $directive,
3738
): Node {
3839
return new ImageNode(
39-
$this->urlGenerator->absoluteUrl(
40+
$this->documentNameResolver->absoluteUrl(
4041
dirname($blockContext->getDocumentParserContext()->getContext()->getCurrentAbsolutePath()),
4142
$directive->getData(),
4243
),

packages/guides-restructured-text/src/RestructuredText/Toc/GlobSearcher.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
use Flyfinder\Specification\Glob;
88
use phpDocumentor\Guides\ParserContext;
9-
use phpDocumentor\Guides\UrlGeneratorInterface;
9+
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolverInterface;
1010

1111
use function rtrim;
1212

1313
class GlobSearcher
1414
{
15-
public function __construct(private readonly UrlGeneratorInterface $urlGenerator)
16-
{
15+
public function __construct(
16+
private readonly DocumentNameResolverInterface $documentNameResolver,
17+
) {
1718
}
1819

1920
/** @return string[] */
@@ -25,7 +26,7 @@ public function globSearch(ParserContext $parserContext, string $globPattern): a
2526
);
2627
$allFiles = [];
2728
foreach ($files as $file) {
28-
$allFiles[] = $this->urlGenerator->absoluteUrl($parserContext->getDirName(), $file['filename']);
29+
$allFiles[] = $this->documentNameResolver->absoluteUrl($parserContext->getDirName(), $file['filename']);
2930
}
3031

3132
return $allFiles;

packages/guides-restructured-text/tests/unit/Parser/Productions/RuleTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
use phpDocumentor\Guides\Nodes\InlineCompoundNode;
1010
use phpDocumentor\Guides\Nodes\ProjectNode;
1111
use phpDocumentor\Guides\ParserContext;
12+
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolver;
1213
use phpDocumentor\Guides\RestructuredText\MarkupLanguageParser;
1314
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
1415
use phpDocumentor\Guides\RestructuredText\Parser\DocumentParserContext;
1516
use phpDocumentor\Guides\RestructuredText\Parser\InlineParser;
1617
use phpDocumentor\Guides\RestructuredText\Parser\LinesIterator;
1718
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRoleFactory;
18-
use phpDocumentor\Guides\UrlGenerator;
1919
use PHPUnit\Framework\TestCase;
2020

2121
abstract class RuleTestCase extends TestCase
@@ -41,7 +41,7 @@ protected function createContext(string $input): BlockContext
4141
'test',
4242
1,
4343
self::createStub(FilesystemInterface::class),
44-
new UrlGenerator(),
44+
new DocumentNameResolver(),
4545
);
4646
$documentParserContext = new DocumentParserContext(
4747
$parserContext,

0 commit comments

Comments
 (0)