1.Connector creation

If you want to develop a connector for Myddleware, we advise you to use this documentation.

Était - ce   utile   ? Yes No Suggérer  de  modifier


It is important that the application you want to connect has a webservice API with functions to read data. This will make it easier to use for source application and create/update data and also for target application.

In our example, we will create the shop-application connector.

First you will need to prepare Myddleware :

  • Add the service in Symfony, file <Myddleware>/RegleBundle/Resources/config/services.yml


  • Add your application in the database, table Solution:


  • Finally create your connector class to develop it in the directory <Myddleware>. The filename has to be the name of the service. The code should be this code, but change the application name :


Lets now look at each function and attribute and how to debug them.

Était - ce   utile   ? Yes No Suggérer  de  modifier

1.2.Method getFieldsLogin

You have to put the parameters required to connect to your solution in the method getFieldsLogin.

For example, if you need an url and an APIkey you can create this method :


Code available in the file <Myddleware>/src/Myddleware/RegleBundle/Solutions/shopapplication.php

If the field you need doesn’t exit in the language file <myddlware>/src/Myddleware/RegleBundle/Resources/translations ($solution->field), you can add its translation here.

Now, click on Connector->Creation, then select your application, the parameters you have added in your function should be visible :


We will now develop the login function.

Était - ce   utile   ? Yes No Suggérer  de  modifier

1.3.Method login

You have to add the function login to check the connexion with you application.


Code available in the file <Myddleware>/src/Myddleware/RegleBundle/Solutions/shopapplication.php

Make sure every error is catched and this->connexion_valide = true if the connexion works.

To debug this function, you can click on the button « test ». The function will be called each time you click on « test », no need to refresh the page :


Let’s now create the first rule.

Était - ce   utile   ? Yes No Suggérer  de  modifier

1.4.Method get_modules

You have to add the module you want to connect in this method.

In input you have access to the type of connexion, if your solution is in target or in source of the rule. Some module could be available only in source or only in target.

You then return an array with a list of module :


Code available in the file <Myddleware>/src/Myddleware/RegleBundle/Solutions/shopapplication.php

Now you can check you function by creating a rule and open the module list :


Next step is the fields mapping, we now need to create a function for it.

Était - ce   utile   ? Yes No Suggérer  de  modifier

1.5.Method get_module_fields

You have to indicate to Myddleware what fields are available for each module. If your application has a function which describe all fields for every module, you should use id. For example, we did it for Salesforce or Prestashop. Otherwise you have to describe every field.

Add the function get_module_fields in you class.

Input :

  • Module indicate from which module we need the fields
  • Type indicate if the module is in source or in target in the rule

Output :

  • An array with all the fields for the module

You should then add the fields related (field available to create relationship) and the class attribute this->fieldsRelate

Your fields will then be displayed after clicking on the button « Go to fields mapping » :


Create a mapping and go to the tab « Simulation ». We will now create the function read_last.

Était - ce   utile   ? Yes No Suggérer  de  modifier

1.6.Method read_last

The function read_last is used to :

  • Get the last data in your application when the user click on « Simulation » when a rule is created
  • Search a data in you application when Myddleware search a duplicate data
  • Get the data from a specific record in you application. The goal is to create a history before Myddleware modify this record. Another goal is to check if Myddleware will change your data. If the data Myddleware will send is the same in the your application so we cancel the data transfer.

Here is an example of input value :


Query is the parameter used to search :

  • Query can have the entry « id » when Myddleware try to get a record before updating it
  • Query can have other parameters you have defined in the attribute FieldsDuplicate
  • Query can be emptied when the user click on « Simulation » during the rule creation. In this case Myddleware has to search the last record modified in your application

The function should return an array like as below :


The entry « done » could be equal to :

  • « 1 » if a data has been found
  • « 0 »if no data has been found and no error occured
  • « -1 » if an error occured

To test it, you can simulate your rule, and the data should be displayed :


Now save your rule. You should now be able to run the rule and develop the method read.

Était - ce   utile   ? Yes No Suggérer  de  modifier

1.7.Method read

You have to develop this function to read the data in your application.

Here is an example of input value :


Parameters :

  • module is the module to read in your application
  • rule contains the parameters of the rule
  • date_ref is used to search all data modified or created after this reference
  • ruleParams is the parameters of the rule
  • fields contains all values the function has to return
  • offset and limit are used only if your application has to be read with limited data
  • jobId is the if of the job
  • manual indicate if the rule is run manually
  • query can be also defined. If this parameter is defined, the read method has to return the result of the query. If it is empty, then Myddleware will user the reference date to read data.

Activate your rule. You can test you function read via the command php app/console myddleware:synchro <your rule id>

The output of the function read should look like these :


Then the function should return an array with these entries :

  • count with the number of records read. Has to be 2 if no record are read.
  • date_ref with the new date_ref. It has to be the max date found in the records read.
  • values with an array of records. The key of these entries has to be the id of the record. The entry id and date_modified has to be present for each record. Date modified contains the value of the date_created or date_modified depending the type of the rule (see the function getDateRefName).
