Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
mathieu
potage
Commits
83fd8f09
Commit
83fd8f09
authored
Aug 27, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
array lettre
parent
fe2726cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
7 deletions
+41
-7
src/PotageBundle/Command/SendMailCommand.php
src/PotageBundle/Command/SendMailCommand.php
+1
-2
src/PotageBundle/Controller/DefaultController.php
src/PotageBundle/Controller/DefaultController.php
+1
-1
src/PotageBundle/Resources/views/Mail/bodyMail.html.twig
src/PotageBundle/Resources/views/Mail/bodyMail.html.twig
+1
-1
src/PotageBundle/Services/Newsletter.php
src/PotageBundle/Services/Newsletter.php
+38
-3
No files found.
src/PotageBundle/Command/SendMailCommand.php
View file @
83fd8f09
...
...
@@ -54,8 +54,7 @@ class SendMailCommand extends ContainerAwareCommand
->
getRepository
(
'PotageBundle:Lettre'
)
->
findOneForSend
(
7
);
$retour
=
$this
->
newsletter
->
sendLettreToGroup
(
$lettre
,
'body du mail de test. Mail envoyé depuis la ligne de commande '
);
$retour
=
$this
->
newsletter
->
sendLettreToGroup
(
$lettre
);
for
(
$i
=
0
;
$i
<
count
(
$retour
);
$i
++
)
{
$output
->
writeln
(
$i
.
' | '
.
$retour
[
$i
][
'to'
]
.
' | '
.
$retour
[
$i
][
'result'
]);
...
...
src/PotageBundle/Controller/DefaultController.php
View file @
83fd8f09
...
...
@@ -32,7 +32,7 @@ class DefaultController extends MasterController
->
getRepository
(
'PotageBundle:Lettre'
)
->
findOneForSend
(
7
);
$retour
=
$newsletter
->
sendLettreToGroup
(
$lettre
,
'body du mail de test'
);
$retour
=
$newsletter
->
sendLettreToGroup
(
$lettre
);
return
$this
->
render
(
'@Potage/Default/test.html.twig'
,
array
(
'retour'
=>
$retour
...
...
src/PotageBundle/Resources/views/Mail/bodyMail.html.twig
View file @
83fd8f09
...
...
@@ -22,7 +22,7 @@
<h1>
Mon template twig
</h1>
<h2>
{{
subject
}}
</h2>
<h3>
{{
to
}}
</h3>
{{
dump
(
body
)
}}
{{
body
}}
</body>
</html>
\ No newline at end of file
src/PotageBundle/Services/Newsletter.php
View file @
83fd8f09
...
...
@@ -68,21 +68,56 @@ class Newsletter
/**
* @param Lettre $lettre
* @param $body
* @return array
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public
function
sendLettreToGroup
(
Lettre
$lettre
,
$body
)
public
function
sendLettreToGroup
(
Lettre
$lettre
)
{
$subject
=
"[Potage] Envoi de l'infolettre "
.
$lettre
->
getReference
();
$subject
=
$lettre
->
getSubject
();
$groupe
=
array
(
'nom'
=>
$lettre
->
getGroupe
()
->
getNom
(),
);
$depot
=
array
(
'localisation'
=>
$lettre
->
getGroupe
()
->
getDepot
()
->
getLocalisation
(),
'responsable'
=>
$lettre
->
getGroupe
()
->
getDepot
()
->
getResponsable
(),
'jour'
=>
$lettre
->
getGroupe
()
->
getDepot
()
->
getJourPanier
(),
'heure'
=>
$lettre
->
getGroupe
()
->
getDepot
()
->
getHeurePanier
(),
);
$offre
=
array
(
'id'
=>
$lettre
->
getOffre
()
->
getId
(),
'reference'
=>
$lettre
->
getOffre
()
->
getReference
(),
'end'
=>
$lettre
->
getOffre
()
->
getEndedAt
(),
'status'
=>
$lettre
->
getOffre
()
->
getStatus
(),
'sorted'
=>
$lettre
->
getOffre
()
->
getSorted
(),
);
$body
=
array
(
'reference'
=>
$lettre
->
getReference
(),
'start'
=>
$lettre
->
getStartedAt
(),
'end'
=>
$lettre
->
getEndedAt
(),
'status'
=>
$lettre
->
getStatus
(),
'sorted'
=>
$lettre
->
getSorted
(),
'groupe'
=>
$groupe
,
'depot'
=>
$depot
,
'offre'
=>
$offre
,
);
/**
* A partir de l'infolettre on récupère les destinataires
* @var array $utilisateurs
*/
$groupe
=
$lettre
->
getGroupe
()
->
getId
();
$utilisateurs
=
$this
->
container
->
get
(
'doctrine'
)
->
getRepository
(
'PotageBundle:Utilisateur'
)
->
findAllByGroup
(
$groupe
);
/**
* Boucle sur chaque utilisateur, envoie le mail,
* récupère le code de retour dans un tableau
*/
$ret
=
array
();
for
(
$i
=
0
;
$i
<
count
(
$utilisateurs
);
$i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment