1 | <?php |
||
2 | /** |
||
3 | * YAWIK |
||
4 | * |
||
5 | * @filesource |
||
6 | * @copyright https://yawik.org/COPYRIGHT.php |
||
7 | * @license MIT |
||
8 | */ |
||
9 | |||
10 | /** NewApplication.php */ |
||
11 | namespace Applications\Mail; |
||
12 | |||
13 | use Applications\Entity\ApplicationInterface; |
||
14 | use Auth\Entity\UserInterface; |
||
15 | use Core\Exception\MissingDependencyException; |
||
16 | use Jobs\Entity\JobInterface; |
||
17 | use Core\Mail\StringTemplateMessage; |
||
18 | use Organizations\Entity\EmployeeInterface; |
||
19 | use Laminas\Mvc\Router\RouteStackInterface; |
||
0 ignored issues
–
show
|
|||
20 | |||
21 | /** |
||
22 | * Sends Information about a new Application to the recruiter |
||
23 | * |
||
24 | * Class NewApplication |
||
25 | * @package Applications\Mail |
||
26 | */ |
||
27 | class NewApplication extends StringTemplateMessage |
||
28 | { |
||
29 | /** |
||
30 | * Job posting |
||
31 | * |
||
32 | * @var ApplicationInterface |
||
33 | */ |
||
34 | protected $application; |
||
35 | |||
36 | /** |
||
37 | * Owner of the job posting |
||
38 | * |
||
39 | * @var \Auth\Entity\User $user |
||
40 | */ |
||
41 | protected $user; |
||
42 | |||
43 | /** |
||
44 | * Organization Admin |
||
45 | * |
||
46 | * @var bool|\Auth\Entity\User $admin |
||
47 | */ |
||
48 | protected $admin; |
||
49 | |||
50 | /** |
||
51 | * @var bool |
||
52 | */ |
||
53 | private $callInitOnSetJob = false; |
||
54 | |||
55 | /** |
||
56 | * @var bool |
||
57 | */ |
||
58 | private $callInitOnSetApplication = false; |
||
59 | |||
60 | /** |
||
61 | * |
||
62 | * |
||
63 | * @var RouteStackInterface |
||
64 | */ |
||
65 | private $router; |
||
66 | |||
67 | /** |
||
68 | * @param array $options |
||
69 | */ |
||
70 | public function __construct($options = array()) |
||
71 | { |
||
72 | if (!is_array($options)) { |
||
73 | $this->router = $options; |
||
74 | $options = []; |
||
75 | } elseif (isset($options['router'])) { |
||
76 | $this->router = $options['router']; |
||
77 | unset($options['router']); |
||
78 | } |
||
79 | |||
80 | if (!$this->router) { |
||
81 | throw new MissingDependencyException('Router', $this); |
||
82 | } |
||
83 | |||
84 | parent::__construct($options); |
||
85 | $this->callInitOnSetJob = true; |
||
86 | } |
||
87 | |||
88 | public function init() |
||
89 | { |
||
90 | if (!$this->application) { |
||
91 | return false; |
||
92 | } |
||
93 | |||
94 | /* @var \Auth\Entity\Info $userInfo */ |
||
95 | $job = $this->application->getJob(); |
||
96 | $userInfo = $this->user->getInfo(); |
||
97 | $name = $userInfo->getDisplayName(); |
||
98 | if ('' == trim($name)) { |
||
99 | $name = $userInfo->getEmail(); |
||
100 | } |
||
101 | |||
102 | $variables = [ |
||
103 | 'name' => $name, |
||
104 | 'title' => $job->getTitle(), |
||
105 | 'link' => $this->router->assemble( |
||
106 | ['id' => $this->application->getId()], |
||
107 | ['name'=>'lang/applications/detail', 'force_canonical'=>true] |
||
108 | ) . '?login=' . $this->user->getLogin(), |
||
109 | ]; |
||
110 | |||
111 | $this->setTo($this->user->getInfo()->getEmail(), $this->user->getInfo()->getDisplayName(false)); |
||
112 | |||
113 | $this->setVariables($variables); |
||
114 | $subject = /*@translate*/ 'New application for your vacancy "%s"'; |
||
115 | |||
116 | if ($this->isTranslatorEnabled()) { |
||
117 | $subject = $this->getTranslator()->translate($subject); |
||
118 | } |
||
119 | $this->setSubject(sprintf($subject, $job->getTitle())); |
||
120 | |||
121 | /* @var \Applications\Entity\Settings $settings */ |
||
122 | $settings = $this->user->getSettings('Applications'); |
||
123 | |||
124 | $body = $settings->getMailAccessText(); |
||
125 | if ('' == $body) { |
||
126 | $body = /*@translate*/ "Hello ##name##,\n\nThere is a new application for your vacancy:\n\"##title##\"\n\n"; |
||
127 | |||
128 | if ($this->isTranslatorEnabled()) { |
||
129 | $body = $this->getTranslator()->translate($body); |
||
130 | } |
||
131 | $body .= "##link##\n\n"; |
||
132 | } |
||
133 | |||
134 | $this->setBody($body); |
||
135 | return $this; |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * @param ApplicationInterface $application |
||
140 | * @param bool $init |
||
141 | * @return $this |
||
142 | */ |
||
143 | public function setApplication(ApplicationInterface $application, $init = true) |
||
144 | { |
||
145 | $this->application = $application; |
||
146 | if ($this->callInitOnSetApplication) { |
||
147 | $this->init(); |
||
148 | } |
||
149 | return $this; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * @param \Auth\Entity\User $user |
||
154 | * @return $this |
||
155 | */ |
||
156 | public function setUser($user) |
||
157 | { |
||
158 | $this->user=$user; |
||
159 | return $this; |
||
160 | } |
||
161 | } |
||
162 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths