abstract class Widget
{
protected $template;
public function __construct()
{ }
public function setTemplate(string $template)
{
if (!file_exists($template)) {
throw new \Exception('Widget template "' . $template . '" was not found.');
}
$this->template = $template;
return $this;
}
abstract public function render(TemplateService $templateService, Client $client) : string;
}
$contacts_fields = array(
"site_telephone_2" => ['value' => "телефон 2", 'type' => 'phone'],
"site_email_2" => ['value' => "почта 2", 'type' => 'email'],
);
function decorator($name, $value, $type) {
switch($type) {
...
}
}
$res = [];
foreach($sqlResult as $row) {
if(!array_key_exists($row['id'], $res) {
$res[$row['id']] = [
'id' => $row['id'],
'name' => $row['name'],
'requests_params' => []
];
}
$res[$row['id']]['requests_params'][] = [
'fio' => $row['fio'],
'rid' => $row['rid']
];
}
echo json_encode(array_values($res));