I'll give you an answer based on what doctrine/data-fixtures-bundle
does, and you can base your system on it.
In the LoadDataFixturesCommand.php
file, which is exactly where the doctrine:fixtures:load
command resides, it has this code block:
$dirOrFile = $input->getOption('fixtures');
if ($dirOrFile) {
$paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
} else {
$paths = array();
foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
$paths[] = $bundle->getPath().'/DataFixtures/ORM';
}
}
$loader = new DataFixturesLoader($this->getContainer());
foreach ($paths as $path) {
if (is_dir($path)) {
$loader->loadFromDirectory($path);
}
}
First, the code checks to see if you've specified any particular fixtures - otherwise, it scans the /DataFixtures/ORM
of all bundles directories in your project to fetch all fixtures that are in them. Then the command iterates through all directories to see if they are valid and finally load the fixtures contained in each of them.
What you can do is something like this: set a directory pattern where the files that will run, load them, check if each one implements the desired interface (with the class_implements
function) using the method implemented. :)