public static function createSampleSiteProperty($key, $val) { $prop = new SiteProperty(); $prop->setKeyName($key); $prop->setKeyValue($val); return $prop; }
/** * Edits a site property * * @param \Site $site * @param \User $user * @param \SiteProperty $prop * @param * $newValues */ public function editSiteProperty(\Site $site, \User $user = null, \SiteProperty $prop, $newValues) { // Check the portal is not in read only mode, throws exception if it is $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user); //Validate User to perform this action $this->validatePropertyActions($user, $site); $this->validate($newValues['SITEPROPERTIES'], 'siteproperty'); $keyname = $newValues['SITEPROPERTIES']['NAME']; $keyvalue = $newValues['SITEPROPERTIES']['VALUE']; $this->checkNotReserved($user, $site, $keyname); $this->em->getConnection()->beginTransaction(); try { // Set the site propertys new member variables $prop->setKeyName($keyname); $prop->setKeyValue($keyvalue); $this->em->merge($prop); $this->em->flush(); $this->em->getConnection()->commit(); } catch (\Exception $ex) { $this->em->getConnection()->rollback(); $this->em->close(); throw $ex; } }