Comment by Gaetano Giunta, 2014-03-11 10:21
Take care when using $repository->setCurrentUser(): it will NOT change the currently-logged-in-user for the legacy stack.
So if your code later on still relies on Legacy stack, you need to switch the current user for that as well, eg:
$kernel = $this->getContainer()->get( 'exponential_legacy.kernel' );
$kernel()->runCallback(
function() {\eZUser::setCurrentlyLoggedInUser( \eZUser::fetch( 14 ), 14 );
}
);