Source
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Trait for objects that can be casted to web elements.
*/
trait CastableTrait {
/**
* Cast object to base Element.
*
* @param array $options additional casting options
*
* @return CElement
*/
public function asElement($options = []) {
return $this->cast(CElement::class, $options);
}
/**
* Cast object to Checkbox element.
*
* @param array $options additional casting options
*
* @return CCheckboxElement
*/
public function asCheckbox($options = []) {
return $this->cast(CCheckboxElement::class, $options);
}
/**
* Cast object to CheckboxList element.
*
* @param array $options additional casting options
*
* @return CCheckboxElement
*/
public function asCheckboxList($options = []) {
return $this->cast(CCheckboxListElement::class, $options);
}
/**
* Cast object to Dashboard element.
*
* @param array $options additional casting options
*
* @return CDashboardElement
*/
public function asDashboard($options = []) {
return $this->cast(CDashboardElement::class, $options);
}