Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
50 changes: 25 additions & 25 deletions src/LiveComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ to familiarize yourself in the `TwigComponent documentation`_.

A real-time product search component might look like this::

// src/Twig/Components/ProductSearch.php
namespace App\Twig\Components;
// src/Twig/Component/ProductSearch.php
namespace App\Twig\Component;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
Expand Down Expand Up @@ -109,8 +109,8 @@ documentation to get the basics of Twig components.

Suppose you've already built a basic Twig component::

// src/Twig/Components/RandomNumber.php
namespace App\Twig\Components;
// src/Twig/Component/RandomNumber.php
namespace App\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

Expand All @@ -137,7 +137,7 @@ re-rendered live on the frontend), replace the component's

.. code-block:: diff

// src/Twig/Components/RandomNumber.php
// src/Twig/Component/RandomNumber.php
- use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
+ use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
+ use Symfony\UX\LiveComponent\DefaultActionTrait;
Expand Down Expand Up @@ -199,8 +199,8 @@ LiveProps: Stateful Component Properties

Let's make our component more flexible by adding a ``$max`` property::

// src/Twig/Components/RandomNumber.php
namespace App\Twig\Components;
// src/Twig/Component/RandomNumber.php
namespace App\Twig\Component;

// ...
use Symfony\UX\LiveComponent\Attribute\LiveProp;
Expand Down Expand Up @@ -299,7 +299,7 @@ Well, actually, we're missing one step. By default, a ``LiveProp`` is

.. code-block:: diff

// src/Twig/Components/RandomNumber.php
// src/Twig/Component/RandomNumber.php
// ...

class RandomNumber
Expand Down Expand Up @@ -1064,8 +1064,8 @@ that, when clicked, sets the min/max numbers back to a default value.
First, add a method with a ``LiveAction`` attribute above it that does
the work::

// src/Twig/Components/RandomNumber.php
namespace App\Twig\Components;
// src/Twig/Component/RandomNumber.php
namespace App\Twig\Component;

// ...
use Symfony\UX\LiveComponent\Attribute\LiveAction;
Expand Down Expand Up @@ -1139,8 +1139,8 @@ normal controller method that you would create with a route.

This means that, for example, you can use action autowiring::

// src/Twig/Components/RandomNumber.php
namespace App\Twig\Components;
// src/Twig/Component/RandomNumber.php
namespace App\Twig\Component;

// ...
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -1192,8 +1192,8 @@ You can also pass arguments to your action by adding each as a
In your component, to allow each argument to be passed, add
the ``#[LiveArg]`` attribute::

// src/Twig/Components/ItemList.php
namespace App\Twig\Components;
// src/Twig/Component/ItemList.php
namespace App\Twig\Component;

// ...
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -1233,8 +1233,8 @@ Sometimes, you may want to redirect after an action is executed
page). You can do that by returning a ``RedirectResponse`` from your
action::

// src/Twig/Components/RandomNumber.php
namespace App\Twig\Components;
// src/Twig/Component/RandomNumber.php
namespace App\Twig\Component;

// ...
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down Expand Up @@ -1302,8 +1302,8 @@ You can also specify a modifier parameter to choose which files should be upload

The files will be available in a regular ``$request->files`` files bag::

// src/Twig/Components/FileUpload.php
namespace App\Twig\Components;
// src/Twig/Component/FileUpload.php
namespace App\Twig\Component;

use Symfony\Component\HttpFoundation\Request;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
Expand Down Expand Up @@ -1426,7 +1426,7 @@ Ok: time to build that ``PostForm`` component! The Live Components
package comes with a special trait - ``ComponentWithFormTrait`` - to
make it easy to deal with forms::

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Post;
use App\Form\PostType;
Expand Down Expand Up @@ -2523,8 +2523,8 @@ Changing the URL when a LiveProp changes

If you want the URL to update when a ``LiveProp`` changes, you can do that with the ``url`` option::

// src/Twig/Components/SearchModule.php
namespace App\Twig\Components;
// src/Twig/Component/SearchModule.php
namespace App\Twig\Component;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
Expand Down Expand Up @@ -3142,7 +3142,7 @@ Full Embedded Component Example
Let's look at a full, complex example of an embedded component. Suppose
you have an ``EditPost``::

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Post;
use Doctrine\ORM\EntityManagerInterface;
Expand All @@ -3168,7 +3168,7 @@ you have an ``EditPost``::

And a ``MarkdownTextarea``::

namespace App\Twig\Components;
namespace App\Twig\Component;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
Expand Down Expand Up @@ -3596,7 +3596,7 @@ Then specify this new route on your component:

.. code-block:: diff

