Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Nov 4, 2019
1 parent 047eaa5 commit 47dd74f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
composer.lock
.idea
.DS_Store
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kirby Loader

With Kirby Loader you can load plugins from multiple roots. Thus, you can simplify the management of your plugins by grouping.
The Kirby Loader allows you to install plugins from multiple root directories. You can easily manage plug-ins by grouping them.

## Installation

Expand Down Expand Up @@ -37,7 +37,7 @@ return [
The default values of the package are:

| Option | Default | Values | Description |
|:--|:--|:--|:--|
|:---|:---|:---|:---|
| afbora.loader.roots | [] | (array) | Array with the roots |

All the values can be updated in the `config.php` file.
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "afbora/kirby-loader",
"description": "Kirby plugins loader from multiple roots",
"keywords": [],
"version": "1.1",
"version": "1.2.0",
"type": "kirby-plugin",
"license": "MIT",
"authors": [
Expand All @@ -21,9 +21,6 @@
"sort-packages": true
},
"autoload": {
"files": [
"config.php"
],
"psr-4": {
"Afbora\\Loader\\": "src/"
}
Expand Down
9 changes: 0 additions & 9 deletions config.php

This file was deleted.

12 changes: 10 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php

use Afbora\Loader\Loader;
use Kirby\Cms\App as Kirby;

@include_once __DIR__ . "/vendor/autoload.php";

$loader = new \Afbora\Loader\Loader();
$loader->register();
(new Loader())->register();

Kirby::plugin('afbora/loader', [
'options' => [
'roots' => []
]
]);
6 changes: 6 additions & 0 deletions src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public function register()
{
if ($this->roots) {
$index = kirby()->root('index');

foreach ($this->roots as $root) {
if (is_string($root)) {
if (strpos($root, $index) === false) {
$root = $index . DIRECTORY_SEPARATOR . ltrim($root, DIRECTORY_SEPARATOR);
}

$this->pluginsLoader($root);
}
}
Expand All @@ -42,15 +44,19 @@ protected function readDir(string $dirname, string $root): bool
if (in_array(substr($dirname, 0, 1), ['.', '_']) === true) {
return false;
}

$dir = $root . DIRECTORY_SEPARATOR . $dirname;
if (is_dir($dir) === false) {
return false;
}

$entry = $dir . DIRECTORY_SEPARATOR . 'index.php';
if (file_exists($entry) === false) {
return false;
}

include_once $entry;

return true;
}
}
10 changes: 0 additions & 10 deletions vendor/composer/autoload_files.php

This file was deleted.

18 changes: 0 additions & 18 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@ public static function getLoader()

$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit3fb0a4d64201676d2dcd03e06dd74f70::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire3fb0a4d64201676d2dcd03e06dd74f70($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequire3fb0a4d64201676d2dcd03e06dd74f70($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
4 changes: 0 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

class ComposerStaticInit3fb0a4d64201676d2dcd03e06dd74f70
{
public static $files = array (
'412e4b389f65beea27bfc71fde38a046' => __DIR__ . '/../..' . '/config.php',
);

public static $prefixLengthsPsr4 = array (
'K' =>
array (
Expand Down

0 comments on commit 47dd74f

Please sign in to comment.