Skip to main content

Improving performance of custom extensions

Most extension points for Form Builder require defining a class, and adding config into CustomXFormsProBundle/Resources/config/services.yml to register this class with Jadu Central.

It is possible to improve performance of custom extensions by defining their metadata in the CustomXFormsProBundle/Resources/config/services.yml YAML file, rather than in the class itself. This allows Jadu Central to 'lazy load' custom classes, and only instantiate them fully when they are required.

Custom classes which still define the metadata methods will continue to work, but will be unable to take advantage of the performance benefits of lazy loading.

Updating a custom extension to take advantage of lazy loading

The changes required differ for each extension point. See the relevant section below.

Custom Actions

  1. Make a note of the returned values of the getSystem() and getName() methods, and then delete these methods from the class.

  2. Update the action's config in CustomXFormsProBundle/Resources/config/services.yml. Change:

       - { name: xfp.rule_action }

    to:

       - { name: xfp.rule_action, system: 'system', label: 'name' }
  3. Check if the class defines its own identifier by implementing the getGUID() method. If it does, make a note of the value. If not, the identifier for the class is the same as sha1($this->getName()).

    note

    If the identifier comes from a call to the sha1() function, this will need to be evaluated to a hash value. To do this, use a tool such as http://www.sha1-online.com/ and copy the result.

  4. Add another entry under the tags section of the YAML file, replacing identifier with the value of getGUID():

       - { name: xfp.rule_action, alias: 'identifier' }
  5. Delete the getGUID() method if it is defined.

Example

From this guide, the worked example for creating an action has the following YAML config:

services:
custom_xfp.rules.action.receipting_system:
class: Jadu\Custom\CustomXFormsProBundle\Rules\Actions\ReceiptingSystemActionType
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: xfp.rule_action }

and the following metadata methods:

    public function getName()
{
return 'Submit Data';
}

public function getSystem()
{
return 'ReceiptingSystem';
}

This would now become:

services:
custom_xfp.rules.action.receipting_system:
class: Jadu\Custom\CustomXFormsProBundle\Rules\Actions\ReceiptingSystemActionType
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: xfp.rule_action, system: 'ReceiptingSystem', label: 'Submit Data' }
- { name: xfp.rule_action, alias: '173bc10e2f2eecc0d82983368c409491a27d68d4' }

Custom Integrated Components

  1. Make a note of the returned values of the getName() and getGUID() methods, and then delete these from the class.

    note

    If the getGUID() method calls the sha1() function, this will need to be evaluated to a hash value. To do this, use a tool such as http://www.sha1-online.com/ and copy the result.

  2. Update the integrated component's config in CustomXFormsProBundle/Resources/config/services.yml. Change:

       - { name: xfp.integrated_component }

    to:

       - { name: xfp.integrated_component, label: 'name' }
    - { name: xfp.integrated_component, alias: 'identifier' }

    replacing identifier with the value of getGUID().

Example

From this guide, the worked example for creating an integrated component has the following YAML config:

services:
custom_xfp.integrated_component.address_service_postcode:
class: Jadu\Custom\CustomXFormsProBundle\IntegratedComponent\AddressServicePostcodeLookup
arguments:
- "@xfp_core.form.component_repository"
tags:
- { name: xfp.integrated_component }

and the following metadata methods:

    public function getGUID()
{
return sha1('AddressServicePostcodeLookup');
}

public function getName()
{
return 'Verified Address - AddressService Postcode Search';
}

This would now become:

services:
custom_xfp.integrated_component.address_service_postcode:
class: Jadu\Custom\CustomXFormsProBundle\IntegratedComponent\AddressServicePostcodeLookup
arguments:
- "@xfp_core.form.component_repository"
tags:
- { name: xfp.integrated_component, label: 'Verified Address - AddressService Postcode Search' }
- { name: xfp.integrated_component, alias: 'eb7b69b292ffbc5d07779bd4966332dbbe65540a' }

Custom Components

  1. Make a note of the returned values of the getName(), getIcon() and getGUID() methods, and then delete these from the class.

    note

    If the getGUID() method calls the sha1() function, this will need to be evaluated to a hash value. To do this, use a tool such as http://www.sha1-online.com/ and copy the result.

  2. Update the component's config in CustomXFormsProBundle/Resources/config/services.yml. Change:

       - { name: xfp.form_component }

    to:

       - { name: xfp.form_component, label: 'name', icon: 'icon' }
    - { name: xfp.form_component, alias: 'identifier' }

    replacing identifier with the value of getGUID().

Example

From this guide, the worked example for creating a component has the following YAML config:

services:
custom_xfp.component.number_field:
class: CustomXFormsProBundle\Component\NumberFieldComponent
arguments:
- "@custom_xfp.component.number_field_service"
- "@custom_xfp.component.number_field_settings_service"
tags:
- { name: xfp.form_component }

and the following metadata methods:

    public function getGUID()
{
return sha1('NumberFieldComponent');
}

public function getName()
{
return 'Number Field';
}

public function getIcon()
{
return 'icon-number';
}

This would now become:

services:
custom_xfp.component.number_field:
class: CustomXFormsProBundle\Component\NumberFieldComponent
arguments:
- "@custom_xfp.component.number_field_service"
- "@custom_xfp.component.number_field_settings_service"
tags:
- { name: xfp.form_component, label: 'Number Field', icon: 'icon-number' }
- { name: xfp.form_component, alias: 'a6b86d938b6d226dfe9310da56ccaa59ebec453c' }

Custom Variables

  1. Make a note of the returned values of the getName() method, and then delete this method from the class.

  2. Update the variable's config in CustomXFormsProBundle/Resources/config/services.yml. Change:

       - { name: xfp.form_variable_definition }

    to:

       - { name: xfp.form_variable_definition, label: 'name' }
  3. Check if the class defines its own identifier by implementing the getGUID() method. If it does, make a note of the value. If not, the identifier for the class is the same as sha1($this->getName()).

    note

    If the identifier comes from a call to the sha1() function, this will need to be evaluated to a hash value. To do this, use a tool such as http://www.sha1-online.com/ and copy the result.

  4. Add another entry under the tags section of the YAML file, replacing identifier with the value of getGUID():

       - { name: xfp.form_variable_definition, alias: 'identifier' }
  5. Delete the getGUID() method if it is defined.

Example

From this guide, the worked example for creating a variable has the following YAML config:

services:
custom_xfp.component.number_field:
class: CustomXFormsProBundle\Component\NumberFieldComponent
arguments:
- "@custom_xfp.component.number_field_service"
- "@custom_xfp.component.number_field_settings_service"
tags:
- { name: xfp.form_component }

and the following metadata method:

    public function getName()
{
return 'Custom - ReceiptingSystemReference';
}

This would now become:

services:
custom_xfp.variables.receipting_system_reference:
class: Jadu\Custom\CustomXFormsProBundle\VariableDefinitions\ReceiptingSystemReferenceDefinition
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: xfp.form_variable_definition, label: 'Custom - ReceiptingSystemReference' }
- { name: xfp.form_variable_definition, alias: '6a2bf07cba4694e1193e1d849533aa4f0a984df6' }

Other Extension Points

If the custom extension is in the list below, lazy loading is not applicable and there is no need to make any changes.

  • Custom Predefined Logic
  • Custom Received Forms Plugins
  • Custom Dictionary Extensions
  • Custom File Output Connectors