Skip to content

Commit e2d029e

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Update mailer.rst Update ssi.rst Fixed some minor issues Update form.rst Update workflow.rst
2 parents e279e95 + 28af5e6 commit e2d029e

File tree

4 files changed

+49
-11
lines changed

4 files changed

+49
-11
lines changed

components/form.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ Creating a simple Form
383383

384384
If you're using the Symfony Framework, then the form factory is available
385385
automatically as a service called ``form.factory``. Also, the default
386-
base controller class has a :method:`Symfony\\Bundle\\FrameworkBundle\\Controller::createFormBuilder`
386+
base controller class has a :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::createFormBuilder`
387387
method, which is a shortcut to fetch the form factory and call ``createBuilder()``
388388
on it.
389389

http_cache/ssi.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ The profile index page has not public caching, but the GDPR block has
114114
{# templates/profile/index.html.twig #}
115115
116116
{# you can use a controller reference #}
117-
{{ render_ssi(controller('App\Controller\ProfileController::gdpr')) }}
117+
{{ render_ssi(controller('App\\Controller\\ProfileController::gdpr')) }}
118118
119119
{# ... or a URL #}
120120
{{ render_ssi(url('profile_gdpr')) }}

mailer.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,29 @@ images inside the HTML contents::
277277
->html('<img src="cid:logo"> ... <img src="cid:footer-signature"> ...')
278278
;
279279

280+
Handling Sending Failures
281+
-------------------------
282+
283+
Symfony Mailer considers that sending was successful when your transport (SMTP
284+
server or third-party provider) accepts the mail for further delivery. The message
285+
can later be lost or not delivered because of some problem in your provider, but
286+
that's out of reach for your Symfony application.
287+
288+
If there's an error when handing over the email to your transport, Symfony throws
289+
a :class:`Symfony\\Component\\Mailer\\Exception\\TransportExceptionInterface`.
290+
Catch that exception to recover from the error or to display some message::
291+
292+
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
293+
294+
$email = new Email();
295+
// ...
296+
try {
297+
$mailer->send($email);
298+
} catch (TransportExceptionInterface $e) {
299+
// some error prevented the email sending; display an
300+
// error message or try to resend the message
301+
}
302+
280303
Debugging Emails
281304
----------------
282305

workflow.rst

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,12 @@ like this:
165165

166166
The configured property will be used via it's implemented getter/setter methods by the marking store::
167167

168+
// src/Entity/BlogPost.php
169+
namespace App\Entity;
170+
168171
class BlogPost
169172
{
170-
// the configured property must be declared
173+
// the configured marking store property must be declared
171174
private $currentPlace;
172175
private $title;
173176
private $content;
@@ -236,11 +239,11 @@ Accessing the Workflow in a Class
236239
To access workflow inside a class, use dependency injection and inject the
237240
registry in the constructor::
238241

242+
use App\Entity\BlogPost;
239243
use Symfony\Component\Workflow\Registry;
240244

241245
class MyClass
242246
{
243-
244247
private $workflowRegistry;
245248

246249
public function __construct(Registry $workflowRegistry)
@@ -356,11 +359,14 @@ order:
356359
Here is an example of how to enable logging for every time a "blog_publishing"
357360
workflow leaves a place::
358361

362+
// src/App/EventSubscriber/WorkflowLoggerSubscriber.php
363+
namespace App\EventSubscriber;
364+
359365
use Psr\Log\LoggerInterface;
360366
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
361367
use Symfony\Component\Workflow\Event\Event;
362368

363-
class WorkflowLogger implements EventSubscriberInterface
369+
class WorkflowLoggerSubscriber implements EventSubscriberInterface
364370
{
365371
private $logger;
366372

@@ -406,14 +412,18 @@ list of the guard event names.
406412
This example stops any blog post being transitioned to "reviewed" if it is
407413
missing a title::
408414

415+
// src/App/EventSubscriber/BlogPostReviewSubscriber.php
416+
namespace App\EventSubscriber;
417+
418+
use App\Entity\BlogPost;
409419
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
410420
use Symfony\Component\Workflow\Event\GuardEvent;
411421

412-
class BlogPostReviewListener implements EventSubscriberInterface
422+
class BlogPostReviewSubscriber implements EventSubscriberInterface
413423
{
414424
public function guardReview(GuardEvent $event)
415425
{
416-
/** @var App\Entity\BlogPost $post */
426+
/** @var BlogPost $post */
417427
$post = $event->getSubject();
418428
$title = $post->title;
419429

@@ -595,13 +605,14 @@ This example has been simplified; in production you may prefer to use the
595605
:doc:`Translation </translation>` component to manage messages in one
596606
place::
597607

598-
namespace App\Listener\Workflow\Task;
608+
// src/App/EventSubscriber/BlogPostPublishSubscriber.php
609+
namespace App\EventSubscriber;
599610

600611
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
601612
use Symfony\Component\Workflow\Event\GuardEvent;
602613
use Symfony\Component\Workflow\TransitionBlocker;
603614

604-
class BlogPostPublishListener implements EventSubscriberInterface
615+
class BlogPostPublishSubscriber implements EventSubscriberInterface
605616
{
606617
public function guardPublish(GuardEvent $event)
607618
{
@@ -796,10 +807,12 @@ requires:
796807
797808
Then you can access this metadata in your controller as follows::
798809

810+
// src/App/Controller/BlogPostController.php
799811
use App\Entity\BlogPost;
800812
use Symfony\Component\Workflow\Registry;
813+
// ...
801814

802-
public function myController(Registry $registry, BlogPost $post)
815+
public function myAction(Registry $registry, BlogPost $post)
803816
{
804817
$workflow = $registry->get($post);
805818

@@ -818,6 +831,8 @@ Then you can access this metadata in your controller as follows::
818831
->getMetadataStore()
819832
->getTransitionMetadata($aTransition)['priority'] ?? 0
820833
;
834+
835+
// ...
821836
}
822837

823838
There is a ``getMetadata()`` method that works with all kinds of metadata::
@@ -867,7 +882,7 @@ In Twig templates, metadata is available via the ``workflow_metadata()`` functio
867882
{% for transition in workflow_transitions(blog_post) %}
868883
<li>
869884
{{ transition.name }}:
870-
<code>{{ workflow_metadata(blog_post, 'priority', transition) ?: '0' }}</code>
885+
<code>{{ workflow_metadata(blog_post, 'priority', transition) ?: 0 }}</code>
871886
</li>
872887
{% endfor %}
873888
</ul>

0 commit comments

Comments
 (0)