5e263e09a1118f14427dd489e8df3ec1.png PSMList 0.4.0 PSM-040-048

Général

Ordre affichage : 46 Création : 29/06/2023 09h31
Index BL : 48 Modification : 29/06/2023 10h01
BL : PSM-040-048

Source : Aucune Soeurs : -

Dev

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 : -

Provenance : 0.4.0  New Constat : -

Début : S.26 Charge j. : -
Fin : S.26 Délai j. : -
Priorité : - Pokercard : -
Estimatif j. : -

Description : Global strategy for slugname length.

Texte Commit : -

Description client : The gst now holds a "global" variable for the strategy slugname length, and a function to access it. Also reworked tsafe_str so it works with it.

Client

Fascicule : Ne pas communiquer :
Alerte Mailing :

PreP

Statut PreP :   OK - Validé Testeur : ARS - Arshellan

Discussion

ARS

Arshellan

jeudi 29 juin 2023 à 09:59

in genereicServiceTools<br/><br/> private int $strategySlugnameLength = 16;<br/><br/><br/>and <br/><br/> public function getStrategySlugnameLength(): int {<br/> return $this->strategySlugnameLength;<br/> }

ARS

Arshellan

jeudi 29 juin 2023 à 09:59

/**<br/> * Returns a random uppercase string of the desired length, only using read-safe letters and numbers.<br/> * If no length is specified, it uses the default strategy length.<br/> * @param int|null $length Number of characters in the returned string<br/> * @return string<br/> */<br/> public function random_safe_str(?int $length = null) :string {<br/> $entityClasses = [Ship::class, Crew::class, Treasure::class, Keyword::class];<br/> $characters = '123456789ABCDEFGHJKLMNPQRSTUVWXYZ';<br/><br/> // Use the default strategy if the parameter isn't specified<br/> $length = $length ?? $this->getStrategySlugnameLength();<br/><br/> // Generate new slugnames until we got one that's unique<br/> do {<br/> $randomString = '';<br/> for ($i = 0; $i < $length; $i++) {<br/> $index = rand(0, strlen($characters) - 1);<br/> $randomString .= $characters[$index];<br/> }<br/> } while ($this->doesSlugnameExists($entityClasses, $randomString));<br/><br/> return $randomString;<br/> }

ARS

Arshellan

jeudi 29 juin 2023 à 10:00

also don't forget to remove the parameter to all the calls of safe_str unlesss we really want another value