- Work done on the console to have at least some working functionality from every parts

This commit is contained in:
mcndave committed 2022-11-29 19:29:15 +00:00
1 parent e78492d398
commit 24e5490c71
18 files changed
+352 -27

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
<?php
namespace Lean\Console\Form\Caching;
use Picea\Ui\Method\{ FormInterface, FormContext, FormContextInterface };
use \Lean\Console\Lib;
use Picea\{Caching\Opcache, Compiler\Context };
use Psr\Http\Message\ServerRequestInterface;
use Ulmus\Common\EntityResolver;
use \Ulmus\Entity\InformationSchema\Table;
use RecursiveIteratorIterator, RecursiveDirectoryIterator;
class Picea implements FormInterface
{
public \Picea\Picea $picea;
public array $folders;
public function __construct(\Picea\Picea $picea, array &$folders)
{
$this->folders = &$folders;
$this->picea = $picea;
}
public function initialize(FormContextInterface $context) : void
{
if ($this->picea->cache instanceof Opcache) {
$path = $this->picea->cache->cachePath() . "/";
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
foreach ($iterator as $file) {
if ($file->isFile() && in_array($file->getExtension(), [ 'php' ])) {
$this->folders[$path][] = $file;
}
}
}
}
public function validate(FormContextInterface $context) : bool
{
return $context->valid();
}
public function execute(FormContextInterface $context) : void
{
$deleted = $failed = 0;
foreach($this->folders as $path => $files) {
foreach($files as $file)
{
unlink($file->getPathname()) ? $deleted++ : $failed++;
}
}
if ($deleted) {
# $context->pushMessage();
}
if ($failed) {
# $context->pushMessage();
}
}
}