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

From Woozle Writes Code
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Feature registration==
==Feature registration==
{{l/ver|Feature}} registration (incomplete) from /login/base/stocker.php:
The Feature Registry exists so that default Feature classes can be replaced (upgraded or modified) with classes provided by {{l/ver|Dropin}}s. The most common example of this is where Systems designed to work headlessly -- such as the {{l/ver|login}} system -- can be upgraded with a graphical interface by a Dropin.
 
{{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 {
use ferret\login as FL;
class csFeatureSetup {
     static public function OnSetup() {
     static public function OnSetup() {
         $oReg = caFeature::FeatureClassRegistry();
         $oReg = data\caFeature::FeatureClassRegistry();
         $oReg->AddFeature(account\cFeature::class);
          
        $oReg->AddFeature(client\cFeature::class);
          // user-login Features
        $oReg->AddFeature(session\cFeature::class);
          $oReg->AddFeature(FL\account\cFeature::class);
        // IN PROGRESS
          $oReg->AddFeature(FL\client\cFeature::class);
          $oReg->AddFeature(FL\group\cFeature::class);
          $oReg->AddFeature(FL\permit\cFeature::class);
          $oReg->AddFeature(FL\perm\xacct\cFeature::class);
          $oReg->AddFeature(FL\session\cFeature::class);
 
          // node-data
          $oReg->AddFeature(data\node\cFeature::class);
         
     }
     }
}</syntaxhighlight>
    static public function Accounts()      : caFeature { return self::FetchFeature(account\cFeature::SpecSlug()); }
For an example of how code can read the Feature Registry, see <code>cDropinLink::InvokeFeature()</code>.
    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>.

Latest revision as of 13:41, 25 May 2022

Feature registration

The Feature Registry exists so that default Feature classes can be replaced (upgraded or modified) with classes provided by Dropins. The most common example of this is where Systems designed to work headlessly -- such as the login system -- can be upgraded with a graphical interface by a Dropin.

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

use ferret\login as FL;
class csFeatureSetup {
    static public function OnSetup() {
        $oReg = data\caFeature::FeatureClassRegistry();
        
          // user-login Features
          $oReg->AddFeature(FL\account\cFeature::class);
          $oReg->AddFeature(FL\client\cFeature::class);
          $oReg->AddFeature(FL\group\cFeature::class);
          $oReg->AddFeature(FL\permit\cFeature::class);
          $oReg->AddFeature(FL\perm\xacct\cFeature::class);
          $oReg->AddFeature(FL\session\cFeature::class);

          // node-data
          $oReg->AddFeature(data\node\cFeature::class);
          
    }
}

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