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
e4093ea5
Commit
e4093ea5
authored
Jul 25, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
une commande qui change le statut (closed) des offres expirées
parent
3c2b4a2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
src/PotageBundle/Command/CronOffreCommand.php
src/PotageBundle/Command/CronOffreCommand.php
+59
-0
No files found.
src/PotageBundle/Command/CronOffreCommand.php
0 → 100644
View file @
e4093ea5
<?php
namespace
PotageBundle\Command
;
use
PotageBundle\Entity\Offre
;
use
Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
class
CronOffreCommand
extends
ContainerAwareCommand
{
/**
* {@inheritdoc}
*/
protected
function
configure
()
{
$this
->
setName
(
'potage:cron:offre'
)
->
setDescription
(
"Vérifie la date d'expiration des offres en cours"
);
}
/**
* Vérifie que les offres en cours n'ont pas expiré.
* Si c'est le cas, le statut est changé et un mail est envoyé aux maraichers.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$em
=
$this
->
getContainer
()
->
get
(
'doctrine'
)
->
getManager
();
$currentOffre
=
$em
->
getRepository
(
'PotageBundle:Offre'
)
->
findAllByStatusForRead
(
'current'
);
$now
=
new
\
DateTime
(
'now'
);
/**
* @var Offre $offre
*/
foreach
(
$currentOffre
as
$offre
)
{
if
(
$offre
->
getEndedAt
()
>=
$now
)
{
//$output->writeln($offre->getReference() . ': offre toujours en cours');
}
else
{
$output
->
writeln
(
$offre
->
getReference
()
.
': offre expirée, on archive..'
);
$offre
->
setStatus
(
'closed'
);
// TODO envoyer un mail au gestionnaire pour annoncer l'expiration de l'offre
}
}
$em
->
flush
();
}
}
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