I believe both Resolvers and Validators run at the point they are added to the package (and my book is wrong on this point). I've been bitten by putting a resolver too early in the package and not having other objects created later in the package available at that point.
I could be wrong, but I don't think there's any real difference between Resolvers and Validators except that Validators have the option to abort the installation.
By convention, Validators are used early on to check for necessary conditions (e.g., the existence of other extras, GD lib support, etc.), and Resolvers are used to do finishing-up operations like connecting TVs to templates, but I suspect that if you put a Validator at the end of the package and used it as a Resolver, it would work fine as long as it returned true.
@ben.duffin I agree that the Doodles tutorial is the last thing you want to see when first learning to create a transport package (though it has a lot of useful information about how to organize the files).
You've probably seen the MyComponent Tutorial at Bob's Guides, but if you can wait a bit, the new version of MyComponent will be out which is infinitely superior and much easier to use, IMO.
There's a pre-alpha version of it here:
https://github.com/BobRay/MyComponent/tree/dev. Unfortunately there's no tutorial or documentation for it other than the comments in the example config file. It does work, however.
At present, it's set up to create the 'Example' extra. You could probably learn a lot by playing with it, because the output tells you everything it's doing. It's designed to run outside of MODX.
To create the Example extra:
1. Download to assets/components/mycomponent/
2. Run
assets/mycomponents/mycomponent/core/components/mycomponent/elements/snippets/bootstrap.php
3. The new extra will be in assets/mycomponents/example/
4. You'll see a bunch of stuff in the Example category in MODX and some new resources (resource1, etc.)
5. You'll see the build files in assets/mycomponents/example/_build
6. What it does is completely controlled by the project config file:
assets/components/mycomponent/_build/utilities/config/example.config.php
7. If you make changes to any of the objects in MODX and run:
assets/mycomponents/mycomponent/core/components/mycomponent/elements/snippets/exportobjects.php, the build files will be updated
8. You can run assets/mycomponents/example/_build/build.transport.php at any point after running bootstrap and it will create a new transport package in core/packages. If you go to Package Manager and select "Search Locally for Packages", you can see it in the grid and install, uninstall, or remove it.
Things are still moving around and those MyComponent paths will be incorrect soon (I think the whole of MyComponent will be moved to the core/components/mycomponent/ directory, where it would normally install).
Bootstrap and exportobjects can be run over and over. Bootstrap is completely non-destructive and won't touch any existing objects or files (but will create new ones if you put them in the project config file).
ExportObjects will rewrite the element files to match what you've done in MODX and also the build files.
build.transport.php can be run at any time to update the transport package in core/packages.
LexiconHelper will create, update, and check your lexicon files, and there are some other utilities as well, but I've probably already told you more than you want to know.
Confession: I have never created a Doodle or even done step one of the Doodles Tutorial.
One last point: Most of what I've learned about building transport packages, I learned here
https://github.com/splittingred and I still refer to it all the time.
One more last point: The hardest thing about package building is to get things connected properly. Installing the objects is quite easy once you get the hang of it, but connecting TVs to Templates, Plugins to Plugin Events, Property Sets to Elements, Resources to Templates, Elements to Categories, Actions to Menus, etc. can take a while to get a handle on. The new MyComponent will do all of that for you.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
[ed. note: BobRay last edited this post 14 years ago.]