phalcon/tutorial-models-init — pull request #1 by dugwood (2014-09-22 12:31:05+00:00)
Title: Alias not working for HasMany

I've read the thread here: https://github.com/phalcon/cphalcon/issues/105, but it's old and I don't like to rely on a function getRelated() where the code without namespaces works fine.

My issue was to use namespaces and annotations for HasMany/BelongsTo. Using namespaces along with Annotations force the use for aliases, else names of default aliases includes backslashes, which is difficult to work with.

Say that you have a namespace Test on your Robots/RobotsParts/Parts classes, then you can add:
@HasMany("id", "Test\RobotsParts", "robotsId", {alias="robotsParts"})
which then will work as expected (as if there was no namespaces).

This fix just send the missing «$options» to the addHasMany() call.