- First commit of the notes/breadcrumb package
This commit is contained in:
commit
d029a6d709
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2019 Dave Mc Nicoll
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"name": "mcnd/notes-breadcrumb",
|
||||||
|
"description": "Annotation-based breadcrumb",
|
||||||
|
"type": "library",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Dave Mc Nicoll",
|
||||||
|
"email": "mcndave@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"mcnd/notes": "master-dev",
|
||||||
|
},
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "https://github.com/mcNdave/notes.git"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Notes\\Breadcrumb\\": "src/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Notes\Breadcrumb\Annotation\Method;
|
||||||
|
|
||||||
|
class Breadcrumb implements \Notes\Annotation {
|
||||||
|
|
||||||
|
public string $parent;
|
||||||
|
|
||||||
|
public string $icon;
|
||||||
|
|
||||||
|
public string $lang;
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php namespace Notes\Breadcrumb;
|
||||||
|
|
||||||
|
use Notes\ObjectReflection,
|
||||||
|
Notes\ObjectResolver;
|
||||||
|
|
||||||
|
use RuntimeException, DirectoryIterator, Generator;
|
||||||
|
|
||||||
|
class Breadcrumb {
|
||||||
|
|
||||||
|
protected array $folderList;
|
||||||
|
|
||||||
|
protected array $fileList;
|
||||||
|
|
||||||
|
public function __construct(array $folderList = []) {
|
||||||
|
$this->folderList = $folderList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFolder($folder) : void
|
||||||
|
{
|
||||||
|
$this->folderList[] = $folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFolderList(array $list) : void
|
||||||
|
{
|
||||||
|
$this->folderList = $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scan() : Generator
|
||||||
|
{
|
||||||
|
foreach($this->folderList as $namespace => $folder) {
|
||||||
|
if ( ! file_exists($folder) ) {
|
||||||
|
throw new RuntimeException(sprintf("Folder `%s` can not be found or scanned", $folder));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (new DirectoryIterator($folder) as $fileinfo) {
|
||||||
|
if ( ! $fileinfo->isDot() ) {
|
||||||
|
yield $namespace => $fileinfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function compile() : array
|
||||||
|
{
|
||||||
|
foreach($this->scan() as $namespace => $file) {
|
||||||
|
$class = $this->generateClassname($file->getBasename(".php"), $namespace);
|
||||||
|
|
||||||
|
# Should generate an equivalent of Ulmus's object reflection here !
|
||||||
|
# var_dump( "<pre>", , "</pre>" );
|
||||||
|
$objectResolver = new ObjectResolver($class);
|
||||||
|
|
||||||
|
#if ( null === $class = $this->getAnnotationFromClassname( Table::class ) ) {
|
||||||
|
|
||||||
|
# }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue