From 84c154184afedf80041a365b25a0f6274075d598 Mon Sep 17 00:00:00 2001 From: Noel Garcia Date: Fri, 17 Feb 2017 17:45:04 +0100 Subject: [PATCH 1/5] added a tip to register annotations namespaces --- components/routing.rst | 20 ++++++++++++++++++++ components/serializer.rst | 20 ++++++++++++++++++++ components/validator/resources.rst | 15 +++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/components/routing.rst b/components/routing.rst index 686faf31ccb..1b889206537 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -312,6 +312,26 @@ Last but not least there are route definitions from class annotations. The specific details are left out here. +.. note:: + + In order to use the annotation loader, you should have installed the + ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. + +.. tip:: + +   Remember that annotation classes aren't loaded automatically, so you should load + them like Symfony usually does in the ``app/autoload.php`` file:: + +       use Composer\Autoload\ClassLoader; + use Doctrine\Common\Annotations\AnnotationRegistry; + + /** @var ClassLoader $loader */ + $loader = require __DIR__.'/../vendor/autoload.php'; + + AnnotationRegistry::registerLoader([$loader, 'loadClass']); + + return $loader; + The all-in-one Router ~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/serializer.rst b/components/serializer.rst index cb16d951afc..5cea6eee643 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -314,6 +314,26 @@ You are now able to serialize only attributes in the groups you want:: .. _ignoring-attributes-when-serializing: +.. note:: + + In order to use the annotation loader, you should have installed the + ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. + +.. tip:: + +   Remember that annotation classes aren't loaded automatically, so you should load + them like Symfony usually does in the ``app/autoload.php`` file:: + +       use Composer\Autoload\ClassLoader; + use Doctrine\Common\Annotations\AnnotationRegistry; + + /** @var ClassLoader $loader */ + $loader = require __DIR__.'/../vendor/autoload.php'; + + AnnotationRegistry::registerLoader([$loader, 'loadClass']); + + return $loader; + Ignoring Attributes ------------------- diff --git a/components/validator/resources.rst b/components/validator/resources.rst index 23e5ba83cde..cbd9573fdfa 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -124,6 +124,21 @@ To disable the annotation loader after it was enabled, call In order to use the annotation loader, you should have installed the ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. +.. tip:: + +   Remember that annotation classes aren't loaded automatically, so you should load + them like Symfony usually does in the ``app/autoload.php`` file:: + +       use Composer\Autoload\ClassLoader; + use Doctrine\Common\Annotations\AnnotationRegistry; + + /** @var ClassLoader $loader */ + $loader = require __DIR__.'/../vendor/autoload.php'; + + AnnotationRegistry::registerLoader([$loader, 'loadClass']); + + return $loader; + Using Multiple Loaders ---------------------- From 0ddf3d21b12c05fb5b34f982feb4005dab877185 Mon Sep 17 00:00:00 2001 From: Noel Date: Sun, 6 Aug 2017 13:35:18 +0200 Subject: [PATCH 2/5] moved the tips to an include fragment file --- _includes/_annotation_loader_tip.rst.inc | 19 +++++++++++++++++++ components/routing.rst | 20 +------------------- components/serializer.rst | 20 +------------------- components/validator/resources.rst | 20 +------------------- 4 files changed, 22 insertions(+), 57 deletions(-) create mode 100644 _includes/_annotation_loader_tip.rst.inc diff --git a/_includes/_annotation_loader_tip.rst.inc b/_includes/_annotation_loader_tip.rst.inc new file mode 100644 index 00000000000..c0daf86570f --- /dev/null +++ b/_includes/_annotation_loader_tip.rst.inc @@ -0,0 +1,19 @@ +.. note:: + + In order to use the annotation loader, you should have installed the + ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. + +.. tip:: + +   Remember that annotation classes aren't loaded automatically, so you should load + them like Symfony usually does in the ``app/autoload.php`` file:: + +       use Composer\Autoload\ClassLoader; + use Doctrine\Common\Annotations\AnnotationRegistry; + + /** @var ClassLoader $loader */ + $loader = require __DIR__.'/../vendor/autoload.php'; + + AnnotationRegistry::registerLoader([$loader, 'loadClass']); + + return $loader; diff --git a/components/routing.rst b/components/routing.rst index 1b889206537..1b8c291fa6e 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -312,25 +312,7 @@ Last but not least there are route definitions from class annotations. The specific details are left out here. -.. note:: - - In order to use the annotation loader, you should have installed the - ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. - -.. tip:: - -   Remember that annotation classes aren't loaded automatically, so you should load - them like Symfony usually does in the ``app/autoload.php`` file:: - -       use Composer\Autoload\ClassLoader; - use Doctrine\Common\Annotations\AnnotationRegistry; - - /** @var ClassLoader $loader */ - $loader = require __DIR__.'/../vendor/autoload.php'; - - AnnotationRegistry::registerLoader([$loader, 'loadClass']); - - return $loader; +.. include:: /_includes/_rewrite_rule_tip.rst.inc The all-in-one Router ~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/serializer.rst b/components/serializer.rst index 5cea6eee643..af8dd06bd0d 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -314,25 +314,7 @@ You are now able to serialize only attributes in the groups you want:: .. _ignoring-attributes-when-serializing: -.. note:: - - In order to use the annotation loader, you should have installed the - ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. - -.. tip:: - -   Remember that annotation classes aren't loaded automatically, so you should load - them like Symfony usually does in the ``app/autoload.php`` file:: - -       use Composer\Autoload\ClassLoader; - use Doctrine\Common\Annotations\AnnotationRegistry; - - /** @var ClassLoader $loader */ - $loader = require __DIR__.'/../vendor/autoload.php'; - - AnnotationRegistry::registerLoader([$loader, 'loadClass']); - - return $loader; +.. include:: /_includes/_rewrite_rule_tip.rst.inc Ignoring Attributes ------------------- diff --git a/components/validator/resources.rst b/components/validator/resources.rst index cbd9573fdfa..b8e16755cda 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -119,25 +119,7 @@ method. It takes an optional annotation reader instance, which defaults to To disable the annotation loader after it was enabled, call :method:`Symfony\\Component\\Validator\\ValidatorBuilder::disableAnnotationMapping`. -.. note:: - - In order to use the annotation loader, you should have installed the - ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. - -.. tip:: - -   Remember that annotation classes aren't loaded automatically, so you should load - them like Symfony usually does in the ``app/autoload.php`` file:: - -       use Composer\Autoload\ClassLoader; - use Doctrine\Common\Annotations\AnnotationRegistry; - - /** @var ClassLoader $loader */ - $loader = require __DIR__.'/../vendor/autoload.php'; - - AnnotationRegistry::registerLoader([$loader, 'loadClass']); - - return $loader; +.. include:: /_includes/_rewrite_rule_tip.rst.inc Using Multiple Loaders ---------------------- From 19c89daf85747da34a86760994b1ee14307909ad Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 29 Dec 2017 08:45:56 +0100 Subject: [PATCH 3/5] Minor reword --- _includes/_annotation_loader_tip.rst.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_includes/_annotation_loader_tip.rst.inc b/_includes/_annotation_loader_tip.rst.inc index c0daf86570f..098407582fb 100644 --- a/_includes/_annotation_loader_tip.rst.inc +++ b/_includes/_annotation_loader_tip.rst.inc @@ -1,12 +1,12 @@ .. note:: In order to use the annotation loader, you should have installed the - ``doctrine/annotations`` and ``doctrine/cache`` packages from `Packagist`_. + ``doctrine/annotations`` and ``doctrine/cache`` packages with Composer. .. tip:: -   Remember that annotation classes aren't loaded automatically, so you should load - them like Symfony usually does in the ``app/autoload.php`` file:: +   Annotation classes aren't loaded automatically, so you must load them + like Symfony does in the ``app/autoload.php`` file::       use Composer\Autoload\ClassLoader; use Doctrine\Common\Annotations\AnnotationRegistry; From f56b5af7f1b2e1e03b4a312df7c5311532be23b3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 29 Dec 2017 08:46:34 +0100 Subject: [PATCH 4/5] Moved the note before the label --- components/serializer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index af8dd06bd0d..668039f4b05 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -312,10 +312,10 @@ You are now able to serialize only attributes in the groups you want:: ); // $obj2 = MyObj(foo: 'foo', bar: 'bar') -.. _ignoring-attributes-when-serializing: - .. include:: /_includes/_rewrite_rule_tip.rst.inc +.. _ignoring-attributes-when-serializing: + Ignoring Attributes ------------------- From 1ce3a43b41cac12ff229d5585db2f5c858246652 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 12 Jan 2018 09:49:04 +0100 Subject: [PATCH 5/5] Removed the reference to specific Symfony files --- _includes/_annotation_loader_tip.rst.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/_annotation_loader_tip.rst.inc b/_includes/_annotation_loader_tip.rst.inc index 098407582fb..ed43b8f51d8 100644 --- a/_includes/_annotation_loader_tip.rst.inc +++ b/_includes/_annotation_loader_tip.rst.inc @@ -5,8 +5,8 @@ .. tip:: -   Annotation classes aren't loaded automatically, so you must load them - like Symfony does in the ``app/autoload.php`` file:: + Annotation classes aren't loaded automatically, so you must load them + using a class loader like this::       use Composer\Autoload\ClassLoader; use Doctrine\Common\Annotations\AnnotationRegistry;