public function getAllClassNames()
{
if (empty($this->classNames)) {
if (empty($this->paths)) {
throw DrestException::pathToConfigFilesRequired();
}
$classes = [];
$included = [];
foreach ($this->paths as $path) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($iterator as $file) {
/* @var \SplFileInfo $file */
if (!in_array($file->getExtension(), $this->extensions)) {
continue;
}
$path = $file->getRealPath();
if (!empty($path)) {
require_once $path;
}
// Register the files we've included here
$included[] = $path;
}
}
foreach (get_declared_classes() as $className) {
$reflClass = new \ReflectionClass($className);
$sourceFile = $reflClass->getFileName();
if (in_array($sourceFile, $included) && $this->isDrestResource($className)) {
$classes[] = $className;
}
}
$this->classNames = $classes;
}
return $this->classNames;
}