// src/Twig/Components/RandomNumber.php
// src/Twig/Component/RandomNumber.php
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;

Expand All @@ -3615,7 +3615,7 @@ You can also control the type of the generated URL:

.. code-block:: diff

// src/Twig/Components/RandomNumber.php
// src/Twig/Component/RandomNumber.php
+ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;
Expand Down
2 changes: 1 addition & 1 deletion src/Map/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ and implement the method ``instantiateMap`` to return a ``Map`` instance.

You can interact with the Map by using ``LiveAction`` attribute::

namespace App\Twig\Components;
namespace App\Twig\Component;

use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
Expand Down
24 changes: 12 additions & 12 deletions src/TwigComponent/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ making it easier to render and re-use small template "units" - like an

Every component consists of (1) a class::

// src/Twig/Components/Alert.php
namespace App\Twig\Components;
// src/Twig/Component/Alert.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// src/Twig/Component/Alert.php
// src/Twig/Component/Alert.php

Something we will discuss in 3.0 .. but i totally agree.

To be fair, i even think we should use src/Component

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do have "devland codebase" component (relatively to symfony component)
having them at root level with "twig component" seems wrong to me

namespace App\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

Expand Down Expand Up @@ -79,8 +79,8 @@ Let's create a reusable "alert" element that we can use to show success
or error messages across our site. Step 1 is to create a component class
and give it the ``AsTwigComponent`` attribute::

// src/Twig/Components/Alert.php
namespace App\Twig\Components;
// src/Twig/Component/Alert.php
namespace App\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

Expand Down Expand Up @@ -166,7 +166,7 @@ public property for each:

.. code-block:: diff

// src/Twig/Components/Alert.php
// src/Twig/Component/Alert.php
// ...

#[AsTwigComponent]
Expand Down Expand Up @@ -265,7 +265,7 @@ You can control the template used via the ``AsTwigComponent`` attribute:

.. code-block:: diff

// src/Twig/Components/Alert.php
// src/Twig/Component/Alert.php
// ...

- #[AsTwigComponent]
Expand Down Expand Up @@ -396,8 +396,8 @@ How? Components are *services*, which means autowiring works like
normal. This example assumes you have a ``Product`` Doctrine entity and
``ProductRepository``::

// src/Twig/Components/FeaturedProducts.php
namespace App\Twig\Components;
// src/Twig/Component/FeaturedProducts.php
namespace App\Twig\Component;

use App\Repository\ProductRepository;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
Expand Down Expand Up @@ -457,7 +457,7 @@ The mount() Method
For more control over how your "props" are handled, you can create a method
called ``mount()``::

// src/Twig/Components/Alert.php
// src/Twig/Component/Alert.php
// ...

#[AsTwigComponent]
Expand Down Expand Up @@ -497,7 +497,7 @@ PreMount Hook
If you need to modify/validate data before it's *mounted* on the
component use a ``PreMount`` hook::

// src/Twig/Components/Alert.php
// src/Twig/Component/Alert.php
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\UX\TwigComponent\Attribute\PreMount;
// ...
Expand Down Expand Up @@ -557,7 +557,7 @@ PostMount Hook
After a component is instantiated and its data mounted, you can run extra
code via the ``PostMount`` hook::

// src/Twig/Components/Alert.php
// src/Twig/Component/Alert.php
use Symfony\UX\TwigComponent\Attribute\PostMount;
// ...

Expand All @@ -580,7 +580,7 @@ will contain any props passed to the component that have *not* yet been processe
``mount()`` method). You can handle these props, remove them from the ``$data``
and return the array::

// src/Twig/Components/Alert.php
// src/Twig/Component/Alert.php
#[AsTwigComponent]
class Alert
{
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/BootstrapModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/ChangelogItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/DinoChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Service\DinoStatsService;
use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/DocsLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/FoodVote.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Food;
use App\Repository\FoodRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Model\UxPackage;
use App\Service\UxPackageRepository;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/InlineEditFood.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Food;
use Doctrine\ORM\EntityManagerInterface;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/InvoiceCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Invoice;
use App\Entity\InvoiceItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Product;
use App\Repository\ProductRepository;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/MealPlanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Form\MealPlannerForm;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/NewCategoryForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Category;
use Doctrine\ORM\EntityManagerInterface;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/NewProductForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Entity\Category;
use App\Entity\Product;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/ProductGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Service\EmojiCollection;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
Expand Down
2 changes: 1 addition & 1 deletion ux.symfony.com/src/Twig/Components/ProductGrid2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace App\Twig\Components;
namespace App\Twig\Component;

use App\Service\EmojiCollection;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
Expand Down
Loading
Loading