Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Include all cursor methods in cursor interface #225

Merged
merged 6 commits into from
Aug 18, 2015

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Aug 16, 2015

This extends the common cursor interface introduced in #209 to include all methods currently available in the cursor. This makes the Cursor and EagerCursor more interchangeable in ODM, allowing us to plug both classes into ODM\Cursor once that has been adapted.

The hasNext and getNext methods have to be simulated by advancing and rewinding the array pointer as well as checking if the cursor has started iterating.

@alcaeus alcaeus added this to the 1.2.0 milestone Aug 16, 2015
@malarzm
Copy link
Member

malarzm commented Aug 16, 2015

👍

/**
* Return the connection for this cursor.
*
* @deprecated 1.1 Will be removed for 2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is deprecated, so we really want to add it to the interface?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking no, until I saw that ODM\Cursor exposes the method as well (where I wanted to use the same interface). If we leave it out of ODM we can remove it from the interface here, otherwise I'd leave it in. What's your opinion on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we can remove this from the interface and have ODM still provide the method in its Cursor class, but simply do $this->baseBursor->getCollection()->getDatabase()->getConnection();

@jmikola
Copy link
Member

jmikola commented Aug 17, 2015

LGTM with the interface revisions.

@jmikola jmikola force-pushed the extend-cursor-interface branch 2 times, most recently from 1f92bc8 to 2fc6120 Compare August 18, 2015 05:27
This replaces a $useKeys constructor option for EagerCursor, allowing it to better support a wrapped CursorInterface.

Additionally, we deprecate the Cursor::toArray() $useKeys argument. If omitted, toArray() will default to the Cursor's class option; otherwise, an explicit $useKeys argument may still override.
@jmikola jmikola merged commit c2f4da9 into master Aug 18, 2015
jmikola added a commit that referenced this pull request Aug 18, 2015
@jmikola jmikola deleted the extend-cursor-interface branch August 18, 2015 06:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants