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
-
Make a note of the returned values of the
getSystem()
andgetName()
methods, and then delete these methods from the class. -
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' }
-
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 assha1($this->getName())
.noteIf 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 ashttp://www.sha1-online.com/
and copy the result. -
Add another entry under the
tags
section of the YAML file, replacingidentifier
with the value ofgetGUID()
:- { name: xfp.rule_action, alias: 'identifier' }
-
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
-
Make a note of the returned values of the
getName()
andgetGUID()
methods, and then delete these from the class.noteIf the
getGUID()
method calls thesha1()
function, this will need to be evaluated to a hash value. To do this, use a tool such ashttp://www.sha1-online.com/
and copy the result. -
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 ofgetGUID()
.
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
-
Make a note of the returned values of the
getName()
,getIcon()
andgetGUID()
methods, and then delete these from the class.noteIf the
getGUID()
method calls thesha1()
function, this will need to be evaluated to a hash value. To do this, use a tool such ashttp://www.sha1-online.com/
and copy the result. -
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 ofgetGUID()
.
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
-
Make a note of the returned values of the
getName()
method, and then delete this method from the class. -
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' }
-
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 assha1($this->getName())
.noteIf 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 ashttp://www.sha1-online.com/
and copy the result. -
Add another entry under the
tags
section of the YAML file, replacingidentifier
with the value ofgetGUID()
:- { name: xfp.form_variable_definition, alias: 'identifier' }
-
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