Skip to content

Commit fef0aeb

Browse files
committed
5.9.1 release
1 parent 1f88337 commit fef0aeb

File tree

3 files changed

+259
-0
lines changed

3 files changed

+259
-0
lines changed

src/Html/Breadcrumbs.php

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* This component offers an easy way to create breadcrumbs for your application.
1818
* The resulting HTML when calling `render()` will have each breadcrumb enclosed
1919
* in `<dt>` tags, while the whole string is enclosed in `<dl>` tags.
20+
*
21+
* @deprecated Will be removed in future version
22+
* Use {@see Phalcon\Html\Helper\Breadcrumbs} instead.
2023
*/
2124
class Breadcrumbs
2225
{

src/Html/Helper/Breadcrumbs.php

+254
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
<?php
2+
3+
/* This file is part of the Phalcon Framework.
4+
*
5+
* (c) Phalcon Team <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE.txt
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Phalcon\Html\Helper;
11+
12+
use Phalcon\Support\Helper\Str\Interpolate;
13+
use Phalcon\Html\Escaper\EscaperInterface;
14+
15+
/**
16+
* This component offers an easy way to create breadcrumbs for your application.
17+
* The resulting HTML when calling `render()` will have each breadcrumb enclosed
18+
* in `<li>` tags, while the whole string is enclosed in `<nav>` and `<ol>` tags.
19+
*
20+
* @phpstan-type TTemplate = array{
21+
* main: string,
22+
* line: string,
23+
* last: string,
24+
* }
25+
* @phpstan-type TElement = array{
26+
* attributes: array<string, string>,
27+
* icon: string,
28+
* link: string,
29+
* text: string,
30+
* }
31+
*/
32+
class Breadcrumbs extends \Phalcon\Html\Helper\AbstractHelper
33+
{
34+
/**
35+
* @var array<string, string>
36+
*/
37+
private $attributes = [];
38+
39+
/**
40+
* Keeps all the breadcrumbs.
41+
*
42+
* @var array<int, TElement>
43+
*/
44+
private $data = [];
45+
46+
/**
47+
* Crumb separator.
48+
*
49+
* @var string
50+
*/
51+
private $separator = '<li>/</li>';
52+
53+
/**
54+
* The HTML template to use to render the breadcrumbs.
55+
*
56+
* @var TTemplate
57+
*/
58+
private $template = ['main' => '
59+
<nav%attributes%>
60+
<ol>
61+
%items%
62+
</ol>
63+
</nav>', 'line' => '<li%attributes%><a href=\\\"%link%\\\">%icon%%text%</a></li>', 'last' => '<li><span%attributes%>%text%</span></li>'];
64+
65+
/**
66+
* The HTML template to use to render the breadcrumbs.
67+
*
68+
* @var Interpolate
69+
*/
70+
private $interpolator;
71+
72+
/**
73+
* AbstractHelper constructor.
74+
*
75+
* @param EscaperInterface $escaper
76+
* @param string $indent = ""
77+
* @param string|null $delimiter = null
78+
*/
79+
public function __construct(\Phalcon\Html\Escaper\EscaperInterface $escaper)
80+
{
81+
}
82+
83+
/**
84+
* Sets the indent and delimiter and returns the object back.
85+
*
86+
* @param string $indent
87+
* @param string $delimiter
88+
* @return Breadcrumbs
89+
*/
90+
public function __invoke(string $indent = ' ', string $delimiter = null): Breadcrumbs
91+
{
92+
}
93+
94+
/**
95+
* Adds a new crumb.
96+
*
97+
* ```php
98+
* // Adding a crumb with a link
99+
* $breadcrumbs->add("Home", "/");
100+
*
101+
* // Adding a crumb with added attributes
102+
* $breadcrumbs->add("Home", "/", ["class" => "main"]);
103+
*
104+
* // Adding a crumb without a link (normally the last one)
105+
* $breadcrumbs->add("Users");
106+
* ```
107+
*
108+
* @param string $text
109+
* @param string $link
110+
* @param string $icon
111+
* @param array $attributes
112+
* @return Breadcrumbs
113+
*/
114+
public function add(string $text, string $link = '', string $icon = '', array $attributes = []): Breadcrumbs
115+
{
116+
}
117+
118+
/**
119+
* Clears the crumbs.
120+
*
121+
* ```php
122+
* $breadcrumbs->clear()
123+
* ```
124+
*
125+
* @return void
126+
*/
127+
public function clear(): void
128+
{
129+
}
130+
131+
/**
132+
* Clear the attributes of the parent element.
133+
*
134+
* @return Breadcrumbs
135+
*/
136+
public function clearAttributes(): Breadcrumbs
137+
{
138+
}
139+
140+
/**
141+
* Get the attributes of the parent element.
142+
*
143+
* @return array<string, string>
144+
*/
145+
public function getAttributes(): array
146+
{
147+
}
148+
149+
/**
150+
* Returns the separator.
151+
*
152+
* @return string
153+
*/
154+
public function getSeparator(): string
155+
{
156+
}
157+
158+
/**
159+
* Return the current template.
160+
*
161+
* @return TTemplate
162+
*/
163+
public function getTemplate(): array
164+
{
165+
}
166+
167+
/**
168+
* Removes crumb by url.
169+
*
170+
* ```php
171+
* // Remove the second element
172+
* $breadcrumbs->remove(2);
173+
* ```
174+
*
175+
* @param int $index
176+
* @return void
177+
*/
178+
public function remove(int $index): void
179+
{
180+
}
181+
182+
/**
183+
* Renders and outputs breadcrumbs based on previously set template.
184+
*
185+
* ```php
186+
* echo $breadcrumbs->render();
187+
* ```
188+
*
189+
* @return string
190+
*/
191+
public function render(): string
192+
{
193+
}
194+
195+
/**
196+
* Set the attributes for the parent element.
197+
*
198+
* @param array $attributes
199+
* @return Breadcrumbs
200+
*/
201+
public function setAttributes(array $attributes): Breadcrumbs
202+
{
203+
}
204+
205+
/**
206+
* Set the separator.
207+
*
208+
* @param string $separator
209+
* @return Breadcrumbs
210+
*/
211+
public function setSeparator(string $separator): Breadcrumbs
212+
{
213+
}
214+
215+
/**
216+
* Set the HTML template.
217+
*
218+
* @param string $main
219+
* @param string $line
220+
* @param string $last
221+
* @return Breadcrumbs
222+
*/
223+
public function setTemplate(string $main, string $line, string $last): Breadcrumbs
224+
{
225+
}
226+
227+
/**
228+
* Returns the internal breadcrumbs array.
229+
*
230+
* @return array<int, TElement>
231+
*/
232+
public function toArray(): array
233+
{
234+
}
235+
236+
/**
237+
* @param TElement $element
238+
* @param string $template
239+
* @return string
240+
*/
241+
private function getLink(string $template, array $element): string
242+
{
243+
}
244+
245+
/**
246+
* Processes attributes
247+
*
248+
* @param array $attributes
249+
* @return string
250+
*/
251+
private function processAttributes(array $attributes): string
252+
{
253+
}
254+
}

src/Html/TagFactory.php

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Phalcon\Factory\AbstractFactory;
1313
use Phalcon\Html\Escaper\EscaperInterface;
14+
use Phalcon\Html\Helper\Breadcrumbs;
1415
use Phalcon\Html\Helper\Doctype;
1516
use Phalcon\Html\Helper\Input\Checkbox;
1617
use Phalcon\Html\Helper\Input\Color;
@@ -58,6 +59,7 @@
5859
*
5960
* @method string a(string $href, string $text, array $attributes = [], bool $raw = false)
6061
* @method string base(string $href, array $attributes = [])
62+
* @method Breadcrumbs breadcrumbs(string $indent = ' ', string $delimiter = "\n")
6163
* @method string body(array $attributes = [])
6264
* @method string button(string $text, array $attributes = [], bool $raw = false)
6365
* @method string close(string $tag, bool $raw = false)

0 commit comments

Comments
 (0)