示例#1
0
 public function __construct(Factory $factory, $documentClass)
 {
     $this->configClass = $factory->getConfigClass($documentClass);
     if (!$this->configClass) {
         var_dump($this->configClass);
     }
     $this->factory = $factory;
     $this->class = $documentClass;
     $this->parseAndCheckFields();
     $this->parseAndCheckReferences();
     $this->parseAndCheckEmbeddeds();
     if (!$this->isEmbedded()) {
         $field = array('type' => 'raw');
         $this->parseField($field, 'id');
     }
 }
示例#2
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testDefineException()
 {
     $factory = new Factory($this->mongator, $this->faker);
     $blueprint = $factory->define('Article', 'Model\\Article');
     $blueprint = $factory->define('Article', 'Model\\Article');
 }
示例#3
0
 public static function reference(Factory $factory, $class, $value = null)
 {
     if (!$value) {
         return $factory->quick($class);
     } else {
         if ($value instanceof Document) {
             return $value;
         } else {
             if (is_array($value)) {
                 return $factory->quick($class, $value);
             } else {
                 if ($value instanceof \MongoId) {
                     $id = $value;
                 } else {
                     $id = new \MongoId($value);
                 }
             }
         }
     }
     $document = $factory->quick($class);
     $document->setId($id);
     return $document;
 }