Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 88 lines (78 sloc) 2.598 kb
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
1 <?php
2 /**
3 * Lithium: the most rad php framework
4 *
a6bd4c4 @mariano Using tabs instead of spaces
authored
5 * @copyright Copyright 2012, Mariano Iglesias (http://marianoiglesias.com.ar)
6 * @license http://opensource.org/licenses/bsd-license.php The BSD License
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
7 */
8
9 namespace li3_doctrine2\models;
10
11 /**
12 * This interface defines the basic behavior a Doctrine model should implement
13 * to be able to use Lithium's validation & form system.
14 */
15 interface IModel {
a6bd4c4 @mariano Using tabs instead of spaces
authored
16 /**
17 * Get the entity manager for this model
18 *
19 * @return EntityManager entity manager
20 */
21 public static function getEntityManager();
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
22
a6bd4c4 @mariano Using tabs instead of spaces
authored
23 /**
24 * Get the repository for this model
25 *
26 * @return EntityRepository entity repository
27 */
28 public static function getRepository();
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
29
a6bd4c4 @mariano Using tabs instead of spaces
authored
30 /**
31 * Returns the model which this entity is bound to.
32 * Usually this would be the fully qualified class name this method belongs
33 * to.
34 *
35 * @return string The fully qualified model class name.
36 */
37 public function model();
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
38
a6bd4c4 @mariano Using tabs instead of spaces
authored
39 /**
40 * A flag indicating whether or not this record exists.
41 *
42 * @return boolean `True` if the record was `read` from the data-source, or has been `create`d
43 * and `save`d. Otherwise `false`.
44 */
45 public function exists();
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
46
47 /**
a6bd4c4 @mariano Using tabs instead of spaces
authored
48 * Allows several properties to be assigned at once, i.e.:
49 * {{{
50 * $record->set(array('title' => 'Lorem Ipsum', 'value' => 42));
51 * }}}
52 *
53 * @param array $data An associative array of fields and values to assign to this instance.
54 */
55 public function set(array $data);
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
56
a6bd4c4 @mariano Using tabs instead of spaces
authored
57 /**
58 * Access the data fields of the record. Can also access a $named field.
59 * Only returns data for fields that have a getter method defined.
60 *
61 * @param string $name Optionally included field name.
62 * @return mixed Entire data array if $name is empty, otherwise the value from the named field.
63 */
64 public function data($name = null);
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
65
a6bd4c4 @mariano Using tabs instead of spaces
authored
66 /**
67 * Perform validation
68 *
69 * @see lithium\data\Model::validates()
70 * @param array $options Options
71 * @return boolean Returns `true` if all validation rules on all fields succeed, otherwise
72 * `false`. After validation, the messages for any validation failures
73 * are accessible through the `errors()` method.
74 */
75 public function validates(array $options = array());
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
76
a6bd4c4 @mariano Using tabs instead of spaces
authored
77 /**
78 * Access the errors of the record.
79 *
80 * @param array|string $field If an array, overwrites `$this->_errors`. If a string, and
81 * `$value` is not `null`, sets the corresponding key in `$this->_errors` to `$value`.
82 * @param string $value Value to set.
83 * @return mixed Either the `$this->_errors` array, or single value from it.
84 */
85 public function errors($field = null, $value = null);
d8eaf7b @mariano Using interfaces to give an alternative to extending from BaseEntity …
authored
86 }
87 ?>
Something went wrong with that request. Please try again.