public function editEndpoint(\Service $service, \User $user, \EndpointLocation $endpoint, $newValues) { //Check the portal is not in read only mode, throws exception if it is $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user); $name = $newValues['SERVICEENDPOINT']['NAME']; $url = $newValues['SERVICEENDPOINT']['URL']; if ($newValues['SERVICEENDPOINT']['INTERFACENAME'] != '') { $interfaceName = $newValues['SERVICEENDPOINT']['INTERFACENAME']; } else { $interfaceName = (string) $service->getServiceType(); } $description = $newValues['SERVICEENDPOINT']['DESCRIPTION']; $this->validate($newValues['SERVICEENDPOINT'], 'endpoint'); if (empty($name)) { throw new \Exception("An endpoint must have a name."); } if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { throw new \Exception("An endpoint must have a valid url."); } // check endpoint's name is unique under the service foreach ($service->getEndpointLocations() as $endpointL) { // exclude itself if ($endpoint != $endpointL && $endpointL->getName() == $name) { throw new \Exception("Please provide a unique name for this endpoint."); } } $this->em->getConnection()->beginTransaction(); try { // Set the endpoints new member variables $endpoint->setName($name); $endpoint->setUrl($url); $endpoint->setInterfaceName($interfaceName); $endpoint->setDescription($description); $this->em->merge($endpoint); $this->em->flush(); $this->em->getConnection()->commit(); } catch (\Exception $ex) { $this->em->getConnection()->rollback(); $this->em->close(); throw $ex; } }
/** * Creates an entry in the service archive table, to enable auditing * of deletion. * @param \Service $service * @param \User $user */ public function addServiceToArchive(\Service $service, \User $user) { $archievedService = new \ArchivedService(); $archievedService->setDeletedBy($user->getCertificateDn()); $archievedService->setHostName($service->getHostName()); $archievedService->setServiceType($service->getServiceType()->getName()); $archievedService->setOriginalCreationDate($service->getCreationDate()); $archievedService->setParentSite($service->getParentSite()->getShortName()); $archievedService->setScopes($service->getScopeNamesAsString()); $archievedService->setMonitored($service->getMonitored()); $archievedService->setBeta($service->getBeta()); $archievedService->setProduction($service->getProduction()); $this->em->persist($archievedService); }
<b><?php echo CHtml::encode($data->getAttributeLabel('price')); ?> :</b> <?php echo CHtml::encode($data->price); ?> <br /> <b><?php echo CHtml::encode($data->getAttributeLabel('service_type_id')); ?> :</b> <?php echo Service::getServiceType($data->service_type_id); ?> <br /> </div> <!--<b><?php echo CHtml::encode($data->getAttributeLabel('active')); ?> :</b> <?php if ($data->active == 1) { echo CHtml::encode('Si'); } else { echo CHtml::encode('No'); }
$doctrineSe->setMonitored(false); } // Set the scope if ((string) $xmlSe->SCOPE == "EGI") { $doctrineSe->addScope($egiScope); } else { if ((string) $xmlSe->SCOPE == 'Local') { $doctrineSe->addScope($localScope); } else { throw new Exception("Unknown scope " . $xmlSe->SCOPE . " for SE " . $xmlSe->HOSTNAME); } } //set creation date $creationDate = new \DateTime("now", new DateTimeZone('UTC')); $doctrineSe->setCreationDate($creationDate); $doctrineSe->setDn((string) $xmlSe->HOSTDN); $doctrineSe->setIpAddress((string) $xmlSe->HOST_IP); $doctrineSe->setOperatingSystem((string) $xmlSe->HOST_OS); $doctrineSe->setArchitecture((string) $xmlSe->HOST_ARCH); $doctrineSe->setHostName((string) $xmlSe->HOSTNAME); $doctrineSe->setDescription((string) $xmlSe->DESCRIPTION); // A service has ELs $doctrineEndpointLocation = new EndpointLocation(); $doctrineEndpointLocation->setUrl((string) $xmlSe->URL); $doctrineEndpointLocation->setName('sampleEndpoint'); $doctrineEndpointLocation->setInterfaceName((string) $doctrineSe->getServiceType()->getName()); $doctrineSe->addEndpointLocationDoJoin($doctrineEndpointLocation); $entityManager->persist($doctrineSe); $entityManager->persist($doctrineEndpointLocation); } $entityManager->flush();