-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 2.20.x: Bump doctrine/.github from 5.1.0 to 5.2.0 (#11680) Psalm 5.26.1 (#11677) Update README (#11673) Fix PHPUnit deprecations Bump doctrine/.github from 5.1.0 to 5.2.0 (#11671) Experiment with literalinclude
- Loading branch information
Showing
22 changed files
with
248 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
docs/en/tutorials/working-with-indexed-associations/Market-annotations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Models\StockExchange; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\GeneratedValue; | ||
use Doctrine\ORM\Mapping\Id; | ||
use Doctrine\ORM\Mapping\OneToMany; | ||
use Doctrine\ORM\Mapping\Table; | ||
use InvalidArgumentException; | ||
|
||
/** | ||
* @Entity | ||
* @Table(name="exchange_markets") | ||
*/ | ||
class Market | ||
{ | ||
/** | ||
* @Id @Column(type="integer") @GeneratedValue | ||
* @var int | ||
*/ | ||
private int|null $id = null; | ||
|
||
/** | ||
* @Column(type="string") | ||
* @var string | ||
*/ | ||
private string $name; | ||
|
||
/** | ||
* @OneToMany(targetEntity="Stock", mappedBy="market", indexBy="symbol") | ||
* @var Collection<int, Stock> | ||
*/ | ||
private Collection $stocks; | ||
|
||
public function __construct($name) | ||
{ | ||
$this->name = $name; | ||
$this->stocks = new ArrayCollection(); | ||
} | ||
|
||
public function getId(): int|null | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function addStock(Stock $stock): void | ||
{ | ||
$this->stocks[$stock->getSymbol()] = $stock; | ||
} | ||
|
||
public function getStock($symbol): Stock | ||
{ | ||
if (!isset($this->stocks[$symbol])) { | ||
throw new InvalidArgumentException("Symbol is not traded on this market."); | ||
} | ||
|
||
return $this->stocks[$symbol]; | ||
} | ||
|
||
/** @return array<string, Stock> */ | ||
public function getStocks(): array | ||
{ | ||
return $this->stocks->toArray(); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
docs/en/tutorials/working-with-indexed-associations/Market.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\StockExchange; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\GeneratedValue; | ||
use Doctrine\ORM\Mapping\Id; | ||
use Doctrine\ORM\Mapping\OneToMany; | ||
use Doctrine\ORM\Mapping\Table; | ||
use InvalidArgumentException; | ||
|
||
#[Entity] | ||
#[Table(name: 'exchange_markets')] | ||
class Market | ||
{ | ||
#[Id] | ||
#[Column(type: 'integer')] | ||
#[GeneratedValue] | ||
private int|null $id = null; | ||
|
||
#[Column(type: 'string')] | ||
private string $name; | ||
|
||
/** @var Collection<string, Stock> */ | ||
#[OneToMany(targetEntity: Stock::class, mappedBy: 'market', indexBy: 'symbol')] | ||
private Collection $stocks; | ||
|
||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
$this->stocks = new ArrayCollection(); | ||
} | ||
|
||
public function getId(): int|null | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function addStock(Stock $stock): void | ||
{ | ||
$this->stocks[$stock->getSymbol()] = $stock; | ||
} | ||
|
||
public function getStock(string $symbol): Stock | ||
{ | ||
if (! isset($this->stocks[$symbol])) { | ||
throw new InvalidArgumentException('Symbol is not traded on this market.'); | ||
} | ||
|
||
return $this->stocks[$symbol]; | ||
} | ||
|
||
/** @return array<string, Stock> */ | ||
public function getStocks(): array | ||
{ | ||
return $this->stocks->toArray(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
docs/en/tutorials/working-with-indexed-associations/market.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping | ||
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> | ||
|
||
<entity name="Doctrine\Tests\Models\StockExchange\Market"> | ||
<id name="id" type="integer"> | ||
<generator strategy="AUTO" /> | ||
</id> | ||
|
||
<field name="name" type="string"/> | ||
|
||
<one-to-many target-entity="Stock" mapped-by="market" field="stocks" index-by="symbol" /> | ||
</entity> | ||
</doctrine-mapping> |
15 changes: 15 additions & 0 deletions
15
docs/en/tutorials/working-with-indexed-associations/market.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Doctrine\Tests\Models\StockExchange\Market: | ||
type: entity | ||
id: | ||
id: | ||
type: integer | ||
generator: | ||
strategy: AUTO | ||
fields: | ||
name: | ||
type:string | ||
oneToMany: | ||
stocks: | ||
targetEntity: Stock | ||
mappedBy: market | ||
indexBy: symbol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.