blob: affd5198fdbc942ddf1b46196a5d682d5fda41ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<?php
namespace ipl\Web\FormElement\ScheduleElement\Common;
trait FieldsProtector
{
/** @var callable */
protected $protector;
/**
* Set callback to protect ids with
*
* @param ?callable $protector
*
* @return $this
*/
public function setIdProtector(?callable $protector): self
{
$this->protector = $protector;
return $this;
}
/**
* Protect the given html id
*
* The provided id is returned as is, if no protector is specified
*
* @param string $id
*
* @return string
*/
public function protectId(string $id): string
{
if (is_callable($this->protector)) {
return call_user_func($this->protector, $id);
}
return $id;
}
}
|