Skip to content

Instantly share code, notes, and snippets.

@ivastly
Created December 10, 2019 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivastly/5d158b8e27f4facd731544a081e91c9d to your computer and use it in GitHub Desktop.
Save ivastly/5d158b8e27f4facd731544a081e91c9d to your computer and use it in GitHub Desktop.
Crosscutting conserns
<?php
public function createNewUser($newUsername)
{
$start = time(); // load time calculation
if (!$this->isGranted('ROLE_ADMIN')) // access control
{ // access control
throw new AccessDeniedException(); // access control
} // access control
$this->logger->info("Creating new user {$newUsername}"); // logging
$user = new User();
$user->setName($newUsername);
$this->entityManager->persist($user);
$this->entityManager->flush();
$this->logger->info("User {$newUsername} was created"); // logging
$totalTime = time() - $start; // load time calculation
header("X-Create-User-Total-Time: $totalTime sec"); // load time calculation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment