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
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Feature registration==
==Feature registration==
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;
     static public function OnPreLoad() {
class csFeatureSetup {
         $oReg = caFeature::FeatureClassRegistry();
     static public function OnSetup() {
         $oReg->AddFeature(account\cFeature::class);
         $oReg = data\caFeature::FeatureClassRegistry();
        $oReg->AddFeature(client\cFeature::class);
          
        $oReg->AddFeature(session\cFeature::class);
          // user-login Features
        // IN PROGRESS
          $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);
         
     }
     }
}</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>

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