Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afbora committed Nov 12, 2021
1 parent 26db260 commit eb57d3f
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 1,564 deletions.
51 changes: 23 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
{
"name": "afbora/kirby-loader",
"description": "Kirby plugins loader from multiple roots",
"keywords": [],
"version": "1.4.0",
"type": "kirby-plugin",
"license": "MIT",
"authors": [
{
"name": "Ahmet Bora",
"email": "[email protected]"
}
],
"require": {
"php": "^7.3 || ^8.0",
"getkirby/composer-installer": "^1.2"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"autoload": {
"psr-4": {
"Afbora\\Loader\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
"name": "afbora/kirby-loader",
"description": "Kirby plugins loader from multiple roots",
"keywords": [],
"version": "2.0.0",
"type": "kirby-plugin",
"license": "MIT",
"authors": [
{
"name": "Ahmet Bora",
"email": "[email protected]"
}
],
"require": {
"php": "^7.4|^8.0",
"getkirby/composer-installer": "^1.2"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
8 changes: 5 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

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

@include_once __DIR__ . "/vendor/autoload.php";
load([
'afbora\\loader' => __DIR__ . '/src/Loader.php',
]);

(new Loader())->register();

Kirby::plugin('afbora/loader', [
'options' => [
'roots' => []
]
]);
]);
11 changes: 6 additions & 5 deletions src/Loader.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php

namespace Afbora\Loader;
namespace Afbora;

use Kirby\Toolkit\Dir;
use Kirby\Filesystem\Dir;
use Kirby\Filesystem\F;

class Loader
{
protected $roots = [];

public function __construct()
{
$this->roots = option('afbora.loader.roots');
$this->roots = option('afbora.loader.roots', []);
}

public function register()
Expand Down Expand Up @@ -58,11 +59,11 @@ protected function readDir(string $dirname, string $root): bool
}

$entry = $dir . DIRECTORY_SEPARATOR . 'index.php';
if (file_exists($entry) === false) {
if (is_dir($dir) !== true || is_file($entry) !== true) {
return false;
}

include_once $entry;
F::loadOnce($entry);

return true;
}
Expand Down
7 changes: 0 additions & 7 deletions vendor/autoload.php

This file was deleted.

Loading

0 comments on commit eb57d3f

Please sign in to comment.