Code Duplication    Length = 16-16 lines in 2 locations

Ubiquity/orm/traits/DAORelationsPrepareTrait.php 1 location

@@ 45-60 (lines=16) @@
42
	 * @param string $member Member on which a OneToMany annotation must be present
43
	 * @param array $annot used internally
44
	 */
45
	protected static function prepareOneToMany(&$ret,$instance, $member, $annot=null) {
46
		$class=get_class($instance);
47
		if (!isset($annot))
48
			$annot=OrmUtils::getAnnotationInfoMember($class, "#oneToMany", $member);
49
			if ($annot !== false) {
50
				$fkAnnot=OrmUtils::getAnnotationInfoMember($annot["className"], "#joinColumn", $annot["mappedBy"]);
51
				if ($fkAnnot !== false) {
52
					$fkv=OrmUtils::getFirstKeyValue($instance);
53
					$key=$annot["className"]."|".$member."|".$annot["mappedBy"];
54
					if(!isset($ret[$key])){
55
						$ret[$key]=new PendingRelationsRequest();
56
					}
57
					$ret[$key]->addPartObject($instance,$fkAnnot["name"] . "= ?",$fkv);
58
				}
59
			}
60
	}
61
	
62
	/**
63
	 * Prepares members associated with $instance with a manyToOne type relationship

Ubiquity/orm/traits/DAORelationsTrait.php 1 location

@@ 149-164 (lines=16) @@
146
	 * @param string $member Member on which a OneToMany annotation must be present
147
	 * @param array $annot used internally
148
	 */
149
	protected static function prepareOneToMany(&$ret,$instance, $member, $annot=null) {
150
		$class=get_class($instance);
151
		if (!isset($annot))
152
			$annot=OrmUtils::getAnnotationInfoMember($class, "#oneToMany", $member);
153
			if ($annot !== false) {
154
				$fkAnnot=OrmUtils::getAnnotationInfoMember($annot["className"], "#joinColumn", $annot["mappedBy"]);
155
				if ($fkAnnot !== false) {
156
					$fkv=OrmUtils::getFirstKeyValue($instance);
157
					$key=$annot["className"]."|".$member."|".$annot["mappedBy"];
158
					if(!isset($ret[$key])){
159
						$ret[$key]=new PendingRelationsRequest();
160
					}
161
					$ret[$key]->addPartObject($instance,$fkAnnot["name"] . "= ?",$fkv);
162
				}
163
			}
164
	}
165
	
166
	/**
167
	 * Prepares members associated with $instance with a manyToOne type relationship