Table of Contents
Joomla Component Builder (JCB), has super powers. Which is another way of saying it now allows for powers to be pulled in from a global array of areas, over which you have full control. This allows for easy sharing of your powers between your JCB instances with your own power repositories on https://git.vdm.dev/[username]/my-powers. While at the same time be able to use the JCB core powers where needed.
Let's explain: This feature called super-powers, manages powers by use of layers, events, tasks, methods, switches, and algorithms that all work in combination of different ways to achieve super powers.
The [powers] are:
- [guid] => Each power has a global unique identifier used to control the power global identity. This [power:guid] looks like this: b836c1b1-b6b1-44f7-b8a2-9a763a4185b1
- [code] => The actual code of the power that is found in a PHP file
- [settings] => The settings define the power details, relationships, and more. They are stored in a Json formatted file in [layer:repo] and/or [layer:local] and/or as column values in the [layer:database]
The [layers] are:
- [database] This JCB instance's Database
- [repo] The https://git.vdm.dev/ git website that holds all repos, and which is managed by Vast Development Method
- [core] The core super-power repo of JCB https://git.vdm.dev/joomla/super-powers
- [own] Your own super-powers repos https://git.vdm.dev/[username]/my-powers (sub-paths)
- [local] Local path, and its sub-paths that hold [core] and [own] repositories.
The [events] are:
- [compile] Compilation of a component
- [sync] Synchronisation of selected powers with [algorithm:cascading]
- [init] Uploads all powers from all active [layers] into [layer:database] if not already exist in [layer:database]
- [reset] Force synchronisation of selected powers with [layer:core]
The [tasks] are:
- [get] To get powers from any of the layers
- [set] To set powers to database or local paths
The [methods] are:
- [auto] When JCB automatically does this for you
- [manual] When you must manually do something
The [switches] are:
- [activate] This switch activates super-powers, and allows for [layer:local] path to be set
- [token] This is the VDM access token from the global tab.
- [super] This switch allows for [layer:own] paths to be set
- [approved] This switch allows a power to be added to a [layer:core] or [layer:own] paths
The [algorithms] are:
- [cascading] The is the way in which JCB [task:get] a power during the [events] so that it can use the power in your component, and store in [layer:database]
These terminologies and ideas are what you need to remember whenever you read any of the comments and other information about super-powers in JCB.
JCB uses powers as the foundation of all it builds. You can build things with JCB without knowing how to use or work with powers. But JCB cannot build anything without powers. That means JCB needs to load powers from the [layer:core] and usually will do this whenever an [event] is triggered based on the [algorithm:cascading].
All these events can possibly move powers into your [layer:database]. These [events] have the [method:auto] behaviour, and therefore we make use of the [algorithm:cascading] that allows for overriding any power in any way you like. Beware that divergence from the core powers may have side effects and therefore should only be done with knowledge and full understanding on your part.
Let's Explain the [algorithm:cascading] During [events] we must [auto] load powers, and so there is a search path for each event.
The [event:compile] when building your component, here is the [algorithm:cascading]:
- [layer:database]
- [layer:local IF switch:activate AND switch:approved]
- [layer:own IF switch:token AND switch:activate AND switch:super AND switch:approved]
- [layer:core]
This means, that if JCB gets a [power:guid] in the [layer:database] it stops the search and uses that found power. But if not, it will continue until it finds the power, or it will show an error that the power could not be found. Once it finds the power, it will make sure that the power is in [layer:database], and if [layer:local] is active, it will update those as well as determined by the approved path selection of each power.
The [event:sync] when the sync button is clicked, here is the [algorithm:cascading]:
- [layer:own IF switch:token AND switch:activate AND switch:super AND switch:approved]
- [layer:local IF switch:activate AND switch:approved]
- [layer:core]
This means, that if JCB gets a [power:guid] in any of the targeted [layer:own] it stops the search for that power at the first instance it finds that power. Then JCB will update your [layer:database] with the found power, irrespective of modify or creation date. The [power:guid] is used as the key, and should JCB therefore have a power in any of your [layer:own] it will override the [layer:core] and [layer:local] version of any power, and update the [layer:database].
The [event:reset] when the reset button is clicked, will update [layer:database] with [layer:core] version of the selected powers if found in [layer:core], irrespective of modify or creation date.
The [event:init] when the init button is clicked, will initialise [layer:database] with all [layers] powers not found in [layer:database]. Should you have the same power in multiple of the layers, here is the [algorithm:cascading]:
- [layer:own IF switch:token AND switch:activate AND switch:super AND switch:approved]
- [layer:local IF switch:activate]
- [layer:core IF_NOT layer:database]
This means, that if JCB gets a [power:guid] in any of the targeted [layer:own] it will not use any of the other [layers] versions. JCB will add this first found power to your [layer:database] unless it's already in [layer:database], in which case it will be ignored. Use [event:sync] or [event:reset] should you like to update [layer:database] existing powers.
In JCB you can add your own repositories.
Add the paths to those repositories you would like to target with this instance of JCB.
You only need to add the path, so if your repository is located here: https://git.vdm.dev/Llewellyn/workshop.
Then the path will be: Llewellyn/workshop
The powers repository local path is where [layer:core] and all [layer:own] powers are placed. So you can with git add your powers to your own profile on https://git.vdm.dev/[username]/power for easy reuse between projects.
Here you can set the path to the super powers local repository folder, where all targeted [layer:own] sub paths will be placed with their selective [switch:approved] powers.
You can set a local path as well.
The powers repository local path is where all powers are placed. So you can with git add your powers to your own profile on https://git.vdm.dev/[username]/power for easy reuse between projects.
To start using these features, open you JCB 3.1.21+ instance global Options and look for the Super Powers tab.