-
Notifications
You must be signed in to change notification settings - Fork 1
RFC: ZfcMongo
manchuck edited this page Dec 14, 2013
·
2 revisions
RFC Author(s): Chuck "MANCHUCK" Reeves
ZfcMongo will have many helpful features for working with Mongo. This module will contain hydrator strategies, validators and factories, and paginiator adapters. The module will add some native Mongo functionality to ZF2.
- Factories for creating collections and gridfs through the service locator
- Hydrator Strategies for all the Mongo types: MongoId, MongoDate etc
- A Validator for duplicate entires
- Paginator adapter
None
None
None
Use case #1 -- Id Hydrator strategy
Namespace ZfcMongo;
use Zend\Stdlib\Hydrator\Strategy\StrategyInterface;
class MongoIdStrategy implements StrategyInterface
{
protected $extractAsString = true;
public function __construct($extractAsString = true)
{
$this->extractAsString = $extractAsString;
}
public function hydrate($value)
{
return new \MongoId($value);
}
public function extract($value)
{
return $this->extractAsString ? (string) $value : $value;
}
}
Use case #2 -- No Record Exists
$userId = new \MongoId();
$validator = new ZfcMongo\Validator\NoRecordExists(
array(
'collection' => 'users',
'field' => 'email',
'exclude' => array(
'field' => '_id',
'value' => $userId
)
)
);
- Rob Allen - No Vote
- Ryan Mauger - No Vote
- Ben Scholzen - No Vote
- Evan Coury - No Vote
- Kyle Spraggs - No Vote
- Artur Bodera - No Vote
- Matthew Weier O'Phinney - No Vote
Click here to view comments and discussion for this RFC.