Skip to content

Commit

Permalink
Merge pull request #4 from LaswitchTech/dev
Browse files Browse the repository at this point in the history
Publishing v1.1.3
  • Loading branch information
LouisOuellet authored Jun 26, 2024
2 parents cb2916b + 3182da2 commit 94e7ba1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [LaswitchTech]
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.2
1.1.3
50 changes: 49 additions & 1 deletion src/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Configurator {
private $RootPath = null;

/**
* Create a new phpConfigurator instance.
* Create a new Configurator instance.
*
* @return object $this
*/
Expand Down Expand Up @@ -261,4 +261,52 @@ public function path($className) {

return $filePath;
}

/**
* Check if the library is installed.
*
* @return bool
*/
public function isInstalled(){

// Retrieve the path of this class
$reflector = new ReflectionClass($this);
$path = $reflector->getFileName();

// Retrieve the filename of this class
$filename = basename($path);

// Modify the path to point to the config directory
$path = str_replace('src/' . $filename, 'config/', $path);

// Add the requirements to the Configurator
$this->Configurator->add('requirements', $path . 'requirements.cfg');

// Retrieve the list of required modules
$modules = $this->Configurator->get('requirements','modules');

// Check if the required modules are installed
foreach($modules as $module){

// Check if the class exists
if (!class_exists($module)) {
return false;
}

// Initialize the class
$class = new $module();

// Check if the method exists
if(method_exists($class, isInstalled)){

// Check if the class is installed
if(!$class->isInstalled()){
return false;
}
}
}

// Return true
return true;
}
}

0 comments on commit 94e7ba1

Please sign in to comment.