I am convinced the economic climate plays at least some part into it. How big of a part, I am not sure. But looking at the history of all kinds of countries, you can see that when there are issues like high unemployment rate, then the sentiment towards foreigners tends to not be the most welcomeing.
Also the worse the situation, the more radical the actions to turn it around will be - no matter if those actions actually help or make it worse.
Also the worse the situation, the more radical the actions to turn it around will be - no matter if those actions actually help or make it worse.