-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathfilesearcher.php
43 lines (35 loc) · 950 Bytes
/
filesearcher.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Pantheon;
use \Pantheon\Messenger,
\Pantheon\Utils,
\Pantheon\Checker;
use \Symfony\Component\Filesystem\Filesystem;
use \Symfony\Component\Finder\Finder;
class Filesearcher extends Checker {
private $finder; // symfony filesystem object
private $dir;
static $instance;
public function __construct($dir) {
$this->finder = new Finder();
$this->dir = $dir;
self::$instance = $this;
return $this;
}
public function execute() {
foreach($this->callbacks() as $class => $object) {
$object->init();
}
$files = $this->finder->files()->in($this->dir)->name("*.php");
foreach ( $files as $file ) {
if (\WP_CLI::get_config('debug')) {
\WP_CLI::line( sprintf("-> %s",$file->getRelativePathname()) );
}
foreach($this->callbacks() as $class => $object) {
$object->run($file);
}
}
foreach($this->callbacks() as $class => $object) {
$object->message(Messenger::instance());
}
}
}