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

From Woozle Writes Code
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
==Feature registration==
==Feature registration==
{{l/ver|Feature}} registration (incomplete) from /login/base/stocker.php:
{{l/ver|Feature}} registration for non-{{l/ver|Dropin}} classes from {{l/ferreteria/code|config/portable/features.php}}:
<syntaxhighlight lang=php>
<syntaxhighlight lang=php>
class csStocker extends FD\csaStocker {
class csSetup {
     static public function OnSetup() {
     static public function OnSetup() {
         $oReg = caFeature::FeatureClassRegistry();
         $oReg = FD\caFeature::FeatureClassRegistry();
         $oReg->AddFeature(account\cFeature::class);
          
        $oReg->AddFeature(client\cFeature::class);
          $oReg->AddFeature(FU\account\cFeature::class);
        $oReg->AddFeature(session\cFeature::class);
          $oReg->AddFeature(FU\client\cFeature::class);
        // IN PROGRESS
          $oReg->AddFeature(FU\perm\cFeature::class);
          $oReg->AddFeature(FU\session\cFeature::class);
         
          $oReg->AddFeature(FDN\cFeature::class);
     }
     }
}</syntaxhighlight>
    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); }
}
</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>.
For an example of how to read the Feature Registry, see <code>cDropinLink::InvokeFeature()</code>.

Revision as of 16:37, 8 March 2022

Feature registration

Feature registration for non-Dropin classes from config/portable/features.php:

class csSetup {
    static public function OnSetup() {
        $oReg = FD\caFeature::FeatureClassRegistry();
        
          $oReg->AddFeature(FU\account\cFeature::class);
          $oReg->AddFeature(FU\client\cFeature::class);
          $oReg->AddFeature(FU\perm\cFeature::class);
          $oReg->AddFeature(FU\session\cFeature::class);
          
          $oReg->AddFeature(FDN\cFeature::class);
    }
}

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