<commit_before><?php
declare(strict_types=1);
/**
 * /src/Controller/UserGroupController.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */
namespace App\Controller;

use App\Form\Rest\UserGroup\UserGroupType;
use App\Resource\UserGroupResource;
use App\Rest\Controller;
use App\Rest\ResponseHandler;
use App\Rest\Traits\Actions;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

/**
 * Class UserGroupController
 *
 * @Route(path="/user_group")
 *
 * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
 *
 * @package App\Controller
 */
class UserGroupController extends Controller
{
    /**
     * Method + Form type class names (key + value)
     *
     * @var string[]
     */
    protected static $formTypes = [
        self::METHOD_PATCH  => UserGroupType::class,
        self::METHOD_CREATE => UserGroupType::class,
        self::METHOD_UPDATE => UserGroupType::class,
    ];

    // Traits for REST actions
    use Actions\Admin\CountAction;
    use Actions\Admin\FindAction;
    use Actions\Admin\FindOneAction;
    use Actions\Admin\IdsAction;
    use Actions\Root\CreateAction;
    use Actions\Root\DeleteAction;
    use Actions\Root\PatchAction;
    use Actions\Root\UpdateAction;

    /**
     * UserGroupController constructor.
     *
     * @param UserGroupResource $userGroupResource
     * @param ResponseHandler   $responseHandler
     */
    public function __construct(UserGroupResource $userGroupResource, ResponseHandler $responseHandler)
    {
        $this->init($userGroupResource, $responseHandler);
    }
}
<commit_msg>feat: Added endpoint action to return specified user group users - note that also role inheritances are affected with this one.<commit_after><?php
declare(strict_types=1);
/**
 * /src/Controller/UserGroupController.php
 *
 * @author  TLe, <NAME> <<EMAIL>>
 */
namespace App\Controller;

use App\Entity\UserGroup;
use App\Form\Rest\UserGroup\UserGroupType;
use App\Resource\UserGroupResource;
use App\Resource\UserResource;
use App\Rest\Controller;
use App\Rest\ResponseHandler;
use App\Rest\Traits\Actions;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Class UserGroupController
 *
 * @Route(path="/user_group")
 *
 * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
 *
 * @package App\Controller
 */
class UserGroupController extends Controller
{
    /**
     * Method + Form type class names (key + value)
     *
     * @var string[]
     */
    protected static $formTypes = [
        self::METHOD_PATCH  => UserGroupType::class,
        self::METHOD_CREATE => UserGroupType::class,
        self::METHOD_UPDATE => UserGroupType::class,
    ];

    // Traits for REST actions
    use Actions\Admin\CountAction;
    use Actions\Admin\FindAction;
    use Actions\Admin\FindOneAction;
    use Actions\Admin\IdsAction;
    use Actions\Root\CreateAction;
    use Actions\Root\DeleteAction;
    use Actions\Root\PatchAction;
    use Actions\Root\UpdateAction;

    /**
     * UserGroupController constructor.
     *
     * @param UserGroupResource $userGroupResource
     * @param ResponseHandler   $responseHandler
     */
    public function __construct(UserGroupResource $userGroupResource, ResponseHandler $responseHandler)
    {
        $this->init($userGroupResource, $responseHandler);
    }

    /**
     * Endpoint action to list specified user group users.
     *
     * @Route(
     *      "/{id}/users",
     *      requirements={
     *          "id" = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
     *      }
     *  )
     *
     * @ParamConverter(
     *     "user",
     *     class="App:UserGroup"
     *  )
     *
     * @Method({"GET"})
     *
     * @Security("has_role('ROLE_ADMIN')")
     *
     * @param Request      $request
     * @param UserResource $userResource
     * @param UserGroup    $userGroup
     *
     * @return Response
     *
     * @throws \UnexpectedValueException
     * @throws \Symfony\Component\HttpKernel\Exception\HttpException
     */
    public function getUserGroupUsersAction(
        Request $request,
        UserResource $userResource,
        UserGroup $userGroup
    ): Response
    {
        // Manually change used resource class, so that serializer groups are correct ones
        $this->getResponseHandler()->setResource($userResource);

        return $this->getResponseHandler()->createResponse($request, $userResource->getUsersForGroup($userGroup));
    }
}

{'fraction_non_alphanumeric': 0.12036066261270707, 'fraction_numerical': 0.0044034388760746486, 'mean_word_length': 3.2934293429342936, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, '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': '3297556', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1392, 'n_words': 264}