Animal.php 788 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace yiiunit\extensions\mongodb\data\ar;
  3. /**
  4. * Animal
  5. *
  6. * @property \MongoDB\BSON\ObjectID|string $_id
  7. * @property string $type
  8. *
  9. * @author Jose Lorente <jose.lorente.martin@gmail.com>
  10. */
  11. class Animal extends ActiveRecord
  12. {
  13. public $does;
  14. public static function collectionName()
  15. {
  16. return 'test_animals';
  17. }
  18. public function attributes()
  19. {
  20. return ['_id', 'type'];
  21. }
  22. public function init()
  23. {
  24. parent::init();
  25. $this->type = get_called_class();
  26. }
  27. public function getDoes()
  28. {
  29. return $this->does;
  30. }
  31. /**
  32. * @param array $row
  33. * @return Animal
  34. */
  35. public static function instantiate($row)
  36. {
  37. $class = $row['type'];
  38. return new $class;
  39. }
  40. }