Ferreteria/v0.5/registry/feature: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
(Created page with "==Feature registration== Feature registration (incomplete) from /login/base/stocker.php: <syntaxhighlight lang=php> class csStocker extends FD\csaStocker { static public f...")
 
No edit summary
Line 1: Line 1:
==Feature registration==
==Feature registration==
Feature registration (incomplete) from /login/base/stocker.php:
{{l/ver|Feature}} registration (incomplete) from /login/base/stocker.php:
<syntaxhighlight lang=php>
<syntaxhighlight lang=php>
class csStocker extends FD\csaStocker {
class csStocker extends FD\csaStocker {
     static public function OnPreLoad() {
     static public function OnSetup() {
         $oReg = caFeature::FeatureClassRegistry();
         $oReg = caFeature::FeatureClassRegistry();
         $oReg->AddFeature(account\cFeature::class);
         $oReg->AddFeature(account\cFeature::class);
Line 23: Line 23:
}
}
</syntaxhighlight>
</syntaxhighlight>
The <code>OnSetup</code> method shows how Features can be registered manually -- though in this case it's actually redundant/unnecessary because they are automatically registered by the {{l/ver|Dropin}}-loading process. (This OnSetup() method ended up being removed from the codebase.)
For an example of how the Registry is read from, see <code>cDropinLink::InvokeFeature()</code>.

Revision as of 15:01, 8 March 2022

Feature registration

Feature registration (incomplete) from /login/base/stocker.php:

class csStocker extends FD\csaStocker {
    static public function OnSetup() {
        $oReg = caFeature::FeatureClassRegistry();
        $oReg->AddFeature(account\cFeature::class);
        $oReg->AddFeature(client\cFeature::class);
        $oReg->AddFeature(session\cFeature::class);
        // IN PROGRESS
    }
 
    static public function Accounts()      : caFeature { return self::FetchFeature(account\cFeature::SpecSlug()); }
    static public function AcctXGroup()    : caFeature { return self::FetchFeature(ctGroupsForAcct::SpecSlug()); }
    static public function Clients()       : caFeature { return self::FetchFeature(client\cFeature::SpecSlug()); }
    static public function Groups()        : caFeature { return self::FetchFeature(ctGroups::SpecSlug()); }
    static public function Permits()       : caFeature { return self::FetchFeature(ctPermits::SpecSlug()); }
    static public function PermitsQuery()  : caFeature { return self::FetchFeature(cqtPermits::SpecSlug()); }
    static public function Sessions()      : caFeature { return self::FetchFeature(session\cFeature::SpecSlug()); }
    
    static public function AccountsFetcher() : FD\cSelectFetcher {
      return self::MakeObject(account\cFetcher::class); }
}

The OnSetup method shows how Features can be registered manually -- though in this case it's actually redundant/unnecessary because they are automatically registered by the Dropin-loading process. (This OnSetup() method ended up being removed from the codebase.)

For an example of how the Registry is read from, see cDropinLink::InvokeFeature().