[Docs] Redirect Mailer & MailerBundle docs to external URL

This commit is contained in:
Kamil Kokot 2020-05-11 15:37:38 +02:00
parent 90a170f13e
commit 408b3df55c
No known key found for this signature in database
GPG key ID: 7BD76F7054D93C89
18 changed files with 16 additions and 629 deletions

View file

@ -5,7 +5,7 @@ E-Mails
=======
Sylius is sending various e-mails and this chapter is a reference about all of them. Continue reading to learn what e-mails are sent, when and how to customize the templates.
To understand how e-mail sending works internally, please refer to :doc:`SyliusMailerBundle documentation </components_and_bundles/bundles/SyliusMailerBundle/index>`.
To understand how e-mail sending works internally, please refer to `SyliusMailerBundle documentation <https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md>`_.
And to learn more about mailer services configuration, read :doc:`the dedicated cookbook </cookbook/emails/mailer>`.
User Confirmation
@ -212,5 +212,4 @@ Example using **EmailManager**:
Learn more
----------
* :doc:`Mailer - Component Documentation </components_and_bundles/components/Mailer/index>`
* :doc:`Mailer - Bundle Documentation </components_and_bundles/bundles/SyliusMailerBundle/index>`
* `Mailer - Documentation <https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md>`_

View file

@ -1,30 +0,0 @@
Configuration reference
=======================
.. code-block:: yaml
sylius_mailer:
sender_adapter: sylius.email_sender.adapter.swiftmailer # Adapter for sending e-mails.
renderer_adapter: sylius.email_renderer.adapter.twig # Adapter for rendering e-mails.
sender:
name: # Required - default sender name.
address: # Required - default sender e-mail address.
templates: # Your templates available for selection in backend!
label: Template path
label: Template path
label: Template path
emails:
your_email:
subject: Subject of your email
template: App:Email:yourEmail.html.twig
enabled: true/false
sender:
name: Custom name
address: Custom sender address for this e-mail
your_another_email:
subject: Subject of your another email
template: App:Email:yourAnotherEmail.html.twig
enabled: true/false
sender:
name: Custom name
address: Custom sender address for this e-mail

View file

@ -1,26 +0,0 @@
SyliusMailerBundle
==================
Sending customizable e-mails has never been easier in Symfony.
You can configure different e-mail types in the YAML or in database. (and use YAML as fallback)
This allows you to send out e-mails with one simple method call, providing an unique code and data.
The bundle supports adapters, by default e-mails are rendered using Twig and sent via Swiftmailer, but you can easily implement your own adapter and delegate the whole operation to external API.
This bundle provides easy integration of the :doc:`Sylius Mailer component </components_and_bundles/components/Mailer/index>`
with any Symfony full-stack application.
.. toctree::
:maxdepth: 1
:numbered:
installation
your_first_email
using_custom_adapter
configuration
Learn more
----------
* :doc:`Emails in the Sylius platform </book/architecture/emails>` - concept documentation

View file

@ -1,53 +0,0 @@
Installation
============
We assume you're familiar with `Composer <http://packagist.org>`_, a dependency manager for PHP.
Use the following command to add the bundle to your `composer.json` and download the package.
If you have `Composer installed globally <http://getcomposer.org/doc/00-intro.md#globally>`_.
.. code-block:: bash
composer require sylius/mailer-bundle
Otherwise you have to download .phar file.
.. code-block:: bash
curl -sS https://getcomposer.org/installer | php
php composer.phar require sylius/mailer-bundle
Adding required bundles to the kernel
-------------------------------------
You need to enable the bundle inside the kernel.
.. code-block:: php
<?php
// config/bundles.php
return [
new winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Sylius\Bundle\MailerBundle\SyliusMailerBundle(),
];
Container configuration
-----------------------
Put this configuration inside your ``config/packages/sylius_mailer.yaml``.
.. code-block:: yaml
sylius_mailer:
sender:
name: My website
address: no-reply@my-website.com
Congratulations! The bundle is now installed and ready to use.

View file

@ -1,46 +0,0 @@
Using Custom Adapter
====================
There are certain use cases, where you do not want to send the e-mail from your app, but delegate the task to an external API.
It is really simple with Adapters system!
Implement Your Adapter
----------------------
Create your adapter class and add your custom logic for sending:
.. code-block:: php
<?php
namespace App\Mailer\Adapter;
use Sylius\Component\Mailer\Sender\Adapter\AbstractAdapter;
use Sylius\Component\Mailer\Model\EmailInterface;
use Sylius\Component\Mailer\Renderer\RenderedEmail;
class CustomAdapter extends AbstractAdapter
{
public function send(array $recipients, $senderAddress, $senderName, RenderedEmail $renderedEmail, EmailInterface $email, array $data)
{
// Your custom logic.
}
}
Register And Configure New Adapter In Container
-----------------------------------------------
In your ``config/packages/sylius_mailer.yaml`` file, add your adapter definition and configure the mailer to use it.
.. code-block:: yaml
services:
app.email_sender.adapter.custom:
parent: sylius.email_sender.adapter.abstract
class: App\Mailer\Adapter\CustomAdapter
sylius_mailer:
sender_adapter: app.email_sender.adapter.custom
That's it! Your new adapter will be used to send out e-mails. You can do whatever you want there!

View file

@ -1,104 +0,0 @@
Your First Email
================
Let's say you want to send a notification to the website team when someone submits a new position to your movie catalog website!
You can do it in few simple steps:
Configure Your E-Mail
---------------------
In your ``config/packages/sylius_mailer.yaml``, under ``sylius_mailer`` you should configure the email:
.. code-block:: yaml
# config/packages/sylius_mailer.yaml
sylius_mailer:
sender:
name: Movie Database Example
address: no-reply@movie-database-example.com
emails:
movie_added_notification:
subject: A new movie {{ movie.title }} has been submitted
template: "Email/movieAddedNotification.html.twig"
That's it! Your unique code is "movie_added_notification". Now, let's create the template.
Creating Your Template
----------------------
In your ``templates/Email/movieAddedNotification.html.twig`` put the following Twig code:
.. code-block:: twig
{% block subject %}
A new movie {{ movie.title }} has been submitted
{% endblock %}
{% block body %}
Hello Movie Database Example!
A new movie has been submitted for review to your database.
Title: {{ movie.title }}
Added by {{ user.name }}
Please review it and accept or reject!
{% endblock %}
That should be enough!
Sending The E-Mail
------------------
The service responsible for sending an e-mail has id ``sylius.email_sender``. All you need to do is retrieve it from the container or inject to a listener:
.. code-block:: php
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
class MovieController
{
public function submitAction(Request $request)
{
// Your code.
$this->get('sylius.email_sender')->send('movie_added_notification', array('team@website.com'), array('movie' => $movie, 'user' => $this->getUser()));
}
}
Listener example:
.. code-block:: php
<?php
namespace App\Controller;
use App\Event\MovieCreatedEvent;
use Sylius\Component\Mailer\Sender\SenderInterface;
class MovieNotificationListener
{
private $sender;
public function __construct(SenderInterface $sender)
{
$this->sender = $sender;
}
public function onMovieCreation(MovieCreatedEvent $event)
{
$movie = $event->getMovie();
$user = $event->getUser();
$this->sender->send('movie_added_notification', array('team@website.com'), array('movie' => $movie, 'user' => $user));
}
}
We recommend using events approach, but you can send e-mails from anywhere in your application. Enjoy!

View file

@ -9,7 +9,6 @@ Sylius Bundles Documentation
SyliusCustomerBundle/index
SyliusGridBundle/index
SyliusInventoryBundle/index
SyliusMailerBundle/index
SyliusOrderBundle/index
SyliusProductBundle/index
SyliusPromotionBundle/index

View file

@ -4,7 +4,7 @@
* `SyliusFixturesBundle <https://github.com/Sylius/SyliusFixturesBundle/blob/master/docs/index.md>`_
* :doc:`/components_and_bundles/bundles/SyliusGridBundle/index`
* :doc:`/components_and_bundles/bundles/SyliusInventoryBundle/index`
* :doc:`/components_and_bundles/bundles/SyliusMailerBundle/index`
* `SyliusMailerBundle <https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md>`_
* :doc:`/components_and_bundles/bundles/SyliusOrderBundle/index`
* :doc:`/components_and_bundles/bundles/SyliusProductBundle/index`
* :doc:`/components_and_bundles/bundles/SyliusPromotionBundle/index`

View file

