protected function removeReferences($glob)
{
$checkResults = $this->getReferencesForGlob($glob);
$nonDeletablePaths = array();
foreach ($checkResults as $path => $filesystemPath) {
if (!array_key_exists($path, $this->json)) {
$nonDeletablePaths[] = $filesystemPath;
}
}
if (count($nonDeletablePaths) > 0) {
throw new InvalidArgumentException(sprintf('You cannot remove resources that are not mapped in the JSON ' . 'file. Tried to remove %s%s.', reset($nonDeletablePaths), count($nonDeletablePaths) > 1 ? ' and ' . (count($nonDeletablePaths) - 1) . ' more' : ''));
}
$deletedPaths = $this->getReferencesForGlob($glob . '{,/**/*}', self::NO_SEARCH_FILESYSTEM);
$removed = 0;
foreach ($deletedPaths as $path => $filesystemPath) {
$removed += 1 + count($this->getReferencesForGlob($path . '/**/*'));
unset($this->json[$path]);
}
return $removed;
}