original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Register entity events listeners for the provided collection
  
  @param EntityCollection $collection
  @param string $cid
  
  @return self
docstring_tokens: Register entity events listeners for the provided collection