@ -1,189 +0,0 @@
.. rst-class:: outdated
Basic usage
===========
.. danger::
We're sorry but **this documentation section is outdated**. Please have that in mind when trying to use it.
You can help us making documentation up to date via Sylius Github. Thank you!
Sender
------
.. _component_mailer_sender_adapter_abstract-adapter:
SenderAdapter
~~~~~~~~~~~~~
This is an abstraction layer that allows you to create your own logic of sending an email.
.. code-block:: php
<?php
use Sylius\Component\Mailer\Sender\Adapter\AbstractAdapter as BaseSenderAdapter;
use Sylius\Component\Mailer\Model\EmailInterface;
use Sylius\Component\Mailer\Model\Email;
class SenderAdapter extends BaseSenderAdapter
{
/**
* Send an e-mail.
*
* @param array $recipients
* @param string $senderAddress
* @param string $senderName
* @param RenderedEmail $renderedEmail
* @param EmailInterface $email
*/
public function send(array $recipients, $senderAddress, $senderName, RenderedEmail $renderedEmail, EmailInterface $email, array $data)
{
// TODO: Implement send() method.
}
}
$email = new Email();
$email->setCode('christmas_party_invitation');
$email->setContent('Hi, we would like to invite you to christmas party');
$email->setSubject('Christmas party');
$email->setSenderAddress('mike.ehrmantraut@gmail.com');
$email->setSenderName('Mike Ehrmantraut');
$senderAdapter = new SenderAdapter();
$rendererAdapter = new RendererAdapter();
$renderedEmail = $rendererAdapter->render($email, $data);
$senderAdapter->send(array('john.doe@gmail.com'), $email->getSenderAddress(), $email->getSenderName(), $renderedEmail, $email, array())
.. _component_mailer_sender_sender:
Sender
~~~~~~
This service collects those two adapters **SenderAdapter**, **RendererAdapter** and deals with process of sending an email.
.. code-block:: php
<?php
use Sylius\Component\Mailer\Provider\DefaultSettingsProvider;
use Sylius\Component\Mailer\Provider\EmailProvider;
use Sylius\Component\Mailer\Sender\Sender;
$sender = new Sender($rendererAdapter, $senderAdapter, $emailProvider, $defaultSettingsProvider);
$sender->send('christmas_party_invitation', array('mike.ehrmantraut@gmail.com'));
Renderer
--------
.. _component_mailer_renderer_abstract-adapter:
RendererAdapter
~~~~~~~~~~~~~~~
This is an abstraction layer that allows you to create your own logic of rendering an email object.
.. code-block:: php
<?php
use Sylius\Component\Mailer\Renderer\Adapter\AbstractAdapter as BaseRendererAdapter;
use Sylius\Component\Mailer\Model\EmailInterface;
use Sylius\Component\Mailer\Model\Email;
class RendererAdapter extends BaseRendererAdapter
{
/**
* Render an e-mail.
*
* @param EmailInterface $email
* @param array $data
*
* @return RenderedEmail
*/
public function render(EmailInterface $email, array $data = array())
{
// TODO: Implement render() method.
return new RenderedEmail($subject, $body);
}
}
$email = new Email();
$email->setCode('christmas_party_invitation');
$email->setContent('Hi, we would like to invite you to christmas party');
$email->setSubject('Christmas party');
$email->setSenderAddress('mike.ehrmantraut@gmail.com');
$email->setSenderName('Mike Ehrmantraut');
$rendererAdapter = new RendererAdapter();
$renderedEmail = $rendererAdapter->render($email, $data); // It will render an email object based on your implementation.
$renderedEmail->getBody(); // Output will be Hi, we would .....
$renderedEmail->getSubject(); // Output will be Christmas party.
.. hint::
Renderer should return `RenderedEmail`_
.. _RenderedEmail: http://api.sylius.com/Sylius/Component/Mailer/Renderer/RenderedEmail.html
.. _component_mailer_provider_default-settings-provider:
DefaultSettingsProvider
-----------------------
The **DefaultSettingsProvider** is service which provides you with default sender address and sender name.
.. code-block:: php
<?php
use Sylius\Component\Mailer\Provider\DefaultSettingsProvider;
$defaultSettingsProvider = new DefaultSettingsProvider('Mike Ehrmantraut', 'mike.ehrmantraut@gmail.com');
$defaultSettingsProvider->getSenderAddress(); // mike.ehrmantraut@gmail.com
$defaultSettingsProvider->getSenderName(); // Output will be Mike Ehrmantraut
.. _component_mailer_provider_email-provider:
EmailProvider
-------------
The **EmailProvider** allows you to get specific email from storage.
.. code-block:: php
<?php
use Sylius\Component\Mailer\Provider\EmailProvider;
use Sylius\Component\Resource\Repository\InMemoryRepository;
$inMemoryRepository = new InMemoryRepository();
$configuration = array(
'christmas_party_invitation' => array(
'subject' => 'Christmas party',
'template' => 'email.html.twig',
'enabled' => true,
'sender' => array(
'name' => 'John',
'address' => 'john.doe@gmail.com',
),
),
);
$emailProvider = new EmailProvider($inMemoryRepository, $configuration);
$email = $emailProvider->getEmail('christmas_party_invitation'); // This method will search for an email in your storage or in given configuration.
$email->getCode(); // Output will be christmas_party_invitation.
$email->getSenderAddress(); // Output will be john.doe@gmail.com.
$email->getSenderName(); // Output will be John.

