Respect/Relational — Issue #4: Redesign and refactoring
Author: alganet
Created: 2011-10-24 05:44:20+00:00
State: open

After great feedback from our users, we now believe its time for a cleaner and more powerful Respect\Relational. Major points in this refactor:

## Schema cleanup

Although the idea of different schema providers is great, their implementation is incomplete and people rarely uses them. We should focus on removing different schemas and upgrading AbstractSchema+Infered to a component more close to the Mapper.

As a result of this, users are encouraged to always use the three main conventions for Respect\Relational.

Future new schema providers are not discarded, but we should focus on getting our API awesome before trying out different things.

## Finders become Collections

Currently finders are the objects that represent node chains in a Relational query. For `$mapper->post->author[3]->fetch()`, which is the query for retrieving all posts from author 3, both **post** and **author** are instantiated as Finders.

We're planning to extend this to make these finders do more than querying. `$mapper->post->author->persist($object)` for example would persist the $object to a predefined set of collections (a post and a table author). This will allow users to reuse the `$mapper->post->author` better and have schema-less objects more cohesive.

This also deprecates persisting directly into a Mapper instance. Users should know where they're persisting.

## Collection shortcuts

Collections are always hierarchical. They implement the composite pattern. This allow us to create collection shortcuts:

```php
postsFromAuthor = $mapper->posts->author; //create the shortcut and assign to the mapper
$posts = $mapper->postsFromAuthor[3]->fetchAll(); //retrieve posts from the author 3
$mapper->postsFromAuthor->persist($newPost); //persists a new post with author
```

----

We also need to make these changes reduce our codebase =)

After this, Respect\Relational will not be called an ORM anymore. We need a better name for this approach.