private function searchForPrivatePlugins($pluginService)
{
$packages = array();
foreach (new \RecursiveDirectoryIterator($pluginService->getPluginsDir() . self::PRIVATE_PLUGINS_DIR) as $file) {
/* @var $file \SplFileInfo */
if (!$file->isFile()) {
continue;
}
if (!extension_loaded('zip')) {
throw new Exception("In order to use private plugins, you need to have zip extension enabled");
}
$zip = new \ZipArchive();
$zip->open($file->getPathname());
if (0 == $zip->numFiles) {
continue;
}
$foundFileIndex = $zip->locateName('composer.json', \ZipArchive::FL_NODIR);
if (false === $foundFileIndex) {
continue;
}
$configurationFileName = $zip->getNameIndex($foundFileIndex);
$composerFile = "zip://{$file->getPathname()}#{$configurationFileName}";
$json = file_get_contents($composerFile);
$package = json_decode($json, true);
$package['dist'] = array('type' => 'zip', 'url' => $file->getRealPath(), 'reference' => $file->getBasename(), 'shasum' => sha1_file($file->getRealPath()));
$packages[] = $package;
}
return $packages;
}