[TYPO3-mvc] Problems on double use of a object in two different objectStorage

Manfred Rutschmann manfred.rutschmann at revier.de
Mon Sep 20 08:41:44 CEST 2010


in my helper class i make a clone from the current object now like this:

	/**
	 * Find a selected Object in a object array by a given uid for forms
	 * @param array	$arr The Object array
	 * @param int $uid The uid
	 * @return array $arr The updated array
	 */
	Public Function  findSelectedObjectinArrayByUid($arr,$uid){
		if(is_array($arr)){
			$i=0;
			foreach ($arr as $obj) {
				if($obj->getUid()==$uid) {
					$arr[$i] = clone $obj;
					$arr[$i]->setFormselected("selected='selected'");
				} 
				$i++;
			}
		}
		return $arr;
	}

On  the clone in filled up the property. That resolve my problem. But is
this right way? 

Thanks and regards 
Manne


More information about the TYPO3-project-typo3v4mvc mailing list