Ferreteria/v0.3/class/fcrDropInModule

From Woozle Writes Code
< Ferreteria‎ | v0.3‎ | class
Jump to navigation Jump to search

Template:Page/code/class

/*::::
  FIELDS:
    [name]: short name for module
    [descr]: one-line description
    [version]: version number (can be non-numeric)
    [date]: release date in YYYY/MM/DD format
    [URL]: URL for more information about the module
*/
class fcrDropInModule extends ferreteria\data\cIORow_sourced {

    // ++ SETUP ++ //
    
    // ACTION: Load specs array and do any additional per-module processing.
    public function SetSpecs(array $arSpecs) {
	$this->SetValues($arSpecs);
	$this->RegisterClasses();
    }
    /*----
      ACTION: register any classes defined within the dropin.
    */
    protected function RegisterClasses() {
	$arCls = $this->ClassArray();
	foreach ($arCls as $sFile => $sClasses) {
	    $om = new fcCodeModule(__FILE__, $sFile);
	    if (is_array($sClasses)) {
		// value is an array of class names for file $sFile
		foreach ($sClasses as $sClass) {
		    $om->AddClass($sClass);
		}
	    } else {
		// assume value is a single class name
		$om->AddClass($sClasses);
	    }
	}
    }

    // -- SETUP -- //
    // ++ FIELD VALUES ++ //

    public function Name() {
	return $this->GetValue('name');
    }
    protected function ClassArray() {
	return $this->GetValue('classes');
    }

    // -- FIELD VALUES -- //
}