PHP Classes

File: docs/Gectrl.md

Recommend this page to a friend!
  Classes of Kjell-Inge Gustafsson   Gectrl PHP Generic Controller Class   docs/Gectrl.md   Download  
File: docs/Gectrl.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Gectrl PHP Generic Controller Class
Controller class that delegates in action classes
Author: By
Last change:
Date: 3 years ago
Size: 3,497 bytes
 

Contents

Class file image Download

[comment]: # (This file is part of Gectrl, PHP Genereric controller. Copyright 2021 Kjell-Inge Gustafsson, kigkonsult, All rights reserved, licence LGPLv3)

Class Gectrl

Gectrl is a PHP generic controller class

  • Supports the MVC software design pattern
  • Distinguish controller and application logic using a strategy pattern

The controller provides coordination logic

The controller delegates application logic to actionClasses

  • using implementations of the (strategy) [ActionClassInterface],
  • invoking of actionClass condition evaluate (in order) and opt, logicdoAction* methods,
  • passing all data information in an encapsulated [Package] class instance * input, output, config, logger etc

For [ActionClassInterface] example, please review test/AcSrc/ActionExampleTest.php.<br> To obtain actionsClasses (FQCNs) from namespace(s), you may use [hpierce1102/ClassFinder].<br> Any trait / interface / abstract class in FQCNs array are ignored.

Class common methods

__construct( [ config [, logger [, actionClasses ]]] )
  • Gectrl constructor
  • 
    
  • 
    
  • Creates (internal) _[Package]_ class intance (in the package property)
init( [ config [, logger [, actionClasses ]]] )
  • Gectrl (static) factory
  • 
    
  • 
    
  • Return _Gectrl_ class instance
  • _static_

main( [ input ] )
  • Main method, assert Gectrl instance, invoke the actionClasses 'evaluate'/'doAction' methods in order
  • stores the input in the default (internally) created _[Package]_ class instance
    
    
  • a (replacing) externally created (preloaded) _[Package]_ class instance
  • Return _[Package]_
  • Throws _RuntimeException_

Properties && methods

actionClasses

  • valueType : _string[]_ actionClass FQCNs
getActionClasses()
  • Return _string[]_ actionClasses (FQCNs)
isActionClassSet( [ fqcn] )
  • 
    
  • Return _bool_, true if actionsClasses (fqcn) is set, otherwise false
addActionClass( actionClass )
  • the ```actionClass``` class MUST implement _[ActionClassInterface]_<br>
    no action on traits / interfaces / abstract classes
    
    
  • Return _static_
  • Throws _InvalidArgumentException_ on other class, interface or trait error
setActionClasses( actionClasses )
  • Set (string[]) actionClasses (FQCNs)
  • any trait / interface / abstract class in FQCNs array ignored
  • 
    
  • Return _static_
  • Throws _InvalidArgumentException_ on other class, interface or trait error

package

  • valueType : _[Package]_
  • Created at Gectrl class intance creation
getPackage()
  • Return _[Package]_ (passed as reference)
setPackage( package )
  • Set (replacing) _[Package]_
  • 
    
  • Return _static_

Go to [README], [ActionClassInterface], [Package] docs.

[ActionClassInterface]:ActionClassInterface.md [hpierce1102/ClassFinder]:https://gitlab.com/hpierce1102/ClassFinder [Package]:Package.md [README]:../README.md