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 revisionNext revisionBoth sides next revision | ||
development:code_generators [2017/08/02 16:15] – demiankatz | development:code_generators [2023/11/09 21:14] – demiankatz | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Code Generators ====== | ====== Code Generators ====== | ||
- | Starting with VuFind | + | Starting with VuFind® |
===== 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 48: | Line 48: | ||
</ | </ | ||
- | ===== Overriding Existing Plugins and Services ===== | ||
- | If you want to extend one of VuFind's built-in plugins or services, you can use the ' | + | ===== Creating Theme Mix-ins ===== |
+ | |||
+ | Starting with VuFind® 4.1, a generator is available to create an example [[development: | ||
+ | |||
+ | ==== Usage ==== | ||
+ | <code bash> | ||
+ | cd $VUFIND_HOME | ||
+ | php public/ | ||
+ | </ | ||
+ | |||
+ | ===== Overriding Existing Plugins and Services (VuFind® 4.x and earlier) ===== | ||
+ | |||
+ | If you want to extend one of VuFind®'s built-in plugins or services, you can use the ' | ||
+ | |||
+ | :!: Starting with VuFind® 5.0, the ' | ||
==== Usage ==== | ==== Usage ==== | ||
Line 59: | Line 72: | ||
</ | </ | ||
- | * 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 71: | Line 84: | ||
==== 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 102: | Line 115: | ||
Successfully updated / | Successfully updated / | ||
</ | </ | ||
+ | |||
+ | ===== Overriding Existing Plugins and Services (VuFind® 5.0 and later) ===== | ||
+ | |||
+ | If you want to extend one of VuFind®' | ||
+ | |||
+ | ==== 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 / | ||
+ | </ | ||
+ | |||
+ | ===== Creating New Plugins ===== | ||
+ | |||
+ | :!: This feature was introduced in VuFind® 5.1. | ||
+ | |||
+ | If you want to create a new [[development: | ||
+ | |||
+ | ==== Usage ==== | ||
+ | |||
+ | <code bash> | ||
+ | cd $VUFIND_HOME | ||
+ | php public/ | ||
+ | </ | ||
+ | |||
+ | * 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, | ||
+ | |||
+ | ==== 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 want to create a new ILS driver for your home-grown system. You could begin like this: | ||
+ | |||
+ | <code bash> | ||
+ | cd $VUFIND_HOME | ||
+ | php public/ | ||
+ | </ | ||
+ | |||
+ | The output should look something like this: | ||
+ | |||
+ | < | ||
+ | Saved file: / | ||
+ | Saved file: / | ||
+ | Created backup: / | ||
+ | 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