<commit_before><?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\InputFilter;
use App\Repository\CampRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * The main entity that eCamp is designed to manage. Contains programme which may be
 * distributed across multiple time periods.
 *
 * @ORM\Entity(repositoryClass=CampRepository::class)
 */
#[ApiResource(
    collectionOperations: [
        'get' => ['security' => 'is_fully_authenticated()'],
        'post' => [
            'security' => 'is_fully_authenticated()',
            'input_formats' => ['jsonld', 'jsonapi', 'json'],
            'validation_groups' => ['Default', 'Camp:create'],
            'denormalization_context' => [
                'groups' => ['write', 'create'],
                'allow_extra_attributes' => false,
            ],
            'normalization_context' => [
                'groups' => ['read', 'Camp:Periods', 'Period:Days'],
                'allow_extra_attributes' => false,
            ],
        ],
    ],
    itemOperations: [
        'get' => [
            'security' => 'object.owner == user or is_granted("ROLE_ADMIN")',
            'normalization_context' => [
                'groups' => ['read', 'Camp:Periods', 'Period:Days'],
                'allow_extra_attributes' => false,
            ],
        ],
        'patch' => [
            'security' => 'object.owner == user or is_granted("ROLE_ADMIN")',
            'denormalization_context' => [
                'groups' => ['write', 'update'],
                'allow_extra_attributes' => false,
            ],
            'normalization_context' => [
                'groups' => ['read', 'Camp:Periods', 'Period:Days'],
                'allow_extra_attributes' => false,
            ],
        ],
        'delete' => ['security' => 'object.owner == user or is_granted("ROLE_ADMIN")'],
    ],
    denormalizationContext: [
        'groups' => ['write'],
        'allow_extra_attributes' => false,
    ],
    normalizationContext: [
        'groups' => ['read'],
        'allow_extra_attributes' => false,
    ],
)]
class Camp extends BaseEntity implements BelongsToCampInterface {
    /**
     * @ORM\OneToMany(targetEntity="CampCollaboration", mappedBy="camp", orphanRemoval=true)
     */
    #[SerializedName('campCollaborations')]
    public Collection $collaborations;

