3232 */
3333class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
3434{
35+ /**
36+ * @var string[]
37+ */
3538 protected $ _aliases = array ();
3639
40+ /**
41+ * @param string[] $aliases A list of relation name
42+ */
3743 public function __construct (array $ aliases )
3844 {
3945 $ this ->_aliases = $ aliases ;
4046 }
4147
48+ /**
49+ * @throws Doctrine_Table_Exception
50+ */
4251 public function init ()
4352 {
44- // check that all aliases exist
45- foreach ($ this ->_aliases as $ alias ) {
53+ // check that all aliases exist
54+ foreach ($ this ->_aliases as $ alias ) {
4655 $ this ->_table ->getRelation ($ alias );
47- }
56+ }
4857 }
4958
5059 /**
51- * filterSet
52- * defines an implementation for filtering the set() method of Doctrine_Record
60+ * Provides fallback for setting value.
61+ *
62+ * @return Doctrine_Record the given record
5363 *
54- * @param mixed $name name of the property or related component
64+ * @thrown Doctrine_Record_UnknownPropertyException
5565 */
5666 public function filterSet (Doctrine_Record $ record , $ name , $ value )
5767 {
5868 foreach ($ this ->_aliases as $ alias ) {
59- // The relationship must be fetched in order to check the field existance .
69+ // The relationship must be fetched in order to check the field existence .
6070 // Related to PHP-7.0 compatibility so an explicit call to method get is required.
6171 $ record [$ alias ];
6272
6373 if ( ! $ record ->exists ()) {
6474 if (isset ($ record [$ alias ][$ name ])) {
6575 $ record [$ alias ][$ name ] = $ value ;
66-
76+
6777 return $ record ;
6878 }
6979 } else {
@@ -78,15 +88,16 @@ public function filterSet(Doctrine_Record $record, $name, $value)
7888 }
7989
8090 /**
81- * filterGet
82- * defines an implementation for filtering the get() method of Doctrine_Record
91+ * Provides fallback for getting value.
92+ *
93+ * @return mixed The value of the given property
8394 *
84- * @param mixed $name name of the property or related component
95+ * @thrown Doctrine_Record_UnknownPropertyException
8596 */
8697 public function filterGet (Doctrine_Record $ record , $ name )
8798 {
8899 foreach ($ this ->_aliases as $ alias ) {
89- // The relationship must be fetched in order to check the field existance .
100+ // The relationship must be fetched in order to check the field existence .
90101 // Related to PHP-7.0 compatibility so an explicit call to method get is required.
91102 $ record [$ alias ];
92103
@@ -102,4 +113,4 @@ public function filterGet(Doctrine_Record $record, $name)
102113 }
103114 throw new Doctrine_Record_UnknownPropertyException (sprintf ('Unknown record property / related component "%s" on "%s" ' , $ name , get_class ($ record )));
104115 }
105- }
116+ }
0 commit comments