Skip to content

Commit 279d461

Browse files
[9.x] Rename scope parameter on Runway tag (#741)
1 parent 81ce29b commit 279d461

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

docs/templating.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function food(Builder $query): void
4747
```
4848

4949
```antlers
50-
{{ runway:post scope="food" }}
50+
{{ runway:post query_scope="food" }}
5151
<h2>{{ title }}</h2>
5252
<p>{{ intro_text }}</p>
5353
{{ /runway:post }}
@@ -56,15 +56,15 @@ protected function food(Builder $query): void
5656
If you need to you can provide arguments to the scope like so:
5757

5858
```antlers
59-
{{ runway:post scope="food:argument" }}
59+
{{ runway:post query_scope="food:argument" }}
6060
```
6161

6262
In the above example, `argument` can either be a string or we'll grab it from 'the context' (the available variables) if we can find it.
6363

6464
You may also provide multiple scopes, if that's something you need...
6565

6666
```antlers
67-
{{ runway:post scope="food:argument|fastfood" }}
67+
{{ runway:post query_scope="food:argument|fastfood" }}
6868
```
6969

7070
### Filtering

docs/upgrade-guides/v8-to-v9.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ We highly recommend upgrading all the way to Laravel 12 and PHP 8.4.
4242

4343
## Medium impact changes
4444

45+
### The `scope` parameter on the Runway tag has been renamed
46+
**Affects app using the `scope` parameter on the Runway tag**
47+
48+
The `scope` parameter on the Runway tag has been renamed to `query_scope` to avoid conflicts with Antlers' own `scope` parameter.
49+
50+
```antlers
51+
{{ runway:post scope="food" }} {{# [!code --] #}}
52+
{{ runway:post query_scope="food" }} {{# [!code ++] #}}
53+
```
54+
4555
### `runway:rebuild-uri-cache` no longer removes global query scopes
4656

4757
The `runway:rebuild-uri-cache` command no longer removes global query scopes when querying models. If you were relying on this behaviour, you may remove global scopes using the `runwayRoutes` query scope:

src/Tags/RunwayTag.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ protected function query(): Builder
6464
$query->select(explode(',', (string) $select));
6565
}
6666

67-
if ($scopes = $this->params->get('scope')) {
68-
$scopes = explode('|', (string) $scopes);
67+
if ($queryScopes = $this->params->get('query_scope')) {
68+
$queryScopes = explode('|', (string) $queryScopes);
6969

70-
foreach ($scopes as $scope) {
71-
$scopeName = explode(':', $scope)[0];
72-
$scopeArguments = isset(explode(':', $scope)[1])
73-
? explode(',', explode(':', $scope)[1])
70+
foreach ($queryScopes as $queryScope) {
71+
$scopeName = explode(':', $queryScope)[0];
72+
$scopeArguments = isset(explode(':', $queryScope)[1])
73+
? explode(',', explode(':', $queryScope)[1])
7474
: [];
7575

7676
foreach ($scopeArguments as $key => $scopeArgument) {

tests/Tags/RunwayTagTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function can_get_models_with_scope_parameter()
9393
$posts[4]->update(['title' => 'Burger']);
9494

9595
$this->tag->setParameters([
96-
'scope' => 'food',
96+
'query_scope' => 'food',
9797
]);
9898

9999
$usage = $this->tag->wildcard('post');
@@ -118,7 +118,7 @@ public function can_get_models_with_scope_parameter_and_scope_arguments()
118118
]);
119119

120120
$this->tag->setParameters([
121-
'scope' => 'fruit:fab',
121+
'query_scope' => 'fruit:fab',
122122
]);
123123

124124
$usage = $this->tag->wildcard('post');
@@ -141,7 +141,7 @@ public function can_get_models_with_scope_parameter_and_scope_arguments_and_mult
141141
]);
142142

143143
$this->tag->setParameters([
144-
'scope' => 'food|fruit:fab',
144+
'query_scope' => 'food|fruit:fab',
145145
]);
146146

147147
$usage = $this->tag->wildcard('post');

0 commit comments

Comments
 (0)