Last active
December 10, 2019 00:08
-
-
Save ivastly/955a45aadaa31a9f6241cd0577420220 to your computer and use it in GitHub Desktop.
Typical PHP application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function createNewUser($newUsername) | |
{ | |
$start = time(); | |
if (!$this->isGranted('ROLE_ADMIN')) | |
{ | |
throw new AccessDeniedException(); | |
} | |
$this->logger->info("Creating new user {$newUsername}"); | |
$user = new User(); | |
$user->setName($newUsername); | |
$this->entityManager->persist($user); | |
$this->entityManager->flush(); | |
$this->logger->info("User {$newUsername} was created"); | |
$totalTime = time() - $start; | |
header("X-Create-User-Total-Time: $totalTime sec"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment