Compare commits
No commits in common. "0a170072ba2723b8fa82942b7b49c47179031cfd" and "59fa22ade019d54866ef643aa829ecc48ebf0930" have entirely different histories.
0a170072ba
...
59fa22ade0
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Notes\Cronard\Attribute\Method;
|
||||
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
||||
class Cronard implements \Notes\Attribute {
|
||||
public function __construct(
|
||||
public string $cron,
|
||||
public null|string $method = null,
|
||||
) {}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Notes\Cronard\Attribute\Object;
|
||||
|
||||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
||||
class Cronard implements \Notes\Attribute {
|
||||
public function __construct(
|
||||
public string $cron,
|
||||
public string $method = "__invoke",
|
||||
) {}
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
<?php namespace Notes\Cronard;
|
||||
|
||||
use Kash\HandleCacheTrait;
|
||||
use Notes\ObjectResolver;
|
||||
use Notes\ObjectReflection,
|
||||
Notes\ObjectResolver;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use RuntimeException, DirectoryIterator, Generator, Closure;
|
||||
|
||||
class TaskFetcher {
|
||||
use HandleCacheTrait;
|
||||
|
||||
protected array $folderList;
|
||||
|
||||
@ -17,10 +15,8 @@ class TaskFetcher {
|
||||
|
||||
protected array $annotations;
|
||||
|
||||
public function __construct( ?array $folderList = null, ?array $annotations = null, ? CacheInterface $cache = null)
|
||||
public function __construct( ?array $folderList = null, ?array $annotations = null)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
|
||||
if ($folderList !== null) {
|
||||
$this->folderList = $folderList;
|
||||
}
|
||||
@ -30,7 +26,7 @@ class TaskFetcher {
|
||||
}
|
||||
else {
|
||||
$this->annotations = [
|
||||
'method' => [ Annotation\Method\Cronard::class, Attribute\Method\Cronard::class ],
|
||||
'method' => Annotation\Method\Cronard::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -67,29 +63,26 @@ class TaskFetcher {
|
||||
}
|
||||
}
|
||||
|
||||
public function compile() : array
|
||||
public function compile() : Generator
|
||||
{
|
||||
return $this->handleCaching(substr(md5(serialize($this->annotations)), 0, 7), function() : array {
|
||||
foreach($this->scan() as $namespace => $file) {
|
||||
if ( $file->getExtension() !== "php" ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $this->generateClassname($file->getBasename(".php"), $namespace);
|
||||
|
||||
# Should generate an equivalent of Ulmus's object reflection here !
|
||||
$objectResolver = new ObjectResolver($class, true, true, false, true);
|
||||
|
||||
foreach($objectResolver->getAnnotationListFromClassname( $this->annotations['method'], false ) as $func => $cronard) {
|
||||
foreach($cronard as $task) {
|
||||
$list[] = [ 'class' => $class, 'method' => $func, 'annotation' => $task ];
|
||||
}
|
||||
}
|
||||
foreach($this->scan() as $namespace => $file) {
|
||||
if ( $file->getExtension() !== "php" ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $this->generateClassname($file->getBasename(".php"), $namespace);
|
||||
|
||||
return $list ?? [];
|
||||
});
|
||||
# Should generate an equivalent of Ulmus's object reflection here !
|
||||
$objectResolver = new ObjectResolver($class, true, true, false, true);
|
||||
|
||||
$taskList = $objectResolver->getAnnotationListFromClassname( $this->annotations['method'] );
|
||||
|
||||
foreach($taskList as $func => $cronard) {
|
||||
foreach($cronard as $task) {
|
||||
yield [ 'class' => $class, 'method' => $func, 'annotation' => $task ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateClassname($file, $namespace)
|
||||
|
Reference in New Issue
Block a user