/**
  * This code is executed when a new session is created.
  *
  * new object : prePersist
  * edited object: preUpdate
  *
  * @param Session $session
  * @param LifecycleEventArgs $args
  *
  * @throws \Exception
  */
 public function prePersist(Session $session, LifecycleEventArgs $args)
 {
     /** @var AccessUrlRelSession $urlRelSession */
     $urlRelSession = $session->getUrls()->first();
     $url = $urlRelSession->getUrl();
     $repo = $args->getEntityManager()->getRepository('ChamiloCoreBundle:Session');
     $this->checkLimit($repo, $url);
 }