    /**
     * The time periods of the camp, there must be at least one. Periods in a camp may not overlap.
     * When creating a camp, the initial periods may be specified as nested payload, but updating,
     * adding or removing periods later should be done through the period endpoints.
     *
     * @ORM\OneToMany(targetEntity="Period", mappedBy="camp", orphanRemoval=true, cascade={"persist"})
     * @ORM\OrderBy({"start": "ASC"})
     */
    #[Assert\Valid]
    #[Assert\Count(min: 1, groups: ['Camp:create'])]
    #[ApiProperty(
        writableLink: true,
        example: '[{ "description": "Hauptlager", "start": "2022-01-01", "end": "2022-01-08" }]',
    )]
    #[Groups(['read', 'create'])]
    public Collection $periods;

    /**
     * Types of programme, such as sports activities or meal times.
     *
     * @ORM\OneToMany(targetEntity="Category", mappedBy="camp", orphanRemoval=true)
     */
    #[ApiProperty(writable: false, example: '["/categories/1a2b3c4d"]')]
    public Collection $categories;

    /**
     * All the programme that will be carried out during the camp. An activity may be carried out
     * multiple times in the same camp.
     *
     * @ORM\OneToMany(targetEntity="Activity", mappedBy="camp", orphanRemoval=true)
     */
    #[ApiProperty(writable: false, example: '["/activities/1a2b3c4d"]')]
    public Collection $activities;

    /**
     * Lists for collecting the required materials needed for carrying out the programme. Each collaborator
     * has a material list, and there may be more, such as shopping lists.
     *
     * @ORM\OneToMany(targetEntity="MaterialList", mappedBy="camp", orphanRemoval=true)
     */
    #[ApiProperty(writable: false, example: '["/material_lists/1a2b3c4d"]')]
    public Collection $materialLists;

    /**
     * The id of the camp that was used as a template for creating this camp. Internal for now, is
     * not published through the API.
     *
     * @ORM\Column(type="string", length=16, nullable=true)
     */
    #[Assert\DisableAutoMapping]
    #[ApiProperty(readable: false, writable: false)]
    public ?string $campPrototypeId = null;

    /**
     * Whether this camp may serve as a template for creating other camps.
     *
     * @ORM\Column(type="boolean")
     */
    #[Assert\Type('bool')]
    #[Assert\DisableAutoMapping]
    #[ApiProperty(example: false, writable: false)]
    public bool $isPrototype = false;

    /**
     * A short name for the camp.
     *
     * @ORM\Column(type="string", length=32)
     */
    #[InputFilter\Trim]
    #[InputFilter\CleanHTML]
    #[Assert\NotBlank]
    #[ApiProperty(example: 'SoLa 2022')]
    #[Groups(['read', 'create'])]
    public string $name;

    /**
     * The full title of the camp.
     *
     * @ORM\Column(type="text")
     */
    #[InputFilter\Trim]
    #[InputFilter\CleanHTML]
    #[Assert\NotBlank]
    #[Assert\Length(max: 32)]
    #[ApiProperty(example: 'Abteilungs-Sommerlager 2022')]
    #[Groups(['read', 'write'])]
    public string $title;

    /**
     * The thematic topic (if any) of the camp's programme and storyline.
     *
     * @ORM\Column(type="text", nullable=true)
     */
    #[InputFilter\Trim]
    #[InputFilter\CleanHTML]
    #[Assert\Length(max: 128)]
    #[ApiProperty(example: 'Piraten')]
    #[Groups(['read', 'write'])]
    public ?string $motto = null;
<commit_msg>Make the camp name writable again<commit_after><?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\InputFilter;
use App\Repository\CampRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * The main entity that eCamp is designed to manage. Contains programme which may be
 * distributed across multiple time periods.
 *
 * @ORM\Entity(repositoryClass=CampRepository::class)
 */
#[ApiResource(
    collectionOperations: [
        'get' => ['security' => 'is_fully_authenticated()'],
        'post' => [
            'security' => 'is_fully_authenticated()',
            'input_formats' => ['jsonld', 'jsonapi', 'json'],
            'validation_groups' => ['Default', 'Camp:create'],
            'denormalization_context' => [
                'groups' => ['write', 'create'],
                'allow_extra_attributes' => false,
            ],
            'normalization_context' => [
                'groups' => ['read', 'Camp:Periods', 'Period:Days'],
                'allow_extra_attributes' => false,
            ],
        ],
    ],
    itemOperations: [
        'get' => [
            'security' => 'object.owner == user or is_granted("ROLE_ADMIN")',
            'normalization_context' => [
                'groups' => ['read', 'Camp:Periods', 'Period:Days'],
                'allow_extra_attributes' => false,
            ],
        ],
        'patch' => [
            'security' => 'object.owner == user or is_granted("ROLE_ADMIN")',
            'denormalization_context' => [
                'groups' => ['write', 'update'],
                'allow_extra_attributes' => false,
            ],
            'normalization_context' => [
                'groups' => ['read', 'Camp:Periods', 'Period:Days'],
                'allow_extra_attributes' => false,
            ],
        ],
        'delete' => ['security' => 'object.owner == user or is_granted("ROLE_ADMIN")'],
    ],
    denormalizationContext: [
        'groups' => ['write'],
        'allow_extra_attributes' => false,
    ],
    normalizationContext: [
        'groups' => ['read'],
        'allow_extra_attributes' => false,
    ],
)]
class Camp extends BaseEntity implements BelongsToCampInterface {
    /**
     * @ORM\OneToMany(targetEntity="CampCollaboration", mappedBy="camp", orphanRemoval=true)
     */
    #[SerializedName('campCollaborations')]
    public Collection $collaborations;

