Skip to content

Commit

Permalink
#17 added an possibilty to change the vendor dir in the YamlConfigura…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
TobiasFranek committed Jul 1, 2018
1 parent b8a9360 commit a867b97
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/BasicUsage/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ if you want to execute all models with the admin instance
'only_admin' => true
```

if you have changed the vendor dir in the composer.json config you can add this parameter
```php
'admin' => [
//f.e. thalia, cissa etc.
'server' => 'yourserver',
'school' => 'yourschool',
'username' => 'youradminusername',
'password' => 'youradminpassword'
],
'vendorDir' => 'lib'
```

To apply the configuration you have to simply create a new WebuntisConfiguration object.

```php
Expand Down
15 changes: 13 additions & 2 deletions src/Configuration/YAMLConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class YAMLConfiguration {
*/
private $models = [];

/**
* @var string
*/
private $vendorDir = 'vendor';

/**
* @var array
*/
Expand All @@ -49,6 +54,12 @@ class YAMLConfiguration {
];

public function __construct() {

$config = WebuntisConfiguration::getConfig();

if(isset($config['vendorDir'])) {
$this->vendorDir = $config['vendorDir'];
}
if(empty(self::$files)) {
$this->load();
}
Expand Down Expand Up @@ -128,10 +139,10 @@ public function getRepositories() {
*/
public function load() {
$explodedPath = explode('/', __DIR__);
if(in_array('vendor', $explodedPath)) {
if(in_array($this->vendorDir, $explodedPath)) {
$path = '';
foreach($explodedPath as $value) {
if($value == 'vendor') {
if($value == $this->vendorDir) {
break;
}
$path .= $value . '/';
Expand Down

0 comments on commit a867b97

Please sign in to comment.