YetiForceCompany / YetiForceCRM

Our team created for you one of the most innovative CRM systems that supports mainly business processes and allows for customization according to your needs. Be ahead of your competition and implement YetiForce!
https://yetiforce.com
Other
1.74k stars 750 forks source link

[Question] How to develop modules and functions preserving ability to update with official Service Packs #12070

Closed svdaru closed 5 years ago

svdaru commented 5 years ago
  1. Is there any Instructions, Best practice guides etc for developing modules and functions?

  2. Yetiforce (VTiger) architecture in some cases requires changing of embedded classes. For example, I need to add detail view link (DETAIL_VIEW_ADDITIONAL) to Account whit linkurl dynamically generated by other module function. In that case, I will change getDetailViewLinks function at Accounts_DetailView_Model class, which can be overwritten with upcoming Service Pack.
    Another case is making custom function for getting related entities. For example, I create new module «Polices». One Account has many Polices, but relation logic is not standard and includes some additional conditions. Custom relation logic must include changing of Parent module (Account) functions.

What can you recommend to avoid merging Service Packs with locally changed files or to minimize (optimize) merging?

davide-alghi commented 5 years ago

Hi,

  1. there is not reference / guide about development
  2. every change to core code will be rewritten by updates/upgrade. this is unavoidably if engine doesn't provide code overriding: for Vtiger is the same
setras commented 5 years ago

you can use the build-in autoloader functionality https://yetiforce.com/en/knowledge-base/documentation/developer-documentation/item/loader-and-autoloader-of-files

The Loader allows to overwrite any system file. A folder named 'custom' needs to be added to the main CRM directory and a complete file path provided, e.g. custom/modules/Accounts/Accounts.php. The system will load the file Accounts.php instead of the original file. Currently, this solution works only for modules, but in the future the system will allow to change system files globally. A list of directories possible to overwrite:

modules/ModuleName/...  >>    custom/modules/ModuleName/...
languages/...   >>   custom/languages/...
layouts/vlayout/modules/...   >>   custom/layouts/vlayout/modules/...

In case of language files, the mechanism responsible for overwriting works differently. An empty language file has to be created and you should only add translations that need to be overwritten (no need to duplicate the entire language file).

mariuszkrzaczkowski commented 5 years ago

@svdaru use link mechanism: https://github.com/YetiForceCompany/YetiForceCRM/blob/developer/modules/ModTracker/ModTracker.php#L171

setras commented 5 years ago

@svdaru forgot to mention that this feature needs to be enabled in the perfomance.php config file

// Parameter that allows to disable file overwriting. After 
    // enabling it the system will additionally check whether the file exists in the custom directory.
    // Ex. custom/modules/Assets/Assets.php 
    'LOAD_CUSTOM_FILES' => true,
    'LOAD_CUSTOM_LANGUAGE' => true,
svdaru commented 5 years ago

@svdaru use link mechanism: https://github.com/YetiForceCompany/YetiForceCRM/blob/developer/modules/ModTracker/ModTracker.php#L171

Thanks. As I understand, linkurl is interpreted at view controller. Is there a way to use static php function from any other module class to generate link?

svdaru commented 5 years ago

@svdaru forgot to mention that this feature needs to be enabled in the perfomance.php config file

// Parameter that allows to disable file overwriting. After 
  // enabling it the system will additionally check whether the file exists in the custom directory.
  // Ex. custom/modules/Assets/Assets.php 
  'LOAD_CUSTOM_FILES' => true,
  'LOAD_CUSTOM_LANGUAGE' => true,

Thank you. That will help.