Remove vendors without packages

@param Storage $storage
@param callable $callback function called after the vendor removal
@return integer
504967
public function cleanupVendors(Storage $storage, callable $callback = null)
    {
        $count = 0;
        $storageNode = $storage->node();
        $query = new FlowQuery([$storageNode]);
        $query = $query->find('[instanceof Neos.MarketPlace:Vendor]');
        foreach ($query as $vendor) {
            /** @var NodeInterface $vendor */
            $hasPackageQuery = new FlowQuery([$vendor]);
            $packageCount = $hasPackageQuery->find('[instanceof Neos.MarketPlace:Package]')->count();
            if ($packageCount > 0) {
                continue;
            }
            $vendor->remove();
            if ($callback !== null) {
                $callback($vendor);
            }
            $this->emitVendorDeleted($vendor);
            $count++;
        }
        return $count;
    }
494872
public function detach(string $event, $callback){
        if(isset($this->listeners[$event])){
            return $this->listeners[$event]->remove($callback);
        }
        return false;
    }
1343621
protected function removeListener(array $listeners , $eventObject , $callback) {
        if (isset($listeners[$eventObject->getName()])) {
            if (($index = array_search($callback, $listeners[$eventObject->getName()])) !== false) {
                unset($listeners[$eventObject->getName()][$index]);
                if(empty($listeners[$eventObject->getName()])) {
                    unset($listeners[$eventObject->getName()]);
                } else {
                    $listeners[$eventObject->getName()] = array_values($listeners[$eventObject->getName()]);
                }
            }
        }
        return $listeners;
    }
834074
public function reduce($callback)
    {
        $result = null;
        foreach ($this as $key => $value) {
            $result = $callback($value, $key);
        }

        return $result;
    }
687914
protected function unloadStorageObjects(SplObjectStorage $storage)
    {
        $storage->rewind();
        while ($storage->valid()) {
            $object = $storage->current();
            $object->unload();
            $storage->detach($object);
        }
    }
295773
private function deleteStore($key)
    {
        if (isset($this->storage[$key])) {
            unset($this->storage[$key]);
            return $this->save();
        }

        return true;
    }
1087874
public function uninstallPackage(PackageEvent $event)
    {
        // Check if library exists and exposes any directories
        $library = $this->getLibrary($event);
        if (!$library || !$library->requiresExpose()) {
            return;
        }

        // Check path to remove
        $target = $library->getPublicPath();
        if (!is_dir($target)) {
            return;
        }

        // Remove directory
        $name = $library->getName();
        $event->getIO()->write("Removing web directories for module <info>{$name}</info>:");
        $this->filesystem->removeDirectory($target);

        // Cleanup empty vendor dir if this is the last module
        $targetParent = dirname($target);
        if ($this->filesystem->isDirEmpty($targetParent)) {
            $this->filesystem->removeDirectory($targetParent);
        }
    }
544102
protected function removeObserversByCallback(callable $callback): EventInterface
    {
        //find the callback
        foreach ($this->observers as $event => $observer) {
            $this->removeObserversByEvent($event, $callback);
        }

        return $this;
    }
765480
public static function deleteImage($fileName, $context, $storage = 'local')
    {
        /** @var Processor $processor */
        $processor = app('icr.processor');

        return $processor->delete($fileName, $context, Facades\Storage::disk($storage));
    }
618736
function destroy(callback) {
            var model = this;
            var request = {
                action : 'remove',
                model : model.constructor,
                data : this
            };
            this.dispatch('beforeDestroy');

            this.constructor.storage.remove(request, function destroyCallback() {
                model.setProperty('id', null);
                model.dispatch('afterDestroy');
                if (callback) {
                    callback(model);
                }
            });
        }
649324
public function detach($event, $callback)
    {
        if (null !== $callback) {
            $oid = $this->hashCallable($callback);
            if (isset($this->callable_map[$event][$oid])) {
                $callback = $this->callable_map[$event][$oid];
                unset($this->callable_map[$event][$oid]);
            }
        } else {
            unset($this->callable_map[$event]);
        }
        return parent::detach($event, $callback);
    }
783915
public function onStorageEventPreDelete(StorageEvent $event)
    {
        /** @var Entity\Users $userEntity */
        $userEntity = $event->getContent();
        if (!$userEntity instanceof Entity\Users) {
            return;
        }

        $this->deleteAuthtokens($userEntity);
        $this->deleteSessions($userEntity);
    }
927325
public function deleteAction(Storage $storage)
    {
        $em = $this->getDoctrine()->getManager();
        $em->remove($storage);
        $em->flush();

        return $this->redirect($this->generateUrl('storage_list'));
    }
1281689
protected function removeImageFromStorage (HCResources $resource)
    {
        $path = $this->uploadPath . $resource->id;

        if (Storage::has ($path)) {
            Storage::delete ($path);
        }
    }
1045607
public function removeAll(self $storage)
    {
        foreach ($this->data as $key => $value) {
            foreach ($storage->data as $object) {
                if ($object === $value) {
                    unset($this->data[$key]);
                    unset($this->info[$key]);
                }
            }
        }
    }
361199
public function reject($callback): CollectionInterface
    {
        return $this->filter(function ($item, $key) use ($callback) {
            if (is_callable($callback)) {
                return !$callback($item, $key);
            }

            if (null === $item || is_scalar($item)) {
                return $item !== $callback;
            }

            return !$this->accessKey($item, $callback, $key);
        });
    }
782675
def remove_callback(self, callback) -> None:
        """"""
        if callback in self._callbacks:
            self._callbacks.remove(callback)