Fix #1249: support relation by array attributes

Fix #1249: support relation by array attributes
Well, perhaps this particular solution is risk prone. I have started with the unit test and code until it was satisfied.
Perhaps I went too far. However this PR contains not only this version, you check up the first solution I came by before refactoring:

https://github.com/klimov-paul/yii2/commit/660f03959df83655395e0572932eb890db27c62b

Maybe we should use it instead.