interval = 0; $this->title = __('Default element'); $this->ajaxController = $ajax_controller; } /** * Return error message to target. * * @param string $msg Error message. * * @return void */ public static function error(string $msg) { echo json_encode(['error' => $msg]); } /** * Verifies target method is allowed to be called using AJAX call. * * @param string $method Method to be invoked via AJAX. * * @return boolean Available (true), or not (false). */ public function ajaxMethod(string $method):bool { return in_array($method, $this->ajaxMethods) === true; } /** * Cut the text to display it on the labels. * * @param string $text Text for cut. * @param integer $length Length max for text cutted. * * @return string */ protected function controlSizeText(string $text, int $length=14):string { if (mb_strlen($text) > $length) { $newText = mb_substr($text, 0, $length).'...'; return $newText; } else { return $text; } } }