Skip to content

Commit c1451ec

Browse files
committed
Remove deprecated code and fix post merge issues
1 parent 85b9e54 commit c1451ec

2 files changed

Lines changed: 51 additions & 168 deletions

File tree

‎src/View/Helper/BreadcrumbsHelper.php‎

Lines changed: 18 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Cake\View\Helper;
2020
use Cake\View\StringTemplateTrait;
2121
use LogicException;
22-
use function Cake\Core\deprecationWarning;
2322

2423
/**
2524
* BreadcrumbsHelper to register and display a breadcrumb trail for your views
@@ -61,36 +60,18 @@ class BreadcrumbsHelper extends Helper
6160
/**
6261
* Add a crumb to the end of the trail.
6362
*
64-
* @param array|string $content If provided as a string, it represents the content of the crumb.
65-
* Alternatively, if you want to add multiple crumbs at once, you can provide an array, with each values being a
66-
* single crumb. Arrays are expected to be of this form:
67-
*
68-
* - *content* The content of the crumb
69-
* - *link* The link of the crumb. If not provided, no link will be made
70-
* - *options* Options of the crumb. See description of params option of this method.
71-
*
63+
* @param string $content Represents the content of the crumb.
7264
* @param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to
7365
* Url::build() or null / empty if the crumb does not have a link.
7466
* @param array<string, mixed> $options Array of options. These options will be used as attributes HTML attribute the crumb will
7567
* be rendered in (a <li> tag by default). It accepts two special keys:
76-
*
7768
* - *innerAttrs*: An array that allows you to define attributes for the inner element of the crumb (by default, to
7869
* the link)
7970
* - *templateVars*: Specific template vars in case you override the templates provided.
8071
* @return $this
8172
*/
82-
public function add(array|string $content, array|string|null $url = null, array $options = []): static
73+
public function add(string $content, array|string|null $url = null, array $options = []): static
8374
{
84-
if (is_array($title)) {
85-
deprecationWarning(
86-
'5.3.0',
87-
'Passing an array as the first argument to BreadcrumbsHelper::add() is deprecated. ' .
88-
'Use addMany() instead.',
89-
);
90-
91-
return $this->addMany($title, $options);
92-
}
93-
9475
$this->crumbs[] = compact('content', 'url', 'options');
9576

9677
return $this;
@@ -99,7 +80,11 @@ public function add(array|string $content, array|string|null $url = null, array
9980
/**
10081
* Add multiple crumbs to the end of the trail.
10182
*
102-
* @param array<array{title?: string, url?: array|string|null, options?: array<string, mixed>}> $crumbs Array of crumbs to add.
83+
* @param array<array{content?: string, url?: array|string|null, options?: array<string, mixed>}> $crumbs Array of crumbs to add.
84+
* Arrays are expected to be of this form:
85+
* - *content* The content of the crumb
86+
* - *link* The link of the crumb. If not provided, no link will be made
87+
* - *options* Options of the crumb. See description of params option of this method.
10388
* @param array<string, mixed> $options Shared options for all crumbs. These options will be used as defaults
10489
* for each crumb, with individual crumb options taking precedence. These options will be used as attributes
10590
* HTML attribute the crumb will be rendered in (a <li> tag by default). It accepts two special keys:
@@ -109,10 +94,10 @@ public function add(array|string $content, array|string|null $url = null, array
10994
* - *templateVars*: Specific template vars in case you override the templates provided.
11095
* @return $this
11196
*/
112-
public function addMany(array $crumbs, array $options = [])
97+
public function addMany(array $crumbs, array $options = []): static
11398
{
11499
foreach ($crumbs as $crumb) {
115-
$crumb += ['title' => '', 'url' => null, 'options' => []];
100+
$crumb += ['content' => '', 'url' => null, 'options' => []];
116101
$crumb['options'] += $options;
117102
$this->crumbs[] = $crumb;
118103
}
@@ -123,14 +108,7 @@ public function addMany(array $crumbs, array $options = [])
123108
/**
124109
* Prepend a crumb to the start of the queue.
125110
*
126-
* @param array|string $content If provided as a string, it represents the content of the crumb.
127-
* Alternatively, if you want to add multiple crumbs at once, you can provide an array, with each values being a
128-
* single crumb. Arrays are expected to be of this form:
129-
*
130-
* - *content* The content of the crumb
131-
* - *link* The link of the crumb. If not provided, no link will be made
132-
* - *options* Options of the crumb. See description of params option of this method.
133-
*
111+
* @param string $content Represents the content of the crumb.
134112
* @param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to
135113
* Url::build() or null / empty if the crumb does not have a link.
136114
* @param array<string, mixed> $options Array of options. These options will be used as attributes HTML attribute the crumb will
@@ -141,18 +119,8 @@ public function addMany(array $crumbs, array $options = [])
141119
* - *templateVars*: Specific template vars in case you override the templates provided.
142120
* @return $this
143121
*/
144-
public function prepend(array|string $content, array|string|null $url = null, array $options = []): static
122+
public function prepend(string $content, array|string|null $url = null, array $options = []): static
145123
{
146-
if (is_array($title)) {
147-
deprecationWarning(
148-
'5.3.0',
149-
'Passing an array as the first argument to BreadcrumbsHelper::prepend() is deprecated. ' .
150-
'Use prependMany() instead.',
151-
);
152-
153-
return $this->prependMany($title, $options);
154-
}
155-
156124
array_unshift($this->crumbs, compact('content', 'url', 'options'));
157125

158126
return $this;
@@ -161,7 +129,11 @@ public function prepend(array|string $content, array|string|null $url = null, ar
161129
/**
162130
* Prepend multiple crumbs to the start of the queue.
163131
*
164-
* @param array<array{title?: string, url?: array|string|null, options?: array<string, mixed>}> $crumbs Array of crumbs to prepend.
132+
* @param array<array{content?: string, url?: array|string|null, options?: array<string, mixed>}> $crumbs Array of crumbs to prepend.
133+
* Arrays are expected to be of this form:
134+
* - *content* The content of the crumb
135+
* - *link* The link of the crumb. If not provided, no link will be made
136+
* - *options* Options of the crumb. See description of params option of this method.
165137
* @param array<string, mixed> $options Shared options for all crumbs. These options will be used as defaults
166138
* for each crumb, with individual crumb options taking precedence. These options will be used as attributes
167139
* HTML attribute the crumb will be rendered in (a <li> tag by default). It accepts two special keys:
@@ -171,11 +143,11 @@ public function prepend(array|string $content, array|string|null $url = null, ar
171143
* - *templateVars*: Specific template vars in case you override the templates provided.
172144
* @return $this
173145
*/
174-
public function prependMany(array $crumbs, array $options = [])
146+
public function prependMany(array $crumbs, array $options = []): static
175147
{
176148
$prepend = [];
177149
foreach ($crumbs as $crumb) {
178-
$crumb += ['title' => '', 'url' => null, 'options' => []];
150+
$crumb += ['content' => '', 'url' => null, 'options' => []];
179151
$crumb['options'] += $options;
180152
$prepend[] = $crumb;
181153
}

0 commit comments

Comments
 (0)