public static function hasBehavior($component, $behavior)
{
if ($behavior instanceof Behavior) {
$behavior = (string) $behavior->className();
} else {
if (is_string($behavior)) {
$behavior = (string) $behavior;
}
}
if (!method_exists($component, 'getBehaviors')) {
return false;
}
$hasBehaviors = $component->getBehaviors();
foreach ($hasBehaviors as $hasBehavior) {
if ($hasBehavior instanceof $behavior) {
return true;
}
}
return false;
}