Write the common functions in espocrm?????????
Write the common functions in espocrm please help me..................?
Collapse
X
-
-
Closest I can find is the "Util" class (application/Espo/Core/Utils/Util.php) which contains public static functions like:
public static function hyphenToCamelCase(string $string) : string
{
return self::toCamelCase($string, '-');
}
that can be called from any class using the full namespace function name like:
$name = \Espo\Core\Utils\Util::hyphenToCamelCase($name);
However any modifications to the Util class would not be upgrade safe, so I would create a custom Util class (custom/Espo/Custom/Utils/MyUtil.php) and define your custom public static functions there like so:
namespace Espo\Custom\Utils;
use \Espo\Core\Exceptions\Error;
class MyUtil
{
public static function myFirstFunction()
{
bla bla bla
}
}
which could be called from another script as $anything = \Espo\Custom\Utils\MyUtil::myFirstFunction();
I haven't tested it because I have no use for it at the moment, but hopefully it can give you an idea, if it works please share your solution so everyone can benefit :-)Comment
-
I am doing that but using an empty entrypoint instead of a whole new class. I've been doing that with static methods since no info is written on how to instantiate an espo-inherited class. IMHO dependency injection is a form of code obfuscation when documentation is not enough...Comment
Comment