Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute for Entity #23

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
77962a1
Update GeoNameImport.php
treeindark Oct 23, 2023
6b30f0d
Create PostalCode.php
treeindark Oct 24, 2023
7e1c7d9
Create PostalCodeImport.php
treeindark Oct 24, 2023
835f819
Update services.yml
treeindark Oct 24, 2023
ed95250
Merge branch 'bordeux:master' into master
treeindark Oct 24, 2023
6ddcccb
Update PostalCode.php
treeindark Oct 25, 2023
960174a
Update Country.php
treeindark Nov 2, 2023
9f980c5
Update Header.php
treeindark Nov 2, 2023
dc10630
Update AlternateName.php
treeindark Nov 2, 2023
45c2956
Update AlternateNameImport.php
treeindark Nov 2, 2023
3f7ff5c
Update AlternateName.php
treeindark Nov 3, 2023
39a2ca6
Update Header.php
treeindark Nov 6, 2023
1f42174
Update Header.php
treeindark Nov 6, 2023
d33a9b4
Update AlternateName.php
treeindark Nov 6, 2023
ea32680
Update ImportCommand.php
treeindark Nov 6, 2023
4ea71f1
Update ImportCommand.php
treeindark Nov 6, 2023
93de972
Update Administrative.php Attributes
treeindark Nov 27, 2023
c33e6f5
Update AlternateName.php attributes
treeindark Nov 27, 2023
1c55993
Update Country.php attributes
treeindark Nov 27, 2023
fe569ce
Update GeoName.php attributes
treeindark Nov 27, 2023
0d6a42d
Update Hierarchy.php attributes
treeindark Nov 27, 2023
691e222
Update PostalCode.php attributes
treeindark Nov 27, 2023
44a61a9
Update Timezone.php attributes
treeindark Nov 27, 2023
eefa60d
Update Administrative.php
treeindark Nov 27, 2023
14a4011
Update Country.php
treeindark Nov 27, 2023
0833962
Update AlternateName.php
treeindark Nov 27, 2023
367c716
Update GeoName.php
treeindark Nov 27, 2023
8082b1a
Update Country.php
treeindark Nov 27, 2023
0770d2f
Update Administrative.php
treeindark Nov 27, 2023
b5447f7
Update GeoName.php
treeindark Nov 27, 2023
7d093ac
Update Country.php
treeindark Nov 27, 2023
2d6774a
Update GeoName.php
treeindark Nov 29, 2023
850b07d
Update composer.json
treeindark Dec 11, 2023
777c0c9
Update AbstractImport.php
treeindark Dec 11, 2023
0bf7f85
Update AbstractImport.php
treeindark Dec 11, 2023
33d2187
Rename Hierarchy.php to Hierarchy.php.todo
treeindark Feb 7, 2024
28ec941
Update GeoName.php
treeindark Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.0",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"symfony/console": "^5.4 || ^6.0"
"symfony/console": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"doctrine/orm": "^2.5",
Expand All @@ -30,8 +30,8 @@
"phpunit/phpunit": "^9.5.20",
"psalm/plugin-symfony": "^4.0 || ^5.0",
"roave/security-advisories": "dev-latest",
"symfony/framework-bundle": "^5.4 || ^6.4",
"symfony/yaml": "^5.4 || ^6.4",
"symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
"weirdan/doctrine-psalm-plugin": "^2.3"
},
"autoload": {
Expand Down
14 changes: 10 additions & 4 deletions src/Command/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ protected function configure()
"Download dir",
sys_get_temp_dir()
);

