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(); } } }