We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

ODM 2.0 - Questions

  1. First, why so many differences from 1.* to 2.0 ?
  2. In 1.* we were able to call toArray() from a Document. Now we can't.
  3. In 1.* we were able to implement custom validators. Now we can't because a validator is expecting a ModelResultInterface object.

I would appreciate suggestions from the people who made those changes in 2.0 in terms of how can we achieve the same (desired) results.

Thanks.

Method toArray is already there: https://github.com/phalcon/cphalcon/blob/2.0.x/phalcon/mvc/collection.zep#L1227

I'm introducing a new interface EntityInterface to allow pass Mvc\Collection and Mvc\Model interfaces in validators in 2.0.4



51.2k
edited Jun '15

Thank for your reply. I saw that toArray is in collection. The problem is that find() method returns arrays with documents (perfectly normal, I say). But a document doesn't have toArray() implemented (https://github.com/phalcon/cphalcon/blob/2.0.x/phalcon/mvc/collection/document.zep) . So, what would be the ideal way to generate an array from a document, besides ... manually ?

There's no method toArray in Mvc\Collection\Document in Phalcon 1.3.x: https://github.com/phalcon/cphalcon/blob/1.3.5/ext/mvc/collection/document.c#L36-L41



51.2k

Uh. I have no clue what class I was watching. Ok. Any suggestions then ? For toArray() ? find -> filter -> toArray or something simillar like the ORM is capable of ?