Fixes #4943 -- Avoid using all-numeric stubs.
This commit is contained in:
parent
26f3b8d1e3
commit
b6c116438d
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Interfaces\IdentifiableEntityInterface;
|
||||
use App\Utilities\File;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use OpenApi\Attributes as OA;
|
||||
use Stringable;
|
||||
|
@ -54,7 +55,7 @@ class CustomField implements Stringable, IdentifiableEntityInterface
|
|||
$this->name = $this->truncateString($name);
|
||||
|
||||
if (empty($this->short_name) && !empty($name)) {
|
||||
$this->setShortName(Station::getStationShortName($name));
|
||||
$this->setShortName(self::generateShortName($name));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +63,7 @@ class CustomField implements Stringable, IdentifiableEntityInterface
|
|||
{
|
||||
return (!empty($this->short_name))
|
||||
? $this->short_name
|
||||
: Station::getStationShortName($this->name);
|
||||
: self::generateShortName($this->name);
|
||||
}
|
||||
|
||||
public function setShortName(string $short_name): void
|
||||
|
@ -92,4 +93,13 @@ class CustomField implements Stringable, IdentifiableEntityInterface
|
|||
{
|
||||
return $this->short_name;
|
||||
}
|
||||
|
||||
public static function generateShortName(string $str): string
|
||||
{
|
||||
$str = File::sanitizeFileName($str);
|
||||
|
||||
return (is_numeric($str))
|
||||
? 'custom_field_' . $str
|
||||
: $str;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ final class Version20171208093239 extends AbstractMigration
|
|||
$this->connection->update(
|
||||
'station',
|
||||
[
|
||||
'short_name' => Station::getStationShortName($record['name']),
|
||||
'short_name' => Station::generateShortName($record['name']),
|
||||
],
|
||||
[
|
||||
'id' => $record['id'],
|
||||
|
|
|
@ -49,7 +49,7 @@ class CustomFieldRepository extends Repository
|
|||
)->getArrayResult();
|
||||
|
||||
foreach ($fieldsRaw as $row) {
|
||||
$fields[$row['id']] = $row['short_name'] ?? Entity\Station::getStationShortName($row['name']);
|
||||
$fields[$row['id']] = $row['short_name'] ?? Entity\Station::generateShortName($row['name']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
$this->name = $this->truncateString($name, 100);
|
||||
|
||||
if (empty($this->short_name) && !empty($name)) {
|
||||
$this->setShortName(self::getStationShortName($name));
|
||||
$this->setShortName(self::generateShortName($name));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
{
|
||||
return (!empty($this->short_name))
|
||||
? $this->short_name
|
||||
: self::getStationShortName($this->name);
|
||||
: self::generateShortName($this->name);
|
||||
}
|
||||
|
||||
public function setShortName(string $shortName): void
|
||||
|
@ -429,15 +429,10 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
$shortName = $this->name;
|
||||
}
|
||||
|
||||
$shortName = self::getStationShortName($shortName);
|
||||
$shortName = self::generateShortName($shortName);
|
||||
$this->short_name = $this->truncateString($shortName, 100);
|
||||
}
|
||||
|
||||
public static function getStationShortName(string $str): string
|
||||
{
|
||||
return File::sanitizeFileName($str);
|
||||
}
|
||||
|
||||
public function setIsEnabled(bool $is_enabled): void
|
||||
{
|
||||
$this->is_enabled = $is_enabled;
|
||||
|
@ -1148,4 +1143,13 @@ class Station implements Stringable, IdentifiableEntityInterface
|
|||
$be_config->setTelnetPort(null);
|
||||
$this->setBackendConfig($be_config);
|
||||
}
|
||||
|
||||
public static function generateShortName(string $str): string
|
||||
{
|
||||
$str = File::sanitizeFileName($str);
|
||||
|
||||
return (is_numeric($str))
|
||||
? 'station_' . $str
|
||||
: $str;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Entity\Enums\PlaylistOrders;
|
|||
use App\Entity\Enums\PlaylistRemoteTypes;
|
||||
use App\Entity\Enums\PlaylistSources;
|
||||
use App\Entity\Enums\PlaylistTypes;
|
||||
use App\Utilities\File;
|
||||
use Azura\Normalizer\Attributes\DeepNormalize;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
@ -234,7 +235,7 @@ class StationPlaylist implements
|
|||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return Station::getStationShortName($this->name);
|
||||
return self::generateShortName($this->name);
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
|
@ -568,4 +569,13 @@ class StationPlaylist implements
|
|||
{
|
||||
return $this->getStation() . ' Playlist: ' . $this->getName();
|
||||
}
|
||||
|
||||
public static function generateShortName(string $str): string
|
||||
{
|
||||
$str = File::sanitizeFileName($str);
|
||||
|
||||
return (is_numeric($str))
|
||||
? 'playlist_' . $str
|
||||
: $str;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue