Skip to content

Commit

Permalink
Merge pull request #15 from v1p3r75:fix-connection
Browse files Browse the repository at this point in the history
Added a setter for config file attribute
  • Loading branch information
v1p3r75 authored Mar 10, 2024
2 parents f14636b + 3d261ce commit 8a9e7b2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Model

private static $foreignKeys;

protected $_config_path = "";
private $_config_path = "";

protected $entity;

Expand Down Expand Up @@ -60,7 +60,7 @@ public function __construct()
{

self::$connection = $this->getConnection();
$reflection = new EntityReflection($this->entity); // TODO: create search_entity method (entity auto detection)
$reflection = new EntityReflection($this->entity);
self::$table = $reflection->getTable(Nexa::$inflector);
self::$queryBuilder = self::$connection->createQueryBuilder();
self::$primaryKeyEntity = $this->getPrimaryKey($reflection);
Expand Down Expand Up @@ -340,4 +340,14 @@ private function getConnection() {
return Nexa::getInstance($this->_config_path)->getConnection();
}

public function setConfigPath(string $filepath) {

if (!file_exists($filepath)) {

throw new NotFoundException("Database configuration file : $filepath not found");
}

$this->_config_path = $filepath;
}

}

0 comments on commit 8a9e7b2

Please sign in to comment.