<commit_before><?php

namespace Ilios\CoreBundle\Controller;

use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\Controller\Annotations\View;
use Ilios\CoreBundle\Classes\UserEvent;
use Ilios\CoreBundle\Exception\InvalidInputWithSafeUserMessageException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FOS\RestBundle\Controller\FOSRestController;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use DateTime;

/**
 * User materials controller
 * @package Ilios\CoreBundle\Controller\;
 * @RouteResource("Usermaterials")
 */
class UsermaterialsController extends FOSRestController
{

  /**
   * Get events for a user
   *
   * @ApiDoc(
   *   resource = true,
   *   description = "Get materials for a user.",
   *   output="Ilios\CoreBundle\Classes\UserMaterial",
   *   statusCodes = {
   *     200 = "List of user materials",
   *     204 = "No content. Nothing to list."
   *   }
   * )
   *
   * @View(serializerEnableMaxDepthChecks=true)
   *
   * @param integer $id
   *
   * @return Response
   *
   *
   * @throws \Exception
   */
    public function getAction($id)
    {
        $manager = $this->container->get('ilioscore.user.manager');

        $user = $manager->findOneBy(['id' => $id]);

        if (!$user) {
            throw new NotFoundHttpException(sprintf('The user \'%s\' was not found.', $id));
        }

        $authChecker = $this->get('security.authorization_checker');
        if (! $authChecker->isGranted('view', $user)) {
            throw $this->createAccessDeniedException('Unauthorized access!');
        }

        $materials = $manager->findMaterialsForUser($user->getId());

        //If there are no matches return an empty array
        $answer['userMaterials'] = $materials ? array_values($materials) : [];

        return $answer;
    }
}
<commit_msg>Add beta tag to usermaterials endpoint<commit_after><?php

namespace Ilios\CoreBundle\Controller;

use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\Controller\Annotations\View;
use Ilios\CoreBundle\Classes\UserEvent;
use Ilios\CoreBundle\Exception\InvalidInputWithSafeUserMessageException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FOS\RestBundle\Controller\FOSRestController;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use DateTime;

/**
 * User materials controller
 * @package Ilios\CoreBundle\Controller\;
 * @RouteResource("Usermaterials")
 */
class UsermaterialsController extends FOSRestController
{

  /**
   * Get events for a user
   *
   * @ApiDoc(
   *   resource = true,
   *   description = "Get materials for a user.",
   *   output="Ilios\CoreBundle\Classes\UserMaterial",
   *   statusCodes = {
   *     200 = "List of user materials",
   *     204 = "No content. Nothing to list."
   *   },
   *   tags = {
   *     "beta"
   *   }
   * )
   *
   * @View(serializerEnableMaxDepthChecks=true)
   *
   * @param integer $id
   *
   * @return Response
   *
   *
   * @throws \Exception
   */
    public function getAction($id)
    {
        $manager = $this->container->get('ilioscore.user.manager');

        $user = $manager->findOneBy(['id' => $id]);

        if (!$user) {
            throw new NotFoundHttpException(sprintf('The user \'%s\' was not found.', $id));
        }

        $authChecker = $this->get('security.authorization_checker');
        if (! $authChecker->isGranted('view', $user)) {
            throw $this->createAccessDeniedException('Unauthorized access!');
        }

        $materials = $manager->findMaterialsForUser($user->getId());

        //If there are no matches return an empty array
        $answer['userMaterials'] = $materials ? array_values($materials) : [];

        return $answer;
    }
}

{'fraction_non_alphanumeric': 0.1318193683111459, 'fraction_numerical': 0.0031323414252153485, 'mean_word_length': 3.1879781420765028, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2012320', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1148, 'n_words': 225}