<?php
namespace OfficeBrain\Bundle\UserBundle\Event;

use Doctrine\ORM\Event\LifecycleEventArgs;
use OfficeBrain\Bundle\ServiceGroupBundle\Entity\ServiceGroup;

class AdminServiceGroupEvent 
{
	protected $container;
	
	public function __construct($container){
		$this->container = $container;
	}
	public function preSoftDelete(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();
        $entityManager = $args->getEntityManager();

        // check is serviceGroup entity
        if ($entity instanceof ServiceGroup) {
        	
        	//Before remove assign default group to user
        	$this->container->get('office_brain_user_manager')->assignDefaultAccessGroup($entity);
        }
    }
}
