|
|
(27 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
| This article desrcibes the class '''I2CE_Configurator''' which extends the class [[Class: I2CE_Fuzzy | I2CE_Fuzzy]]
| | #REDIRECT [[Class: I2CE_Configurator (4.1.12)]] |
| It is contained in the module [[iHRIS Module List#I2CE|I2CE]] in the package [https://launchpad.net/i2ce I2CE]
| |
| | |
| The class is defined in the file: [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0.0-release/files/head:/lib/I2CE_Configurator.php lib/I2CE_Configurator.php]
| |
| | |
| ==Variables==
| |
| ===$mod_path===
| |
| Hack to store the paths to each config
| |
| *Type: private y $mod_path
| |
| | |
| ===$top_module===
| |
| An associative array linking directory to top-level module
| |
| *Type: private y $top_module
| |
| | |
| ===$checked_paths===
| |
| A list of the paths checked
| |
| *Type: private y $checked_paths
| |
| | |
| ===$found_modules===
| |
| Holds a list of found modules
| |
| @var private array $found_module
| |
| *Type: private $found_modules
| |
| | |
| ===$errors===
| |
| Errors encountered
| |
| *Type: private ng $errors
| |
| | |
| ===$file_list===
| |
| list of files for each module
| |
| *Type: private y $file_list
| |
| | |
| ===$storage===
| |
| Where we are saving all configuration data
| |
| *Type: protected [[Class: I2CE_MagicData | I2CE_MagicData]] $storage
| |
| | |
| ===$template===
| |
| the current template we are working with
| |
| ;
| |
| *Type: protected [[Class: I2CE_MagicDataTemplate | I2CE_MagicDataTemplate]] $template
| |
| | |
| ===$merges===
| |
| $var protected array $merges. Keys are magic data paths,
| |
| values are merge type
| |
| *Type: protected $merges
| |
| | |
| ===$locales===
| |
| The locales for which we check for config files.
| |
| *Type: protected $locales
| |
| | |
| ===$hash===
| |
| . The hash of the last config
| |
| file processed. It is a string, the hash, if the last
| |
| config file loaded successully. false if the last config
| |
| file did not load succesully. null if there was never a
| |
| config file processed.
| |
| *Type: protected [http://www.php.net/manual/en/language.pseudo-types.php mixed] $hash
| |
| | |
| ==Methods==
| |
| ===__construct()===
| |
| Constructor
| |
| | |
| then a simple MagicData and config storage object using
| |
| MagicDataStorageMem will be set up.
| |
| *Signature: public function __construct($storage,$set_last_access)
| |
| Parameters:
| |
| * [[Class: I2CE_MagicData | I2CE_MagicData]] $storage<br/>if none is passed in,
| |
| **Default Value: null
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $set_last_access
| |
| **Default Value: true
| |
| ===__destruct()===
| |
| *Signature: public function __destruct()
| |
| ===checkForConflicts()===
| |
| *Signature: protected function checkForConflicts($requirements,$enabled_modules)
| |
| Parameters:
| |
| *$requirements
| |
| *$enabled_modules
| |
| ===checkRequirements()===
| |
| Checks the requirements. if all requirements are met and
| |
| there are no conflicts, it returns a list of those that
| |
| need to be installed, an empty array() if none are needed.
| |
| On failure returns null.
| |
| | |
| @param array $shortnames an array of shortnames
| |
| | |
| shortnames of modules to disable. Defaults to empty array
| |
| | |
| @param array $remove an array of potential shortnames to
| |
| remove -- if we did not find them somplace else. (it may
| |
| have just been moved) defaults to an empty array.
| |
| | |
| enabled modules -- we check for conflicts against this
| |
| array
| |
| | |
| shortnames of required modules -- if a module is set to be
| |
| updated and it is not required by on of the modules in this
| |
| array, it will be set as an optional modules. Defaults to
| |
| the empty array
| |
| *Signature: public function checkRequirements($updates,$disables,$removals,$enabled_modules,$required_modules)
| |
| *Returns: array. Keys are:
| |
| 'failure' - string with the reason for failture
| |
| 'requirements' - array which has as keys shortnames and
| |
| values files for the requirements.
| |
| 'removals' - array of shortnames that need to be removed.
| |
| 'optional' - array with key shortnames and value true
| |
| 'moved' - array with key shortnames and value true
| |
| Parameters:
| |
| *$updates
| |
| * [http://www.php.net/manual/en/language.pseudo-types.php mixed] $disables<br/>a shortname or an array of
| |
| **Default Value: array()
| |
| *$removals
| |
| **Default Value: array()
| |
| * [http://www.php.net/manual/en/language.types.array.php array] $enabled_modules<br/>An array of shortnames of
| |
| **Default Value: array()
| |
| * [http://www.php.net/manual/en/language.pseudo-types.php mixed] $required_modules<br/>A shortname or an array of
| |
| **Default Value: array()
| |
| ===extRequirements()===
| |
| Get a list of External dependencies for the module
| |
| *Signature: public function extRequirements($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of requirement objects
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check.
| |
| ===findAvailableConfigs()===
| |
| Searches the system for available configuration files (if
| |
| not done already) and stores them in the given I2CE_MagicData
| |
| | |
| @param I2CE_FileSearch A file search to use for modules.
| |
| If null(default) uses I2CE::getFileSearch()
| |
| | |
| checks the module paths of the currently enabled modules.
| |
| If true, checks the module paths of all modules which are
| |
| either enabled or disabled.
| |
| | |
| extensions which we wish to test if they are a config
| |
| file. Defaults to the empty array in which case we look for
| |
| files with the 'xml' extension and any additional
| |
| extensions registered under
| |
| I2CE::getConfig()->config->additional_configuration_extensions
| |
| | |
| and this is set, we only add in the directories which are
| |
| subdirectorues of $limit_to_subdir (check is by string
| |
| comparision)
| |
| *Signature: public function findAvailableConfigs($file_search,$deep,$extensions,$limit_to_subdir,$verbose_errors)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] of string the list of shortnames found
| |
| Parameters:
| |
| *$file_search
| |
| **Default Value: null
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $deep<br/>Defaults to false. If false, only
| |
| **Default Value: false
| |
| * [http://www.php.net/manual/en/language.types.array.php array] $extensions<br/>An array containing file
| |
| **Default Value: array()
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $limit_to_subdir<br/>If $file_search is given
| |
| **Default Value: ''
| |
| *$verbose_errors
| |
| **Default Value: false
| |
| ===findPotentialConfigs()===
| |
| Return a list of potential configuration files. "Potential
| |
| config files" are those whose extension matches the regular
| |
| expression.
| |
| | |
| @param array
| |
| @returns
| |
| *Signature: private function findPotentialConfigs($extensions,$file_search)
| |
| Parameters:
| |
| *$extensions
| |
| *$file_search
| |
| ===flattenRequirements()===
| |
| *Signature: protected function flattenRequirements($requirementDOM)
| |
| Parameters:
| |
| *$requirementDOM
| |
| ===getAvailableModules()===
| |
| Scan a directory for available modules.
| |
| *Signature: public function getAvailableModules($search_dirs,$limit_search,$rescan,$verbose)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of modules found
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.array.php array] $search_dirs<br/>List of Directories to search
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $limit_search<br/>Don't scan by depth (true)
| |
| **Default Value: true
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $rescan<br/>Whether to force a rescan (false)
| |
| **Default Value: false
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $verbose<br/>Verbose errors (false)
| |
| **Default Value: false
| |
| ===getConflicts()===
| |
| For a given module, find a list of conflicting modules.
| |
| *Signature: private function getConflicts($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of conflicts
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check
| |
| ===getDefaultExtensions()===
| |
| *Signature: private function getDefaultExtensions()
| |
| ===getDependencyList()===
| |
| Gets information about the dependecies for a module
| |
| *Signature: public function getDependencyList($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] indexed by 'requirements', 'conflicts'
| |
| 'enable', 'path', and 'badness' where 'badness' is an array of
| |
| strings of error messages and the other are arrays of
| |
| shortnames
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module
| |
| ===getDependsList()===
| |
| Gets the list of modules depending on the specified module.
| |
| *Signature: public function getDependsList($shortname)
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $shortname<br/>The shortname of a module
| |
| ===getDescription()===
| |
| Returns a brief one-line description of the module.
| |
| *Signature: public function getDescription($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.string.php string]
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>name
| |
| ===getEnabled()===
| |
| Get enabled sub-modules
| |
| *Signature: private function getEnabled($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of enabled submodules
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check.
| |
| ===getHash()===
| |
| Get the hash of the contents of the last processConfifFile.
| |
| *Signature: public function getHash()
| |
| *Returns: mixed. String, the hash, if the last config file
| |
| loaded successfully. false if the last config file did not
| |
| load succesully. null if there was never a config file
| |
| processed.
| |
| ===getI2CERoot()===
| |
| *Signature: public function getI2CERoot()
| |
| ===getLongDescription()===
| |
| Returns a longer description of the module.
| |
| *Signature: public function getLongDescription($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.string.php string]
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>name
| |
| ===getMaxChildOrder()===
| |
| *Signature: protected function getMaxChildOrder($node,$xpath)
| |
| Parameters:
| |
| *$node
| |
| *$xpath
| |
| ===getMerges()===
| |
| Get the magic data paths whose status we are tracking.
| |
| $retrurns array. Keys are magic data paths, values are the merge type
| |
| *Signature: public function getMerges()
| |
| ===getModuleDir()===
| |
| Return the directory of the module
| |
| *Signature: public function getModuleDir($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.string.php string] Path to config file.
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check.
| |
| **Default Value: null
| |
| ===getModuleFileList()===
| |
| Get a list of files for a given module
| |
| *Signature: public function getModuleFileList($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of files in the module. Paths are
| |
| relative to the directory where the
| |
| module's configuration file is.
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>The module name
| |
| ===getModuleFileMap()===
| |
| Get a list of each files under each path.
| |
| *Signature: public function getModuleFileMap($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of file maps in the module. Paths are
| |
| relative to the directory where the
| |
| module's configuration file is.
| |
| @todo Contains a hack for the special case where CLASSES directory is ./
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>The module name
| |
| ===getModulePath()===
| |
| Return the path to the module configuration file
| |
| *Signature: public function getModulePath($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.string.php string] Path to config file.
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check.
| |
| ===getModulePathList()===
| |
| *Signature: public function getModulePathList($module)
| |
| Parameters:
| |
| *$module
| |
| ===getNextUnchecked()===
| |
| *Signature: protected function getNextUnchecked($requirementDOM)
| |
| Parameters:
| |
| *$requirementDOM
| |
| ===getPackageAuthors()===
| |
| Returns a longer description of the module.
| |
| *Signature: public function getPackageAuthors($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.string.php string]
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>name
| |
| ===getRequirements()===
| |
| Get a list of requirements for the module
| |
| *Signature: private function getRequirements($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of required modules.
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check.
| |
| ===getRoot()===
| |
| Get the root of where this I2CE instance started.
| |
| *Signature: public function getRoot()
| |
| *Returns: the fully resolved path to the starting directory
| |
| ===getStorage()===
| |
| Get the magic data node storage for the configurator
| |
| *Signature: public function getStorage()
| |
| *Returns: [[Class: I2CE_MagicDataNode | I2CE_MagicDataNode]]
| |
| ===getTopModule()===
| |
| Find the top-level module in a directory. (e.g. I2CE,
| |
| ihris-common, ihris-manage)
| |
| | |
| | |
| @return
| |
| *Signature: public function getTopModule($d,$verbose)
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $d<br/>Directory to check
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $verbose
| |
| **Default Value: false
| |
| ===getVersion()===
| |
| Return the version for a given module
| |
| *Signature: public function getVersion($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.string.php string]
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>name
| |
| ===importLocalizedTemplates()===
| |
| *Signature: public function importLocalizedTemplates($localized)
| |
| Parameters:
| |
| *$localized
| |
| **Default Value: array()
| |
| ===isReq()===
| |
| Determine if this object is a I2CE_MagicDataNode that can
| |
| be used as a requirement.
| |
| @param mixed $string
| |
| *Signature: private function isReq($req)
| |
| *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean]
| |
| Parameters:
| |
| *$req
| |
| ===loadConfigFile()===
| |
| Load a config file with various extensions.
| |
| *Signature: protected function loadConfigFile($file,$verbose_errors)
| |
| *Returns: booolean true on success
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $file<br/>Path to the config file
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $verbose_errors<br/>(true)
| |
| **Default Value: true
| |
| ===moduleConflicts()===
| |
| Checks to see if a module conflicts with by another module
| |
| | |
| requirements (true)
| |
| *Signature: public function moduleConflicts($module,$version,$conflicts,$deep)
| |
| *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean]
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $version<br/>Version of the module
| |
| * [http://www.php.net/manual/en/language.pseudo-types.php mixed] $conflicts<br/>Module name or an array of module names
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $deep<br/>Whether to recursively check the
| |
| **Default Value: true
| |
| ===moduleRequires()===
| |
| Checks to see if a module is required by another module
| |
| | |
| check requirements of requiremnets of requirements of ...
| |
| *Signature: public function moduleRequires($module,$version,$requirements,$deep,$cat)
| |
| *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean]
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $version
| |
| * [http://www.php.net/manual/en/language.pseudo-types.php mixed] $requirements<br/>a module name or an array of module names
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $deep<br/>Defaults to true meaning we should
| |
| **Default Value: true
| |
| *$cat
| |
| **Default Value: 'requirement'
| |
| ===processConfig()===
| |
| *Signature: public function processConfig($process_configuration,$verbose_errors,$process_meta,$localized)
| |
| Parameters:
| |
| *$process_configuration
| |
| **Default Value: false
| |
| *$verbose_errors
| |
| **Default Value: true
| |
| *$process_meta
| |
| **Default Value: true
| |
| *$localized
| |
| **Default Value: array()
| |
| ===processConfigFile()===
| |
| Loads in a config file and validates it against its
| |
| referenced DTD. Sets the access time and the shortname
| |
| (provided in the metadata) for the file. If there is
| |
| already a config file with the same shortname, it will
| |
| remove that fro the list of the config files. Save all the
| |
| configuration metadata under $storage->$shortname where
| |
| $shortname is the shortname provided for by the config
| |
| file.
| |
| | |
| this is less than the time the file was last accessed, it
| |
| does not load the file/set the access time.
| |
| | |
| want to save the configuration data into (defaults to
| |
| false). If true process all config data. If it is a
| |
| string, then we assume that it is a version number, in
| |
| which case we process all configuration data that is
| |
| versioned after the specified version
| |
| | |
| | |
| file already loaded.
| |
| *Signature: public function processConfigFile($file,$process_configuration,$verbose_errors,$process_meta,$localized)
| |
| *Returns: [http://www.php.net/manual/en/language.types.string.php string] the shortname provided for by this config
| |
| file or null on failure.
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $file<br/>The full path to the config file. If
| |
| * [http://www.php.net/manual/en/language.pseudo-types.php mixed] $process_configuration<br/>: Boolean -- true if you
| |
| **Default Value: false
| |
| * [http://www.php.net/manual/en/language.types.boolean.php boolean] $verbose_errors<br/>defaults to true.
| |
| **Default Value: true
| |
| *$process_meta
| |
| **Default Value: true
| |
| * [http://www.php.net/manual/en/language.types.array.php array] $localized<br/>Data on localized versions of the
| |
| **Default Value: array()
| |
| ===processRequirementsDOM()===
| |
| shortnames of module we wish to be loaded.
| |
| | |
| node should have an order attribute. Optionally hey may
| |
| have the attribute 'checked' meaning that we consider this
| |
| node to be checked.
| |
| | |
| @param boolean $options. Defaults to false. Set to true if
| |
| the new requests are optional i.e. don't cause a fatal
| |
| error/add to the DOM if there a conflict
| |
| *Signature: public function processRequirementsDOM($new_requests,$requests,$optional)
| |
| *Returns: an array of the new modules that were installed on
| |
| sucess. A string on failure describing the failure reason.
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.pseudo-types.php mixed] $new_requests<br/>a shortname or an array of
| |
| * [http://www.php.net/manual/en/class.domdocument.php domdocument] $requests<br/>The existing requests. Each
| |
| *$optional
| |
| **Default Value: false
| |
| ===recursiveScan()===
| |
| *Signature: private function recursiveScan($shortnames,$extensions,$limit_to_subdir,$verbose)
| |
| Parameters:
| |
| *&$shortnames
| |
| *$extensions
| |
| *$limit_to_subdir
| |
| *$verbose
| |
| ===requirements()===
| |
| Get a list of requirement objects for the module
| |
| *Signature: public function requirements($module)
| |
| *Returns: [http://www.php.net/manual/en/language.types.array.php array] List of requirement objects
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module<br/>Module to check.
| |
| ===resetCheckedPaths()===
| |
| *Signature: public function resetCheckedPaths()
| |
| ===resetMerges()===
| |
| Reset the tracked data.
| |
| *Signature: public function resetMerges()
| |
| ===setLocales()===
| |
| Set the locales used when handingling the processing of config data.
| |
| *Signature: public function setLocales($locales)
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.pseudo-types.php mixed] $locales<br/>Either a string ( a locale) or an array of strings
| |
| ===setModulePath()===
| |
| Set the module's path, usually used for testing.
| |
| *Signature: public function setModulePath($module,$path)
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $module
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $path
| |
| ===setRoot()===
| |
| Set the root of where this I2CE instance started.
| |
| | |
| this instance of Configurator was created.
| |
| *Signature: public function setRoot($dir)
| |
| *Returns: the fully resolved path to $dir
| |
| Parameters:
| |
| * [http://www.php.net/manual/en/language.types.string.php string] $dir<br/>Directory (defaults to getcwd()) where
| |
| **Default Value: null
| |
| ===setTopModule()===
| |
| Set the top level module for a directory.
| |
| *Signature: public function setTopModule($dir,$module)
| |
| Parameters:
| |
| *$dir
| |
| *$module
| |
| ===setupFileSearch()===
| |
| *Signature: private function setupFileSearch($mod,$path)
| |
| Parameters:
| |
| *$mod
| |
| **Default Value: null
| |
| *$path
| |
| **Default Value: "MODULES"
| |
| ===shallowScan()===
| |
| *Signature: private function shallowScan($potential_configs,$verbose)
| |
| Parameters:
| |
| *$potential_configs
| |
| *$verbose
| |
| **Default Value: false
| |
| ==Inherited Fuzzy Methods==
| |
| ===userMessage()===
| |
| This method is inherited from [[Class: I2CE_Fuzzy#userMessage() | I2CE_Fuzzy->userMessage()]]
| |
| ==Fuzzy Methods==
| |
| ===loadConfigFile_YAML()===
| |
| This method is implemented by [[Class: I2CE_Module_YAML#loadConfigFile_YAML() | I2CE_Module_YAML->loadConfigFile_YAML() ]]
| |
| | |
| | |
| [[Category:Class Documentation]]
| |