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 revision | ||
development:code_generators [2018/02/07 20:53] – demiankatz | development:code_generators [2023/11/09 21:19] (current) – [extendservice] 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 Zend Framework | + | Adding new entries to the router |
==== 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> | ||
+ | cd $VUFIND_HOME | ||
+ | php public/ | ||
+ | </ | ||
+ | |||
+ | * --extendfactory is a switch which will cause the existing factory method to be cloned into your local module. If you omit the switch, the existing factory will be used. :!: Using the existing factory only makes sense for factories that dynamically determine the name of the constructed object using the service name; however, a significant number of VuFind® services use this type of factory starting in release 5.0. | ||
+ | * 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. | ||
+ | |||
+ | === 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 VuFind®' | ||
+ | |||
+ | :!: 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 === | ||
+ | |||
+ | Suppose you wish to create a custom subclass of VuFind®' | ||
+ | |||
+ | <code bash> | ||
+ | cd $VUFIND_HOME | ||
+ | php public/ | ||
+ | </ | ||
+ | |||
+ | The output should look something like this: | ||
+ | |||
+ | < | ||
+ | Saved file: / | ||
+ | Saved file: / | ||
+ | Saved file: / | ||
+ | Created backup: / | ||
+ | Successfully updated / | ||
+ | Successfully updated / | ||
+ | </ | ||
+ | |||
+ | ==== extendservice ==== | ||
+ | |||
+ | You can also use the ' | ||
+ | |||
+ | === Usage === | ||
<code bash> | <code bash> | ||
Line 72: | Line 112: | ||
</ | </ | ||
- | * path/ | + | * path/ |
* 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. | ||
Line 82: | Line 122: | ||
:!: Don't forget to escape backslashes in service names within the path/ | :!: 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. You can see in module/ | + | Suppose you wish to create a custom subclass of VuFind®'s SolrMarc record driver. You can see in module/ |
<code php> | <code php> | ||
Line 116: | Line 156: | ||
</ | </ | ||
- | ===== Overriding Existing | + | ===== Creating New Plugins ===== |
- | If you want to extend one of VuFind' | + | :!: This feature was introduced in VuFind® 5.1. |
+ | |||
+ | If you want to create a new [[development: | ||
==== Usage ==== | ==== Usage ==== | ||
Line 124: | Line 166: | ||
<code bash> | <code bash> | ||
cd $VUFIND_HOME | cd $VUFIND_HOME | ||
- | php public/ | + | php public/ |
</ | </ | ||
- | * --extendfactory | + | * MyModule\\PluginType\\PluginName |
- | * Fully\\Qualified\\ClassName is the name of the class you wish to extend/ | + | * [optional factory name] may be included to specify |
- | * 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. | ||
Line 138: | Line 179: | ||
==== Example ==== | ==== Example ==== | ||
- | Suppose you wish to create a custom subclass of VuFind' | + | Suppose you want to create a new ILS driver |
<code bash> | <code bash> | ||
cd $VUFIND_HOME | cd $VUFIND_HOME | ||
- | php public/ | + | php public/ |
</ | </ | ||
Line 148: | Line 189: | ||
< | < | ||
- | Saved file: /.../ | + | Saved file: /home/ |
- | Saved file: /.../module/MyModule/ | + | Saved file: /home/dkatz/vufind3/ |
- | Saved file: /.../ | + | Created backup: /home/ |
- | Created backup: /.../ | + | Successfully updated /home/ |
- | Successfully updated /.../ | + | Successfully updated /home/ |
- | Successfully updated /.../ | + | |
</ | </ | ||
+ | |||
+ | ===== Related Video ===== | ||
+ | |||
+ | See the [[videos: | ||
---- struct data ---- | ---- struct data ---- | ||
+ | properties.Page Owner : | ||
---- | ---- | ||
development/code_generators.1518036796.txt.gz · Last modified: 2018/02/07 20:53 by demiankatz