protected function registerEventsTo(EntityCollection $collection, $cid)
    {
        $collection->setId($cid);
        $collection->getEmitter()
            ->addListener(
                EntityAdded::ACTION_ADD,
                [$this, 'updateCollection']
            );
        $collection->getEmitter()
            ->addListener(
                EntityRemoved::ACTION_REMOVE,
                [$this, 'updateCollection']
            );
        $entity = $this->repository->getEntityDescriptor()->className();
        Orm::addListener(
            $entity,
            Delete::ACTION_AFTER_DELETE,
            function (Delete $event) use ($collection) {
                $collection->remove($event->getEntity());
            },
            EmitterInterface::P_HIGH
        );
        return $this;
    }