-
Notifications
You must be signed in to change notification settings - Fork 9
/
Worker.php
87 lines (76 loc) · 2.07 KB
/
Worker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace Laelaps\GearmanBundle;
use LogicException;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* @author Mateusz Charytoniuk <mateusz.charytoniuk@absolvent.pl>
*/
abstract class Worker implements ContainerAwareInterface
{
/**
* @var Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* @param Symfony\Component\DependencyInjection\ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->setContainer($container);
}
/**
* @param string $id
* @return object
*/
public function get($id)
{
return $this->container->get($id);
}
/**
* @param string $route
* @param mixed $parameters
* @param boolean $absolute
* @return string
*/
public function generateUrl($route, $parameters = array(), $absolute = false)
{
return $this->container->get('router')->generate($route, $parameters, $absolute);
}
/**
* @return Doctrine\Bundle\DoctrineBundle\Registry
* @throws LogicException If DoctrineBundle is not available
*/
public function getDoctrine()
{
if (!$this->container->has('doctrine')) {
throw new LogicException('The DoctrineBundle is not registered in your application.');
}
return $this->container->get('doctrine');
}
/**
* @param string $id
* @return boolean
*/
public function has($id)
{
return $this->container->has($id);
}
/**
* @param Symfony\Component\DependencyInjection\ContainerInterface $container
* @return void
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* Called when timeout is reached
*
* @param OutputInterface $output
*/
public function doTimeout(OutputInterface $output)
{
}
}