Était - ce   utile   ? Yes No Suggérer  de  modifier

1.8.Method create

Create a rule now with your application in target. Then create the function public function create($param) in your class.

Run your rule as you did while developing the method read.

Here is an example of input value :


Parameters :

  • data contains all the record Myddleware want to create in tour application. The key of each record is the id of the data trasfer in Myddleware
  • module is the module to write in your application
  • ruleId is teh id of the rule
  • rule contains the parameters of the rule
  • ruleFields contains the fields of the rule
  • ruleParams is the parameters of the rule
  • ruleRelationships contains the relationships with the current rule
  • fieldsType contains the type of all fields in the rule
  • jobId is the if of the job

The output of the function created should look like these :


The function should then return an array with an array (key = id of the data transfer in Myddleware) for each record created.  This array has 2 entries :

  • id of the record in your application
  • error : the error message or empty if the record is successfully created
Était - ce   utile   ? Yes No Suggérer  de  modifier

1.9.Method update

The method update works in the same way as the method create. The output parameter must be built exactly like in the method create.

The only difference is that you have the entry « target_id » for each record in the array data. You will need this entry to update your data in your application.

Était - ce   utile   ? Yes No Suggérer  de  modifier

2.Create formula

In this article we‘ll look at an important point in your synchronization rules and one of the many setting options offered by Myddleware, formulas.


The fundamentals

For starters, formulas allow you to format or to set the values that will be sent to a given target field . In other words, you have the option of adding fixed text to all uppercase, change timezones, concatenate several source fields etc.


The syntaxe

To help, syntax highlighting (1) is available to you right on your text box. Furthermore you will find below, the list of source fields that you have chosen (2), the available functions and their categories (3) and one or two drop list(s) (4) of the different values for the list type fields (as SalutationID example).



– Concatenate multiple fields, Myddleware uses the « . » as in PHP {field1}.{field2}.{fields3}

– Concatenate a fixed text with one or multiple fields « Client Name: « .{Firstname}. » « .{Lastname}

Three-valued condition , « If the Greeting field is ‘Mr.’ then send 1, otherwise send 2 » is written as followed : (({Greeting} == « Mr. ») ? « 1 » : « 2 »), those three-valued conditions can be nested in order, for example, to make the data correspond. Thus, ({resolution} == « 10 » ? « Open » : ({resolution} == « 20 » ? « Fixed » : ({resolution} == « 30 » ? « Reopened » : « Suspended »))) is correct and functional, this formula means « If resolution is 10 then ‘Open’ is sent, otherwise if resolution is 20 then ‘Fixedis sent, otherwise if resolution is 30 then Reopened’ is sent, otherwise Suspended ‘ is sent.

– Add two fileds {field1} + {field2}




In the formula of Myddleware, you can use the functions listed at the bottom right (see (3) of the previous image).


round(numbre [, clarification)(PHP) Ex: round(525.6352, 2) // Gives 525.64

This function round floating point (up).


ceil(float)(PHP) Ex: ceil(525.6352) // gives 526

Rounds up.


abs(number)(PHP) Ex: abs(-5) // gives 5

Returns the absolute value.


trim(string [, Masque])(PHP) Ex: trim( » bonjour « ) returns « bonjour »

Deletes spaces (or other charachters) at the begenning and the end of a string.


lower(STRING)(PHP) Ex: lower(« BONJOUR ») returns « bonjour »

Lowercases all charachters.


upper(Strin)(PHP) Ex: upper(« bonjour ») returns « BONJOUR »

Uppercases all charachters.


date(Format [, Timestamp])(PHP) Ex: date(« Y:m:d ») returns « 2014:09:16 »

Formats a local date/hour.


microtime([true if you want a float result])(PHP) Ex: microtime(true) returns 1410338028.5745

Returns current Unix timestamp with microseconds.


changeTimeZone(Date you want to change, old timezone, new timezone)(PHP) Ex: changeTimeZone(« 2014-09-16 12:00:00 », « America/Denver », « America/New_York ») returns « 2014-09-16 14:00:00 »

Changes the timezone of the given date.


changeFormatDate(Date you want to change, New format) Ex: changeTimeZone(« 2014-09-16 12:00:00 », « Y/m/d H:i:s ») returns « 2014/09/16 12:00:00 »

Changes the format of the given date.


substr(String, Index)(PHP) Ex: substr(« abcdef », -1) returns « f »

Reads a string starting of the given Index.


striptags(String)(PHP) Ex: striptags(« <p>Test paragraph.</p><!– Comment –> <a href= »#fragment »>Other text</a> ») returns « Test paragraph. Other text »

Strips HTML and PHP tags from a string.


Était - ce   utile   ? Yes No Suggérer  de  modifier
Suggérer  de  modifier