get.config.php

Hook-Datei zur Abfrage von Konfigurationswerten aus einem Modul

Dieses Beispiel zeigt den Aufbau einer Hook-Datei get.config.php und den Aufruf aus einem Modul bzw. den Systemfunktionen...

Hook-Datei: get.config.php

<?php
/**
 * This file is part of
 *   
 * XXX
 
 * a module build up within the ALAF - PHP Framework System.
 * Copyright by Andre Lachnicht www.alaniso.de
 *
 * $Revision: 1.1 $
 * $Author: xxx-Gronau / A.Lachnicht $
 * $Date: 2016-07-01 09:10:11 +0200 (Fr, 1. July 2016) $
 */
$hook = function ($module_name, $options, &$config) {
	
	/* $options enthält die kompletten Daten des aktuellen Admins */
	extract ( $options, EXTR_SKIP );
	
	switch ($options ['CONFIG_PARAMETER']) {
		case 'JOB_PATH' :
			include_once (ALAF_MODULES_DIR . DS . 'Lager000' . DS . 'includes' . DS . "class.lager.php");
			include_once (dirname ( dirname ( __FILE__ ) ) . DS . 'includes' . DS . "class.lager391.php");
			$myObj = new Lager391 ();
			$config [$module_name] = array (
					'JOB_PATH' => array (
							'ID' => $module_name,
							'DESCRIPTION' => $myObj->config_get_configuration_xml_value ( 'longtitle' ) . ' (' . $module_name . ')',
							'JOB_PATH' => $myObj->config_get_value ( 'JOB_PATH' ) 
					) 
			);
			unset ( $myObj );
			break;
	}
};
?>

Aufruf durch eine Funktion:

	private function job_paths_load() {
		// Zuerst den System-Ordner anlegen:
		$this->_jobpaths ['Standard'] = array (
				'ID' => 'Standard',
				'DESCRIPTION' => af_tran ( 'System Job-Verzeichnis' ),
				'JOB_PATH' => $this->_config ['job_path'] 
		);
		
		// Job-Verzeichnisse über Config-Hook ermitteln:
		$hook_name = 'get.config';
		$hook = load_class ( 'af_hook', $hook_name );
		// set: setzt einen Schlüssel+Wert in die Variable $options
		//      somit kann ein bestimmter Parameter abgefragt werden!
		$hook->set ( 'CONFIG_PARAMETER', 'JOB_PATH' );
		$hook->run ( $jobpath_list );
		if (isset ( $jobpath_list )) {
			if (sizeof ( $jobpath_list ) > 0) {
				foreach ( $jobpath_list as $module => $value ) {
					$this->_jobpaths [$value ['JOB_PATH'] ['ID']] = $value ['JOB_PATH'];
				}
			}
		}
	}

Last updated