Ferreteria/v0.5/registry/feature

From Woozle Writes Code
< Ferreteria‎ | v0.5‎ | registry
Revision as of 15:01, 8 March 2022 by htyp>Woozle
Jump to navigation Jump to search

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().