    /**
     * The time periods of the camp, there must be at least one. Periods in a camp may not overlap.
     * When creating a camp, the initial periods may be specified as nested payload, but updating,
     * adding or removing periods later should be done through the period endpoints.
     *
     * @ORM\OneToMany(targetEntity="Period", mappedBy="camp", orphanRemoval=true, cascade={"persist"})
     * @ORM\OrderBy({"start": "ASC"})
     */
    #[Assert\Valid]
    #[Assert\Count(min: 1, groups: ['Camp:create'])]
    #[ApiProperty(
        writableLink: true,
        example: '[{ "description": "Hauptlager", "start": "2022-01-01", "end": "2022-01-08" }]',
    )]
    #[Groups(['read', 'create'])]
    public Collection $periods;

    /**
     * Types of programme, such as sports activities or meal times.
     *
     * @ORM\OneToMany(targetEntity="Category", mappedBy="camp", orphanRemoval=true)
     */
    #[ApiProperty(writable: false, example: '["/categories/1a2b3c4d"]')]
    public Collection $categories;

    /**
     * All the programme that will be carried out during the camp. An activity may be carried out
     * multiple times in the same camp.
     *
     * @ORM\OneToMany(targetEntity="Activity", mappedBy="camp", orphanRemoval=true)
     */
    #[ApiProperty(writable: false, example: '["/activities/1a2b3c4d"]')]
    public Collection $activities;

    /**
     * Lists for collecting the required materials needed for carrying out the programme. Each collaborator
     * has a material list, and there may be more, such as shopping lists.
     *
     * @ORM\OneToMany(targetEntity="MaterialList", mappedBy="camp", orphanRemoval=true)
     */
    #[ApiProperty(writable: false, example: '["/material_lists/1a2b3c4d"]')]
    public Collection $materialLists;

    /**
     * The id of the camp that was used as a template for creating this camp. Internal for now, is
     * not published through the API.
     *
     * @ORM\Column(type="string", length=16, nullable=true)
     */
    #[Assert\DisableAutoMapping]
    #[ApiProperty(readable: false, writable: false)]
    public ?string $campPrototypeId = null;

    /**
     * Whether this camp may serve as a template for creating other camps.
     *
     * @ORM\Column(type="boolean")
     */
    #[Assert\Type('bool')]
    #[Assert\DisableAutoMapping]
    #[ApiProperty(example: false, writable: false)]
    public bool $isPrototype = false;

    /**
     * A short name for the camp.
     *
     * @ORM\Column(type="string", length=32)
     */
    #[InputFilter\Trim]
    #[InputFilter\CleanHTML]
    #[Assert\NotBlank]
    #[ApiProperty(example: 'SoLa 2022')]
    #[Groups(['read', 'write'])]
    public string $name;

    /**
     * The full title of the camp.
     *
     * @ORM\Column(type="text")
     */
    #[InputFilter\Trim]
    #[InputFilter\CleanHTML]
    #[Assert\NotBlank]
    #[Assert\Length(max: 32)]
    #[ApiProperty(example: 'Abteilungs-Sommerlager 2022')]
    #[Groups(['read', 'write'])]
    public string $title;

    /**
     * The thematic topic (if any) of the camp's programme and storyline.
     *
     * @ORM\Column(type="text", nullable=true)
     */
    #[InputFilter\Trim]
    #[InputFilter\CleanHTML]
    #[Assert\Length(max: 128)]
    #[ApiProperty(example: 'Piraten')]
    #[Groups(['read', 'write'])]
    public ?string $motto = null;

{'fraction_non_alphanumeric': 0.14717825474434407, 'fraction_numerical': 0.007624098781801608, 'mean_word_length': 2.818987341772152, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 65, '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': '5074048', 'n_tokens_mistral': 3627, 'n_tokens_neox': 3584, 'n_words': 849}