$commandLine->addOption(
"only",
null,
InputOption::VALUE_REQUIRED,
"Importing only importName, use import-option-name (ex: alternate-names)",
false
);
foreach ($this->importers as $importer) {
$commandLine = $commandLine->addOption(
$commandLine->addOption(
$importer->getOptionName(),
null,
InputOption::VALUE_OPTIONAL,
Expand All @@ -85,11 +91,11 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$downloadDir = $input->getOption('download-dir');

$only = $input->getOption('only');
foreach ($this->importers as $importer) {
$value = $input->getOption($importer->getOptionName());
$skip = $input->getOption("skip-" . $importer->getOptionName());
if (empty($value) || $skip) {
if (empty($value) || $skip || (!empty($only) && $only !== $importer->getOptionName())) {
$output->writeln("\nSkipping importing {$importer->getName()}");
continue;
}
Expand Down
44 changes: 10 additions & 34 deletions src/Entity/Administrative.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,26 @@

use Doctrine\ORM\Mapping as ORM;

/**
* Administrative
*
* @ORM\Table(name="geo__administrative")
* @ORM\Entity()
*/
#[ORM\Entity()]
#[ORM\Table(name: 'geo__administrative')]
class Administrative
{
/**
* @var int|null
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected ?int $id = null;

/**
* @var string
*
* @ORM\Column(name="code", type="string", length=30, unique=true)
*/
#[ORM\Column(length: 30, unique: true)]
protected string $code;

/**
* @var string
*
* @ORM\Column(name="name", type="string", length=200)
*/
#[ORM\Column(length: 200)]
protected string $name;

/**
* @var string
*
* @ORM\Column(name="ascii_name", type="string", length=200, nullable=true)
*/
#[ORM\Column(length: 200, nullable: true)]
protected ?string $asciiName;

/**
* @var GeoName
*
* @ORM\ManyToOne(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\GeoName")
* @ORM\JoinColumn(name="geoname_id", referencedColumnName="id", nullable=true)
*/
#[ORM\ManyToOne(targetEntity: GeoName::class)]
#[ORM\JoinColumn(name: "geoname_id", referencedColumnName: "id", nullable: true)]
protected ?GeoName $geoName;

/**
Expand Down
66 changes: 31 additions & 35 deletions src/Entity/AlternateName.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,31 @@
use Doctrine\ORM\Mapping as ORM;
use Stringable;

/**
* AlternateNames
*
* @ORM\Table(name="geo__alternate_name", indexes={
* @ORM\Index(name="geoname_name_search_idx", columns={"geoname_id", "type"}),
* })
* @ORM\Entity()
*/
#[ORM\Entity()]
#[ORM\Table(name: 'geo__alternate_name')]
#[ORM\Index(name: 'geoname_name_search_idx', columns: ['geoname_id', 'type'])]
class AlternateName implements Stringable
{
public const TYPE_NONE = 'none';

/**
* @var int|null
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
protected ?int $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'NONE')]
protected ?int $id = null;


/**
* @var GeoName
*
* @ORM\ManyToOne(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\GeoName")
* @ORM\JoinColumn(name="geoname_id", referencedColumnName="id", nullable=false)
*/
#[ORM\ManyToOne(targetEntity: 'GeoName')]
#[ORM\JoinColumn(name: "geoname_id", referencedColumnName: "id", nullable: false)]
protected GeoName $geoName;


/**
* @var string
*
* @ORM\Column(name="type", type="string", length=10, nullable=false)
*/
#[ORM\Column(length: 10, nullable: false)]
protected string $type;

/**
* @var string
*
* @ORM\Column(name="value", type="text", nullable=false)
*/
protected $value;
#[ORM\Column(type: "text", length: 10, nullable: false)]
protected string $value;

#[ORM\Column(length: 1, nullable: true)]
protected string $prefered;

/**
*
* @return int
Expand Down Expand Up @@ -113,7 +93,23 @@ public function setValue(string $value): self
$this->value = $value;
return $this;
}
/**
* Get the value of prefered
*/
public function getPrefered(): string
{
return $this->prefered;
}

/**
* Set the value of prefered
*/
public function setPrefered(string $prefered): self
{
$this->prefered = $prefered;
return $this;
}

/**
* @return string
*/
Expand Down
148 changes: 45 additions & 103 deletions src/Entity/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,142 +5,69 @@
use Doctrine\ORM\Mapping as ORM;
use Stringable;

/**
* GeoName
*
* @ORM\Table(name="geo__country" ,indexes={
* @ORM\Index(name="geoname_country_search_idx", columns={"name", "iso"})
* })
* @ORM\Entity()
*/
#[ORM\Entity()]
#[ORM\Table(name: 'geo__country')]
#[ORM\Index(name: 'geoname_country_search_idx', columns: ['name', 'iso'])]
class Country implements Stringable
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'NONE')]
protected int $id;

/**
* @var string
*
* @ORM\Column(name="iso", type="string", length=2, nullable=false)
*/
#[ORM\Column(length: 2, nullable: false)]
protected string $iso;

/**
* @var string
*
* @ORM\Column(name="iso3", type="string", length=3, nullable=false)
*/
#[ORM\Column(length: 3, nullable: false)]
protected string $iso3;

/**
* @var integer
*
* @ORM\Column(name="iso_numeric", type="integer", length=3, nullable=false)
*/
#[ORM\Column(length: 3, nullable: false)]
protected int $isoNumeric;


/**
* @var string
*
* @ORM\Column(name="fips", type="string", length=2, nullable=true)
*/
#[ORM\Column(length: 2, nullable: true)]
protected ?string $fips;


/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
#[ORM\Column(nullable: false)]
protected string $name;

/**
* @var string
*
* @ORM\Column(name="capital", type="string", length=255, nullable=true)
*/
#[ORM\Column(nullable: true)]
protected ?string $capital;


/**
* @var integer
*
* @ORM\Column(name="area", type="bigint", nullable=false)
*/
#[ORM\Column(type: "bigint", nullable: false)]
protected int $area;

/**
* @var int
*
* @ORM\Column(name="population", type="bigint", nullable=false)
*/

#[ORM\Column(type: "bigint", nullable: false)]
protected int $population;

/**
* @var string
*
* @ORM\Column(name="tld", type="string", length=15, nullable=true)
*/
#[ORM\Column(length: 15, nullable: true)]
protected ?string $tld;

/**
* @var string
*
* @ORM\Column(name="currency", type="string", length=3, nullable=true)
*/

#[ORM\Column(length: 3, nullable: true)]
protected ?string $currency;

/**
* @var string
*
* @ORM\Column(name="currency_name", type="string", length=50, nullable=true)
*/
#[ORM\Column(length: 50, nullable: true)]
protected ?string $currencyName;


/**
* @var int
*
* @ORM\Column(name="phone_prefix", type="integer", nullable=true)
*/
#[ORM\Column(nullable: true)]
protected ?int $phonePrefix;


/**
* @var string
*
* @ORM\Column(name="postal_format", type="text", nullable=true)
*/
#[ORM\Column(type: "text", nullable: true)]
protected ?string $postalFormat;

/**
* @var string
*
* @ORM\Column(name="postal_regex", type="text", nullable=true)
*/
#[ORM\Column(type: "text", nullable: true)]
protected ?string $postalRegex;


/**
* @var array
*
* @ORM\Column(name="languages", type="json", nullable=true)
*/
#[ORM\Column(type: "json", nullable: true)]
protected ?array $languages;

/**
* @var GeoName
*
* @ORM\ManyToOne(targetEntity="Bordeux\Bundle\GeoNameBundle\Entity\GeoName")
* @ORM\JoinColumn(name="geoname_id", referencedColumnName="id", nullable=true)
*/
#[ORM\ManyToOne(targetEntity: GeoName::class)]
#[ORM\JoinColumn(name: "continent_id", referencedColumnName: "id", nullable: true)]
protected ?GeoName $continent;

#[ORM\ManyToOne(targetEntity: GeoName::class)]
#[ORM\JoinColumn(name: "geoname_id", referencedColumnName: "id", nullable: true)]
protected ?GeoName $geoName;

/**
Expand Down Expand Up @@ -450,7 +377,22 @@ public function setGeoName(?GeoName $geoName): self
$this->geoName = $geoName;
return $this;
}

/**
* @param GeoName|null $geoName
* @return $this
*/
public function setContinent(?GeoName $geoName): self
{
$this->continent = $geoName;
return $this;
}
/**
* @return GeoName|null
*/
public function getContinent(): ?GeoName
{
return $this->continent;
}
/**
* @return string
*/
Expand Down
Loading