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 [2023/11/09 21:14] – 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 ===== | ||
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® | + | If you want to extend one of VuFind®'s built-in plugins or services, you can use the ' |
- | ==== 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 VuFind®' | :!: 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. | :!: 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®' |
- | + | ||
- | Suppose you wish to create a custom subclass of VuFind®' | + | |
- | + | ||
- | <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 VuFind®' | :!: 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. | :!: 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®' | + | === Example === |
+ | |||
+ | Suppose you wish to create a custom subclass of VuFind®' | ||
+ | |||
+ | <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 / | ||
</ | </ |
development/code_generators.1699564483.txt.gz · Last modified: 2023/11/09 21:14 by demiankatz