Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update Associations with fix code-block example#12812

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:4.4fromTheGarious:patch-17
Mar 12, 2020
Merged
Changes fromall commits
Commits
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
14 changes: 10 additions & 4 deletionsdoctrine/associations.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,7 @@ In this case, you'll need a ``Category`` class, and a way to relate a

Start by creating a ``Category`` entity with a ``name`` field:

.. code-block::terminal
.. code-block::bash

$ php bin/console make:entity Category

Expand All@@ -64,6 +64,8 @@ Start by creating a ``Category`` entity with a ``name`` field:
This will generate your new entity class::

// src/Entity/Category.php
namespace App\Entity;

// ...

class Category
Expand DownExpand Up@@ -99,7 +101,7 @@ the ``ManyToOne`` annotation. You can do this by hand, or by using the ``make:en
command, which will ask you several questions about your relationship. If you're
not sure of the answer, don't worry! You can always change the settings later:

.. code-block::terminal
.. code-block::bash

$ php bin/console make:entity

Expand DownExpand Up@@ -144,6 +146,7 @@ the ``Product`` entity (and getter & setter methods):
.. code-block:: php-annotations

// src/Entity/Product.php
namespace App\Entity;

// ...
class Product
Expand DownExpand Up@@ -214,7 +217,8 @@ class that will hold these objects:
.. code-block:: php-annotations

// src/Entity/Category.php

namespace App\Entity;

// ...
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand DownExpand Up@@ -310,8 +314,10 @@ Saving Related Entities

Now you can see this new code in action! Imagine you're inside a controller::

// src/Controller/ProductController.php
namespace App/Controller;

// ...

use App\Entity\Category;
use App\Entity\Product;
use Symfony\Component\HttpFoundation\Response;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp