Warning: This page has not been updated in over over a year and may be outdated or deprecated.
development:code_generators
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
development:code_generators [2020/03/04 13:41] – [Creating Routes] demiankatz | development:code_generators [2023/11/09 21:18] – demiankatz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Code Generators ====== | ====== Code Generators ====== | ||
- | Starting with VuFind 2.4, command | + | Command |
===== Creating Routes ===== | ===== Creating Routes ===== | ||
- | Adding new entries to the router configuration can involve tedious array creation, so VuFind | + | Adding new entries to the router configuration can involve tedious array creation, so VuFind® |
==== Static Routes ==== | ==== Static Routes ==== | ||
Line 40: | Line 40: | ||
===== Creating Themes ===== | ===== Creating Themes ===== | ||
- | Starting with VuFind | + | Starting with VuFind® |
==== Usage ==== | ==== Usage ==== | ||
Line 51: | Line 51: | ||
===== Creating Theme Mix-ins ===== | ===== Creating Theme Mix-ins ===== | ||
- | Starting with VuFind | + | Starting with VuFind® |
==== Usage ==== | ==== Usage ==== | ||
Line 59: | Line 59: | ||
</ | </ | ||
- | ===== Overriding Existing Plugins and Services | + | ===== Overriding Existing Plugins and Services ===== |
- | If you want to extend one of VuFind' | + | ==== extendclass ==== |
- | :!: Starting with VuFind 5.0, the ' | + | If you want to extend one of VuFind®' |
- | ==== Usage ==== | + | === Usage === |
<code bash> | <code bash> | ||
cd $VUFIND_HOME | cd $VUFIND_HOME | ||
- | php public/ | + | php public/ |
</ | </ | ||
- | * path/ | + | * --extendfactory |
+ | * Fully\\Qualified\\ClassName is the name of the class you wish to extend/ | ||
* MyModule is the name of your local module where you wish to create a new class. | * MyModule is the name of your local module where you wish to create a new class. | ||
- | ==== Notes ==== | + | === Notes === |
- | :!: Be sure that MyModule already exists and is included in your VUFIND_LOCAL_MODULES environment variable, or the generator may not work correctly. If MyModule does not yet exist, you can re-run | + | :!: Be sure that MyModule already exists and is included in your VUFIND_LOCAL_MODULES environment variable, or the generator may not work correctly. If MyModule does not yet exist, you can re-run |
:!: If things don't work right away after generating code, you may need to clear your local/cache directory to get rid of outdated configurations. | :!: If things don't work right away after generating code, you may need to clear your local/cache directory to get rid of outdated configurations. | ||
- | :!: Don't forget to escape backslashes in service names within the path/ | + | === Example === |
- | ==== Example ==== | + | Suppose you wish to create a custom subclass of VuFind®'s SolrMarc record driver. The command to generate a custom extension of the default class is: |
- | + | ||
- | Suppose you wish to create a custom subclass of VuFind's SolrMarc record driver. | + | |
- | + | ||
- | <code php> | + | |
- | $config = array( | + | |
- | ' | + | |
- | ... | + | |
- | ' | + | |
- | ... | + | |
- | ' | + | |
- | ... | + | |
- | ' | + | |
- | ... | + | |
- | ' | + | |
- | </ | + | |
- | + | ||
- | The path to this service would be vufind/ | + | |
<code bash> | <code bash> | ||
cd $VUFIND_HOME | cd $VUFIND_HOME | ||
- | php public/ | + | php public/ |
</ | </ | ||
Line 109: | Line 93: | ||
< | < | ||
- | Saved file: / | ||
Saved file: / | Saved file: / | ||
+ | Saved file: / | ||
Saved file: / | Saved file: / | ||
Created backup: / | Created backup: / | ||
+ | Successfully updated / | ||
Successfully updated / | Successfully updated / | ||
</ | </ | ||
- | ===== Overriding Existing Plugins and Services (VuFind 5.0 and later) ===== | + | ==== extendservice |
- | If you want to extend one of VuFind' | + | You can also use the 'extendservice' generator to create a new subclass and automatically configure your local module to use it. It is recommended that you use ' |
- | ==== Usage ==== | + | === Usage === |
<code bash> | <code bash> | ||
cd $VUFIND_HOME | cd $VUFIND_HOME | ||
- | php public/ | + | php public/ |
</ | </ | ||
- | * --extendfactory | + | * path/ |
- | * Fully\\Qualified\\ClassName is the name of the class you wish to extend/ | + | |
* MyModule is the name of your local module where you wish to create a new class. | * MyModule is the name of your local module where you wish to create a new class. | ||
- | ==== Notes ==== | + | === Notes === |
- | :!: Be sure that MyModule already exists and is included in your VUFIND_LOCAL_MODULES environment variable, or the generator may not work correctly. If MyModule does not yet exist, you can re-run | + | :!: Be sure that MyModule already exists and is included in your VUFIND_LOCAL_MODULES environment variable, or the generator may not work correctly. If MyModule does not yet exist, you can re-run |
:!: If things don't work right away after generating code, you may need to clear your local/cache directory to get rid of outdated configurations. | :!: If things don't work right away after generating code, you may need to clear your local/cache directory to get rid of outdated configurations. | ||
- | ==== Example ==== | + | :!: Don't forget to escape backslashes in service names within the path/ |
- | Suppose you wish to create a custom subclass of VuFind's SolrMarc record driver. The command to generate a custom extension of the default class is: | + | === Example === |
+ | |||
+ | Suppose you wish to create a custom subclass of VuFind®'s SolrMarc record driver. | ||
+ | |||
+ | <code php> | ||
+ | $config = array( | ||
+ | ' | ||
+ | ... | ||
+ | ' | ||
+ | ... | ||
+ | ' | ||
+ | ... | ||
+ | ' | ||
+ | ... | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | The path to this service would be vufind/ | ||
<code bash> | <code bash> | ||
cd $VUFIND_HOME | cd $VUFIND_HOME | ||
- | php public/ | + | php public/ |
</ | </ | ||
Line 148: | Line 149: | ||
< | < | ||
+ | Saved file: / | ||
Saved file: / | Saved file: / | ||
- | Saved file: / | ||
Saved file: / | Saved file: / | ||
Created backup: / | Created backup: / | ||
- | Successfully updated / | ||
Successfully updated / | Successfully updated / | ||
</ | </ | ||
Line 158: | Line 158: | ||
===== Creating New Plugins ===== | ===== Creating New Plugins ===== | ||
- | :!: This feature was introduced in VuFind | + | :!: This feature was introduced in VuFind® |
- | If you want to create a new [[development: | + | If you want to create a new [[development: |
==== Usage ==== | ==== Usage ==== | ||
Line 169: | Line 169: | ||
</ | </ | ||
- | * MyModule\\PluginType\\PluginName is the name of the class you wish to create. The generator will use the first part of the class name to determine which module it belongs in (since modules correspond to namespaces); | + | * MyModule\\PluginType\\PluginName is the name of the class you wish to create. The generator will use the first part of the class name to determine which module it belongs in (since modules correspond to namespaces); |
* [optional factory name] may be included to specify the name of an existing factory that should be used to construct your plugin. For example, if your class will not have any dependencies, | * [optional factory name] may be included to specify the name of an existing factory that should be used to construct your plugin. For example, if your class will not have any dependencies, | ||
==== Notes ==== | ==== Notes ==== | ||
- | :!: Be sure that MyModule already exists and is included in your VUFIND_LOCAL_MODULES environment variable, or the generator may not work correctly. If MyModule does not yet exist, you can re-run | + | :!: Be sure that MyModule already exists and is included in your VUFIND_LOCAL_MODULES environment variable, or the generator may not work correctly. If MyModule does not yet exist, you can re-run |
:!: If things don't work right away after generating code, you may need to clear your local/cache directory to get rid of outdated configurations. | :!: If things don't work right away after generating code, you may need to clear your local/cache directory to get rid of outdated configurations. | ||
Line 195: | Line 195: | ||
Successfully updated / | Successfully updated / | ||
</ | </ | ||
+ | |||
+ | ===== Related Video ===== | ||
+ | |||
+ | See the [[videos: | ||
---- struct data ---- | ---- struct data ---- | ||
+ | properties.Page Owner : | ||
---- | ---- | ||
development/code_generators.txt · Last modified: 2023/11/09 21:19 by demiankatz