View file

@ -1,24 +0,0 @@
.. rst-class:: outdated
Mailer
======
.. danger::
We're sorry but **this documentation section is outdated**. Please have that in mind when trying to use it.
You can help us making documentation up to date via Sylius Github. Thank you!
Sylius Mailer component abstracts the process of sending e-mails. It also provides interface to configure various parameters for unique e-mails.
.. toctree::
:maxdepth: 2
installation
basic_usage
models
interfaces
Learn more
----------
* :doc:`Emails in the Sylius platform </book/architecture/emails>` - concept documentation

View file

@ -1,18 +0,0 @@
.. rst-class:: outdated
Installation
============
.. danger::
We're sorry but **this documentation section is outdated**. Please have that in mind when trying to use it.
You can help us making documentation up to date via Sylius Github. Thank you!
You can install the component in 2 different ways:
* :doc:`Install it via Composer </components_and_bundles/components/general/using_components>` (``sylius/mailer`` on `Packagist`_);
* Use the official Git repository (https://github.com/Sylius/Mailer).
.. include:: /components_and_bundles/components/require_autoload.rst.inc
.. _Packagist: https://packagist.org/packages/sylius/mailer

View file

@ -1,83 +0,0 @@
.. rst-class:: outdated
Interfaces
==========
.. danger::
We're sorry but **this documentation section is outdated**. Please have that in mind when trying to use it.
You can help us making documentation up to date via Sylius Github. Thank you!
Model Interfaces
----------------
.. _component_mailer_model_email-interface:
EmailInterface
~~~~~~~~~~~~~~
This interface should be implemented by model representing a single type of Email.
.. note::
This interface extends :ref:`component_resource_model_code-aware-interface` and :ref:`component_resource_model_timestampable-interface`.
For more detailed information go to `Sylius API EmailInterface`_.
.. _Sylius API EmailInterface: http://api.sylius.com/Sylius/Component/Mailer/Model/EmailInterface.html
Service Interfaces
------------------
.. _component_mailer_provider_default-settings-provider-interface:
DefaultSettingsProviderInterface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This interface provides methods for retrieving default sender name nad address.
.. note::
For more detailed information go to `Sylius API DefaultSettingsProviderInterface`_.
.. _Sylius API DefaultSettingsProviderInterface: http://api.sylius.com/Sylius/Component/Mailer/Provider/DefaultSettingsProviderInterface.html
.. _component_mailer_provider_email-provider-interface:
EmailProviderInterface
~~~~~~~~~~~~~~~~~~~~~~
This interface provides methods for retrieving an email from storage.
.. note::
For more detailed information go to `Sylius API EmailProviderInterface`_.
.. _Sylius API EmailProviderInterface: http://api.sylius.com/Sylius/Component/Mailer/Provider/EmailProviderInterface.html
Sender
~~~~~~
The **Sender** it is way of sending emails
.. _component_mailer_sender_adapter_adapter-interface:
AdapterInterface
^^^^^^^^^^^^^^^^
This interface provides methods for sending an email. This is an abstraction layer to provide flexibility of mailer component.
The Adapter is injected into sender thanks to this you are free to inject your own logic of sending an email, one thing you should do is just implement this interface.
.. _component_mailer_sender_sender-interface:
SenderInterface
^^^^^^^^^^^^^^^
This interface provides methods for sending an email.
Renderer
~~~~~~~~
.. _component_mailer_renderer_adapter_adapter-interface:
AdapterInterface
^^^^^^^^^^^^^^^^
This interface provides methods for rendering an email. The Adapter is inject into sender for rendering email's content.

View file

@ -1,47 +0,0 @@
.. rst-class:: outdated
Models
======
.. danger::
We're sorry but **this documentation section is outdated**. Please have that in mind when trying to use it.
You can help us making documentation up to date via Sylius Github. Thank you!
.. _component_mailer_model_email:
Email
-----
**Email** object represents an email.
Email has the following properties:
+---------------+-------------------------------------------------------+
| Property | Description |
+===============+=======================================================+
| id | Unique id of the email |
+---------------+-------------------------------------------------------+
| code | Code of the email |
+---------------+-------------------------------------------------------+
| enabled | Indicates whether email is available |
+---------------+-------------------------------------------------------+
| subject | Subject of the email message |
+---------------+-------------------------------------------------------+
| content | Content of the email message |
+---------------+-------------------------------------------------------+
| template | Template of the email |
+---------------+-------------------------------------------------------+
| senderName | Name of a sender |
+---------------+-------------------------------------------------------+
| senderAddress | Address of a sender |
+---------------+-------------------------------------------------------+
| createdAt | Date when the email was created |
+---------------+-------------------------------------------------------+
| updatedAt | Date of last change |
+---------------+-------------------------------------------------------+
.. note::
This model implements the :ref:`component_mailer_model_email-interface`
For more detailed information go to `Sylius API Email`_.
.. _Sylius API Email: http://api.sylius.com/Sylius/Component/Mailer/Model/Email.html

View file

@ -28,7 +28,6 @@ We recommend checking out :doc:`/components_and_bundles/components/general/index
Grid/index
Inventory/index
Locale/index
Mailer/index
Order/index
Payment/index
Product/index

View file

@ -6,7 +6,7 @@
* :doc:`/components_and_bundles/components/Grid/index`
* :doc:`/components_and_bundles/components/Inventory/index`
* :doc:`/components_and_bundles/components/Locale/index`
* :doc:`/components_and_bundles/components/Mailer/index`
* `Mailer <https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md>`_
* :doc:`/components_and_bundles/components/Order/index`
* :doc:`/components_and_bundles/components/Payment/index`
* :doc:`/components_and_bundles/components/Product/index`

View file

@ -4,7 +4,7 @@ How to customize email templates per channel?
.. note::
This cookbook is suitable for a clean :doc:`sylius-standard installation </book/installation/installation>`.
For more general tips, while using :doc:`SyliusMailerBundle </components_and_bundles/bundles/SyliusMailerBundle/index>`
For more general tips, while using `SyliusMailerBundle <https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md>`_
go to `Sending configurable e-mails in Symfony Blogpost <http://sylius.com/blog/sending-configurable-e-mails-in-symfony>`_.
It is a common use-case to customize email templates depending on a channel in which an action was performed.

View file

@ -4,7 +4,7 @@ How to send a custom e-mail?
.. note::
This cookbook is suitable for a clean :doc:`sylius-standard installation </book/installation/installation>`.
For more general tips, while using :doc:`SyliusMailerBundle </components_and_bundles/bundles/SyliusMailerBundle/index>`
For more general tips, while using `SyliusMailerBundle <https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md>`_
go to `Sending configurable e-mails in Symfony Blogpost <http://sylius.com/blog/sending-configurable-e-mails-in-symfony>`_.
Currently **Sylius** is sending e-mails only in a few "must-have" cases - see :doc:`E-mails documentation </book/architecture/emails>`.

View file

@ -6,6 +6,11 @@ components_and_bundles/bundles/SyliusFixturesBundle/custom_listener.rst https://
components_and_bundles/bundles/SyliusFixturesBundle/index.rst https://github.com/Sylius/SyliusFixturesBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusFixturesBundle/installation.rst https://github.com/Sylius/SyliusFixturesBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusFixturesBundle/summary.rst https://github.com/Sylius/SyliusFixturesBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusMailerBundle/configuration.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusMailerBundle/index.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusMailerBundle/installation.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusMailerBundle/using_custom_adapter.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusMailerBundle/your_first_email.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusThemeBundle/configuration_sources.rst https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusThemeBundle/configuration_sources/creating_custom.rst https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusThemeBundle/configuration_sources/filesystem.rst https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/index.md
@ -17,6 +22,11 @@ components_and_bundles/bundles/SyliusThemeBundle/summary.rst https://github.com/
components_and_bundles/bundles/SyliusThemeBundle/theme_configuration_reference.rst https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusThemeBundle/theme_inheritance.rst https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/index.md
components_and_bundles/bundles/SyliusThemeBundle/your_first_theme.rst https://github.com/Sylius/SyliusThemeBundle/blob/master/docs/index.md
components_and_bundles/components/Mailer/basic_usage.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/components/Mailer/index.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/components/Mailer/installation.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/components/Mailer/interfaces.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
components_and_bundles/components/Mailer/models.rst https://github.com/Sylius/SyliusMailerBundle/blob/master/docs/index.md
contributing/code/bc.rst book/organization/backward-compatiblity-promise.rst
contributing/organization/core-team.rst book/organization/team.rst
contributing/organization/index.rst book/organization/index.rst