PSMList 0.4.0 PSM-040-056
| Ordre affichage : | 50 | Création : | 04/07/2023 09h25 |
| Index BL : | 56 | Modification : | 05/07/2023 23h10 |
| BL : | PSM-040-056 | ||
| Source : | Aucune | Soeurs : | - |
| Fin dev : | D (Done) | Ticket : | - |
| Contrôle dev effectué : | Fiche : | - | |
| C.Qualif. : | #000000 | ||
| Activé : | Icône FA : | Par défaut | |
| Contact : | ARS - Arshellan | Qualification : | Nouveauté |
| Répartition : | - | Module : | Data |
| Dev : | ARS - Arshellan | Sous module : | Treasure |
| Provenance : | 0.4.0 New | Constat : | - |
| Début : | S.27 | Charge j. : | - |
| Fin : | S.27 | Délai j. : | - |
| Priorité : | - | Pokercard : | - |
| Estimatif j. : | - | ||
| Description : | Add support for coin values on treasures | ||
| Texte Commit : | - | ||
| Description client : | Added the support for coins values on treasures. This field is optional and you only have to fill it if you want your card to have coins on them. | ||
| Fascicule : | Ne pas communiquer : | ||
| Alerte Mailing : |
| Statut PreP : | OK - Validé | Testeur : | ARS - Arshellan |
Treasure.php<br/><br/><br/><br/> /**<br/> * @ORM\Column(type="string", length=50, nullable=true)<br/> */<br/> private $coinvalues;<br/><br/><br/><br/><br/><br/><br/> public function getCoinvalues(): ?string {<br/> return $this->coinvalues;<br/> }<br/> public function setCoinvalues(?string $coinvalues): self {<br/> $this->coinvalues = $coinvalues;<br/> return $this;<br/> }
at the end of the gst<br/><br/><br/> /**<br/> * tells whether a string is a valid "coinvalues" or not.<br/> * @param string $input<br/> * @return bool<br/> */<br/> public function isCoinvaluesCorrectlyWritten(string $input): bool<br/> {<br/> // Check if the string length is within the allowed limit<br/> if (strlen($input) > 50) {<br/> return false;<br/> }<br/><br/> // Check if the string starts or ends with a comma<br/> if (str_starts_with($input, ',') || str_ends_with($input, ',')) {<br/> return false;<br/> }<br/><br/> // Split the string by commas<br/> $values = explode(',', $input);<br/><br/> // Check if any number is missing<br/> if (in_array('', $values, true)) {<br/> return false;<br/> }<br/><br/> // Check if each value is a number<br/> foreach ($values as $value) {<br/> if (!is_numeric($value)) {<br/> return false;<br/> } else {<br/> if ($value > 999) {<br/> return false;<br/> }<br/> }<br/> }<br/><br/> // If all checks pass, the string is valid<br/> return true;<br/> }
in all the functions add and edit in the controller for treasure<br/><br/><br/> if ($gst->isCoinvaluesCorrectlyWritten($form->get('coinvalues')->getData())) {<br/> $obj->setCoinvalues($form->get('coinvalues')->getData());<br/> } else {<br/> $obj->setCoinvalues(null);<br/> $this->addFlash('error', 'The coin values you provided aren\'t written correctly, please check that value and retry.');<br/> $canPersist = false;<br/> }