@@ -209,9 +209,9 @@ inside the ``Entity`` directory of your AppBundle::
209209
210210 class Product
211211 {
212- protected $name;
213- protected $price;
214- protected $description;
212+ private $name;
213+ private $price;
214+ private $description;
215215 }
216216
217217The class - often called an "entity", meaning *a basic class that holds data * -
@@ -274,22 +274,22 @@ directly inside the ``Product`` class via DocBlock annotations:
274274 * @ORM\Id
275275 * @ORM\GeneratedValue(strategy="AUTO")
276276 */
277- protected $id;
277+ private $id;
278278
279279 /**
280280 * @ORM\Column(type="string", length=100)
281281 */
282- protected $name;
282+ private $name;
283283
284284 /**
285285 * @ORM\Column(type="decimal", scale=2)
286286 */
287- protected $price;
287+ private $price;
288288
289289 /**
290290 * @ORM\Column(type="text")
291291 */
292- protected $description;
292+ private $description;
293293 }
294294
295295 .. code-block :: yaml
@@ -391,10 +391,10 @@ Generating Getters and Setters
391391
392392Even though Doctrine now knows how to persist a ``Product `` object to the
393393database, the class itself isn't really useful yet. Since ``Product `` is just
394- a regular PHP class with ``protected `` properties, you need to create ``public ``
394+ a regular PHP class with ``private `` properties, you need to create ``public ``
395395getter and setter methods (e.g. ``getName() ``, ``setName($name) ``) in order
396- to access its properties. Fortunately, the following command can generate
397- these boilerplate methods automatically:
396+ to access its properties in the rest of your application's code. Fortunately,
397+ the following command can generate these boilerplate methods automatically:
398398
399399.. code-block :: bash
400400
@@ -444,13 +444,6 @@ mapping information) of a bundle or an entire namespace:
444444 # generates all entities of bundles in the Acme namespace
445445 $ php app/console doctrine:generate:entities Acme
446446
447- .. note ::
448-
449- Doctrine doesn't care whether your properties are ``protected `` or ``private ``,
450- or whether corresponding getter/setter methods exist for your properties.
451- Using getters and setters is suggested here only because you'll need them
452- to interact with your PHP object in the rest of your application's code.
453-
454447 .. _book-doctrine-creating-the-database-tables-schema :
455448
456449Creating the Database Tables/Schema
@@ -944,7 +937,7 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
944937 /**
945938 * @ORM\OneToMany(targetEntity="Product", mappedBy="category")
946939 */
947- protected $products;
940+ private $products;
948941
949942 public function __construct()
950943 {
@@ -1027,7 +1020,7 @@ object, you'll want to add a ``$category`` property to the ``Product`` class:
10271020 * @ORM\ManyToOne(targetEntity="Category", inversedBy="products")
10281021 * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
10291022 */
1030- protected $category;
1023+ private $category;
10311024 }
10321025
10331026 .. code-block :: yaml
0 commit comments