Mock.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. namespace lithium\data\source;
  9. /**
  10. * The `Mock` data source is used behind-the-scenes when a model does not use a backend data source.
  11. * It implements the necessary methods, but does not support querying and has no storage backend.
  12. * It can create generic entities for use in forms and elsewhere within the framework. This allows
  13. * developers to create domain objects with business logic and schemas, without worrying about
  14. * backend storage.
  15. */
  16. class Mock extends \lithium\data\Source {
  17. protected $_classes = array(
  18. 'entity' => 'lithium\data\Entity',
  19. 'set' => 'lithium\data\Collection',
  20. 'relationship' => 'lithium\data\model\Relationship',
  21. 'schema' => 'lithium\data\Schema'
  22. );
  23. public function connect() {
  24. return true;
  25. }
  26. public function disconnect() {
  27. return true;
  28. }
  29. public function sources($class = null) {
  30. return array();
  31. }
  32. public function describe($entity, $fields = array(), array $meta = array()) {
  33. return $this->_instance('schema', compact('fields'));
  34. }
  35. public function relationship($class, $type, $name, array $options = array()) {
  36. return false;
  37. }
  38. public function create($query, array $options = array()) {
  39. return false;
  40. }
  41. public function read($query, array $options = array()) {
  42. return false;
  43. }
  44. public function update($query, array $options = array()) {
  45. return false;
  46. }
  47. public function delete($query, array $options = array()) {
  48. return false;
  49. }
  50. }
  51. ?>