Completed
Pull Request — develop (#359)
by Mathias
23:51
created

Organization::getImages()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
6
 * @license       MIT
7
 */
8
9
namespace Organizations\Entity;
10
11
use Auth\Entity\UserInterface;
12
use Core\Entity\AbstractIdentifiableModificationDateAwareEntity as BaseEntity;
13
use Core\Entity\Collection\ArrayCollection;
14
use Core\Entity\DraftableEntityInterface;
15
use Core\Entity\EntityInterface;
16
use Core\Entity\Hydrator\EntityHydrator;
17
use Core\Entity\ImageSet;
18
use Core\Entity\Permissions;
19
use Core\Entity\PermissionsInterface;
20
use Doctrine\Common\Collections\Collection;
21
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
22
use Zend\Hydrator\HydratorInterface;
23
use Zend\Permissions\Acl\Resource\ResourceInterface;
24
25
/**
26
 * The organization.
27
 *
28
 * @ODM\Document(collection="organizations", repositoryClass="Organizations\Repository\Organization")
29
 * @ODM\HasLifecycleCallbacks
30
 * @ODM\Indexes({
31
 *      @ODM\Index(keys={
32
 *          "_organizationName"="text"
33
 *      }, name="fulltext")
34
 * })
35
 *
36
 * @todo   write test
37
 * @author Mathias Weitz <[email protected]>
38
 * @author Mathias Gelhausen <[email protected]>
39
 */
40
class Organization extends BaseEntity implements
0 ignored issues
show
Coding Style introduced by
The property $_organizationName is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
41
    OrganizationInterface,
42
    DraftableEntityInterface,
43
    ResourceInterface
44
{
45
    /**
46
     * Event name of post construct event.
47
     *
48
     * @var string
49
     */
50
    const postConstruct = 'postRepositoryConstruct';
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected POSTCONSTRUCT).
Loading history...
51
52
    /**
53
     * externalId. Allows external applications to reference their primary key.
54
     *
55
     * @var string
56
     * @ODM\Field(type="string")
57
     * @ODM\Index
58
     */
59
    protected $externalId;
60
61
    /**
62
     * The actual name of the organization.
63
     *
64
     * @var \Organizations\Entity\OrganizationName
65
     * @ODM\ReferenceOne(targetDocument="\Organizations\Entity\OrganizationName", simple=true, cascade="persist")
66
     */
67
    protected $organizationName;
68
69
    /**
70
     * Only for sorting/searching purposes
71
     *
72
     * @var string
73
     * @ODM\Field(type="string")
74
     */
75
    protected $_organizationName;
0 ignored issues
show
Coding Style introduced by
$_organizationName does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
76
77
    /**
78
     * Assigned permissions.
79
     *
80
     * @var PermissionsInterface
81
     * @ODM\EmbedOne(targetDocument="\Core\Entity\Permissions")
82
     */
83
    protected $permissions;
84
85
    /**
86
     * primary logo of an organization
87
     *
88
     * @var \Organizations\Entity\OrganizationImage
89
     * @ODM\ReferenceOne(targetDocument="\Organizations\Entity\OrganizationImage", inversedBy="organization", simple=true, nullable="true", cascade={"all"})
90
     */
91
    protected $image;
92
93
    /**
94
     *
95
     *
96
     * @ODM\EmbedOne(targetDocument="\Core\Entity\ImageSet")
97
     * @var Images
98
     */
99
    protected $images;
100
    /**
101
     * Flag indicating draft state of this job.
102
     *
103
     * @var bool
104
     * @ODM\Boolean
105
     */
106
    protected $isDraft = false;
107
108
    /**
109
     * Organization contact data.
110
     *
111
     * @ODM\EmbedOne(targetDocument="\Organizations\Entity\OrganizationContact")
112
     */
113
    protected $contact;
114
115
    /**
116
     * The organizations' description.
117
     *
118
     * @var string
119
     * @ODM\Field(type="string")
120
     */
121
    protected $description;
122
123
    /**
124
     * The parent of this organization.
125
     *
126
     * @see   setParent()
127
     * @var OrganizationInterface | null
128
     * @ODM\ReferenceOne(targetDocument="\Organizations\Entity\Organization", simple=true, nullable=true)
129
     * @since 0.18
130
     */
131
    protected $parent;
132
133
    /**
134
     * The hiring organizations of this organization.
135
     *
136
     * @var Collection
137
     * @ODM\ReferenceMany(
138
     *      targetDocument="Organizations\Entity\Organization",
139
     *      repositoryMethod="getHiringOrganizationsCursor"
140
     * )
141
     * @since 0.18
142
     */
143
    protected $hiringOrganizations;
144
145
    /**
146
     * The associated employees (users)
147
     *
148
     * @ODM\EmbedMany(targetDocument="\Organizations\Entity\Employee")
149
     * @var Collection
150
     */
151
    protected $employees;
152
153
    /**
154
     * Jobs of this organization.
155
     *
156
     * @var Collection
157
     * @ODM\ReferenceMany(targetDocument="\Jobs\Entity\Job", simple=true, mappedBy="organization")
158
     * @since 0.18
159
     */
160
    protected $jobs;
161
162
    /**
163
     * the owner of a Organization
164
     *
165
     * @var UserInterface $user
166
     * @ODM\ReferenceOne(targetDocument="\Auth\Entity\User", simple=true)
167
     * @ODM\Index
168
     */
169
    protected $user;
170
171
    /**
172
     * Default values of an organizations job template
173
     *
174
     * @var TemplateInterface;
175
     * @ODM\EmbedOne(targetDocument="\Organizations\Entity\Template")
176
     */
177
    protected $template;
178
179
    /**
180
     * Default values Workflow
181
     *
182
     * @var WorkflowSettingsInterface $workflowSettings ;
183
     * @ODM\EmbedOne(targetDocument="\Organizations\Entity\WorkflowSettings")
184
     */
185
    protected $workflowSettings;
186
187
    /**
188
     * Returns the string identifier of the Resource
189
     *
190
     * @return string
191
     */
192
    public function getResourceId()
193
    {
194
        return 'Entity/Organization';
195
    }
196
197
198
    /**
199
     * Gets the organization name
200
     *
201
     * @return string
202
     */
203
    public function getName()
204
    {
205
        if (empty($this->organizationName)) {
206
            return '';
207
        }
208
209
        return $this->organizationName->getName();
210
    }
211
212
    /**
213
     * Sets the parent of an organization
214
     *
215
     * @param OrganizationInterface $parent
216
     *
217
     * @return $this
218
     */
219
    public function setParent(OrganizationInterface $parent)
220
    {
221
        $this->parent = $parent;
222
223
        return $this;
224
    }
225
226
    /**
227
     * @deprecated
228
     * @return array
229
     */
230
    public function getSearchableProperties()
231
    {
232
        return array();
233
    }
234
235
    /**
236
     * Gets the parent of an organization
237
     *
238
     * @param bool $returnSelf returns itself, if this organization does not have a parent?
239
     *
240
     * @return null|OrganizationInterface
241
     */
242
    public function getParent($returnSelf = false)
243
    {
244
        return $this->parent ? : ($returnSelf ? $this : null);
245
    }
246
247
    /**
248
     * Gets the Draft flag
249
     *
250
     * @return bool
251
     */
252
    public function isDraft()
253
    {
254
        return $this->isDraft;
255
    }
256
257
    /**
258
     * Gets linked organizations
259
     *
260
     * @return Collection
261
     */
262
    public function getHiringOrganizations()
263
    {
264
        return $this->hiringOrganizations;
265
    }
266
267
    /**
268
     * Sets the draft flag
269
     *
270
     * @param bool $flag
271
     *
272
     * @return $this
273
     */
274
    public function setIsDraft($flag)
275
    {
276
        $this->isDraft = (bool) $flag;
277
278
        return $this;
279
    }
280
281
    /**
282
     * @return bool
283
     */
284
    public function isHiringOrganization()
285
    {
286
        return null !== $this->parent;
287
    }
288
289
    /**
290
     * Returns true, if the user belongs to the organization.
291
     *
292
     * @param UserInterface $user
293
     *
294
     * @return bool
295
     */
296
    public function isAssociated(UserInterface $user)
297
    {
298
        return $this->isOwner($user) || $this->isEmployee($user);
299
    }
300
301
    /**
302
     * Sets the external id.
303
     *
304
     * @param $externalId
305
     *
306
     * @return self
307
     */
308
    public function setExternalId($externalId)
309
    {
310
        $this->externalId = $externalId;
311
312
        return $this;
313
    }
314
315
    /**
316
     * Checks, if a User is the owner of an organization
317
     *
318
     * @param UserInterface $user
319
     *
320
     * @return bool
321
     */
322
    public function isOwner(UserInterface $user)
323
    {
324
        return $this->getUser()->getId() == $user->getId();
325
    }
326
327
    /**
328
     * Gets the internal id.
329
     *
330
     * @return string
331
     */
332
    public function getExternalId()
333
    {
334
        return $this->externalId;
335
    }
336
337
    /**
338
     * Returns true, if a User is an employee of the organization
339
     *
340
     * @param UserInterface $user
341
     *
342
     * @return bool
343
     */
344
    public function isEmployee(UserInterface $user)
345
    {
346
        return $this->refs && in_array($user->getId(), $this->refs->getEmployeeIds());
0 ignored issues
show
Documentation introduced by
The property refs does not exist on object<Organizations\Entity\Organization>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
347
    }
348
349
    /**
350
     * @todo review this
351
     *
352
     * @param HydratorInterface $hydrator
353
     *
354
     * @return $this
355
     */
356
    public function setHydrator(HydratorInterface $hydrator)
357
    {
358
        return $this;
359
    }
360
361
    /**
362
     * Updates the organizationsPermissions to allow all employees to view this organization.
363
     *
364
     * In case of a HiringOrganization Permissions are granted to all employees of the parent
365
     * organization.
366
     *
367
     * @ODM\PreUpdate
368
     * @ODM\PrePersist
369
     * @since 0.18
370
     */
371
    public function updatePermissions()
372
    {
373
        if ($this->isHiringOrganization()) {
374
            $organization = $this->getParent();
375
            $owner        = $organization->getUser();
376
377
            $this->setUser($owner);
378
        } else {
379
            $organization = $this;
380
        }
381
382
        /* @var $employees null | ArrayCollection | \Doctrine\ODM\MongoDB\PersistentCollection */
383
        $employees = $organization->getEmployees();
384
385
        $perms = $this->getPermissions();
386
387
        foreach ($employees as $emp) {
0 ignored issues
show
Bug introduced by
The expression $employees of type null is not traversable.
Loading history...
388
            /* @var $emp \Organizations\Entity\Employee */
389
            $perms->grant($emp->getUser(), PermissionsInterface::PERMISSION_CHANGE, false);
0 ignored issues
show
Unused Code introduced by
The call to PermissionsInterface::grant() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
390
        }
391
        $perms->build();
392
    }
393
394
    /**
395
     * * @todo review this
396
     * @return EntityHydrator
397
     */
398
    public function getHydrator()
399
    {
400
        return new EntityHydrator();
401
    }
402
403
    /**
404
     * Sets the name of an organization
405
     *
406
     * @param OrganizationName $organizationName
407
     *
408
     * @return $this
409
     */
410
    public function setOrganizationName(OrganizationName $organizationName)
411
    {
412
        if (isset($this->organizationName)) {
413
            $this->organizationName->refCounterDec()->refCompanyCounterDec();
414
        }
415
        $this->organizationName = $organizationName;
416
        $this->organizationName->refCounterInc()->refCompanyCounterInc();
417
        $this->_organizationName = $organizationName->getName();
418
419
        return $this;
420
    }
421
422
    /**
423
     * Gets the organization name entity of an organisation
424
     *
425
     * @return OrganizationName
426
     */
427
    public function getOrganizationName()
428
    {
429
        return $this->organizationName;
430
    }
431
432
433
    /**
434
     * Gets the Permissions of an organization
435
     *
436
     * @return PermissionsInterface
437
     */
438
    public function getPermissions()
439
    {
440
        if (!$this->permissions) {
441
            $permissions = new Permissions();
442
            if ($this->user) {
443
                $permissions->grant($this->user, Permissions::PERMISSION_ALL);
444
            }
445
            $this->setPermissions($permissions);
446
        }
447
448
        return $this->permissions;
449
    }
450
451
    /**
452
     * Sets the Permissions of an Organization
453
     *
454
     * @param PermissionsInterface $permissions
455
     *
456
     * @return $this
457
     */
458 View Code Duplication
    public function setPermissions(PermissionsInterface $permissions)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
459
    {
460
        // Assure the user has always all rights.
461
        if ($this->user) {
462
            $permissions->grant($this->user, Permissions::PERMISSION_ALL);
463
        }
464
        $this->permissions = $permissions;
465
466
        return $this;
467
    }
468
469
    /**
470
     * Gets the Permissions Resource ID
471
     *
472
     * @return string
473
     */
474
    public function getPermissionsResourceId()
475
    {
476
        return 'organization:' . $this->getId();
477
    }
478
479
    /**
480
     * @param null $type
481
     *
482
     * @return array
483
     */
484
    public function getPermissionsUserIds($type = null)
485
    {
486
        // if we have a user, grant him full access to all associated permissions.
487
        $user = $this->getUser();
488
        $spec = $user
489
            ? $spec = array(PermissionsInterface::PERMISSION_ALL => array($this->getUser()->getId()))
490
            : array();
491
492
        if (null === $type || ('Job/Permissions' != $type && 'Application' != $type)) {
493
            return $spec;
494
        }
495
496
        if ('Job/Permissions' == $type) {
497
            $change = EmployeePermissionsInterface::JOBS_CHANGE;
498
            $view   = EmployeePermissionsInterface::JOBS_VIEW;
499
        } else {
500
            $change = EmployeePermissionsInterface::APPLICATIONS_CHANGE;
501
            $view   = EmployeePermissionsInterface::APPLICATIONS_VIEW;
502
        }
503
504
        $employees = $this->isHiringOrganization()
505
            ? $this->getParent()->getEmployees()
506
            : $this->getEmployees();
507
508
        foreach ($employees as $emp) {
509
            /* @var $emp EmployeeInterface */
510
            if ($emp->isUnassigned()) {
511
                continue;
512
            }
513
514
            $perm = $emp->getPermissions();
515
            if ($perm->isAllowed($change)) {
516
                $spec[PermissionsInterface::PERMISSION_CHANGE][] = $emp->getUser()->getId();
517
            } elseif ($perm->isAllowed($view)) {
518
                $spec[PermissionsInterface::PERMISSION_VIEW][] = $emp->getUser()->getId();
519
            }
520
        }
521
522
        return $spec;
523
    }
524
525
    /**
526
     * Sets the logo of an organization
527
     *
528
     * @param OrganizationImage $image
0 ignored issues
show
Documentation introduced by
Should the type for parameter $image not be null|OrganizationImage?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
529
     *
530
     * @return self
531
     */
532
    public function setImage(OrganizationImage $image = null)
533
    {
534
        $this->image = $image;
535
536
        return $this;
537
    }
538
539
    /**
540
     * Gets the Logo of an organization
541
     *
542
     * @return OrganizationImage
543
     */
544
    public function getImage()
545
    {
546
        return $this->image;
547
    }
548
549
    /**
550
     * @param ImageSet $images
551
     *
552
     * @return self
553
     */
554
    public function setImages(ImageSet $images)
555
    {
556
        $this->images = $images;
0 ignored issues
show
Documentation Bug introduced by
It seems like $images of type object<Core\Entity\ImageSet> is incompatible with the declared type object<Organizations\Entity\Images> of property $images.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
557
558
        return $this;
559
    }
560
561
    /**
562
     * @return \Organizations\Entity\Images
563
     */
564
    public function getImages()
565
    {
566
        if (!$this->images) {
567
            $this->images = new ImageSet();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Core\Entity\ImageSet() of type object<Core\Entity\ImageSet> is incompatible with the declared type object<Organizations\Entity\Images> of property $images.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
568
        }
569
570
        return $this->images;
571
    }
572
573
    /**
574
     *
575
     *
576
     * @return self
577
     */
578
    public function removeImages()
579
    {
580
        $this->images = null;
581
582
        return $this;
583
    }
584
585
586
587
    /**
588
     * Sets the Contact Data of an organization
589
     *
590
     * @param EntityInterface $contact
0 ignored issues
show
Documentation introduced by
Should the type for parameter $contact not be null|EntityInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
591
     *
592
     * @return $this
593
     */
594
    public function setContact(EntityInterface $contact = null)
595
    {
596
        if (!$contact instanceof OrganizationContact) {
597
            $contact = new OrganizationContact($contact);
0 ignored issues
show
Unused Code introduced by
The call to OrganizationContact::__construct() has too many arguments starting with $contact.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
598
        }
599
        $this->contact = $contact;
600
601
        return $this;
602
    }
603
604
    /**
605
     * Gets the contact Data of an organization
606
     *
607
     * @return OrganizationContact
608
     */
609
    public function getContact()
610
    {
611
        if (!$this->contact instanceof OrganizationContact) {
612
            $this->contact = new OrganizationContact();
613
        }
614
615
        return $this->contact;
616
    }
617
618
619
    /**
620
     * Gets the default description of an organization.
621
     *
622
     * This description is used as the default of the company_description
623
     * used in a job template
624
     *
625
     * @return string
626
     */
627
    public function getDescription()
628
    {
629
        return $this->description;
630
    }
631
632
    /**
633
     * Set the default description af an organization
634
     *
635
     * @param string $description
636
     *
637
     * @return $this
638
     */
639
    public function setDescription($description)
640
    {
641
        $this->description = $description;
642
643
        return $this;
644
    }
645
646
    /**
647
     * Sets the the list of employees
648
     *
649
     * @param Collection $employees
650
     *
651
     * @return $this
652
     */
653
    public function setEmployees(Collection $employees)
654
    {
655
        /* todo: Throw exception or at least log incidents, where employees are added to "hiring orgs" */
656
        if (!$this->isHiringOrganization()) {
657
            $this->employees = $employees;
658
        }
659
660
        return $this;
661
    }
662
663
    /**
664
     * Gets the list of employees
665
     *
666
     * @return ArrayCollection|Collection
667
     */
668
    public function getEmployees()
669
    {
670
        if ($this->isHiringOrganization()) {
671
            // Always return empty list, as we never have employees in this case.
672
            return new ArrayCollection();
673
        }
674
675
        if (!$this->employees) {
676
            $this->setEmployees(new ArrayCollection());
677
        }
678
679
        return $this->employees;
680
    }
681
682
    /**
683
     * Gets an employee by User or ID.
684
     *
685
     * @param UserInterface|string $userOrId
686
     *
687
     * @return mixed|null
688
     */
689
    public function getEmployee($userOrId)
690
    {
691
        $employees = $this->getEmployees();
692
        $userId    = $userOrId instanceof \Auth\Entity\UserInterface ? $userOrId->getId() : $userOrId;
693
694
        foreach ($employees as $employee) {
695
            if ($employee->getUser()->getId() == $userId) {
696
                return $employee;
697
            }
698
        }
699
700
        return null;
701
    }
702
703
    /**
704
     * Gets a list of Employees by a user role
705
     *
706
     * @param string $role
707
     *
708
     * @return ArrayCollection
709
     */
710
    public function getEmployeesByRole($role)
711
    {
712
        $employees = new ArrayCollection();
713
714
        /* @var \Organizations\Entity\Employee $employee */
715
        foreach ($this->getEmployees() as $employee) {
716
            if ($role === $employee->getRole()) {
717
                $employees->add($employee);
718
            }
719
        }
720
721
        return $employees;
722
    }
723
724
725 View Code Duplication
    public function setUser(UserInterface $user)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
726
    {
727
        if ($this->user) {
728
            $this->getPermissions()->revoke($this->user, Permissions::PERMISSION_ALL, false);
0 ignored issues
show
Unused Code introduced by
The call to PermissionsInterface::revoke() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
729
        }
730
        $this->user = $user;
731
        $this->getPermissions()->grant($user, Permissions::PERMISSION_ALL);
732
733
        return $this;
734
    }
735
736
    /**
737
     * Gets the owner of the organization
738
     *
739
     * @return UserInterface
740
     */
741
    public function getUser()
742
    {
743
        return $this->user;
744
    }
745
746
    /**
747
     * Gets the Jobs of an organization
748
     *
749
     * @return Collection
750
     */
751
    public function getJobs()
752
    {
753
        return $this->jobs;
754
    }
755
756
    /**
757
     * Gets default values of an organizations job template
758
     *
759
     * @return TemplateInterface
760
     */
761
    public function getTemplate()
762
    {
763
        if (null === $this->template) {
764
            $this->template = new Template();
765
        }
766
767
        return $this->template;
768
    }
769
770
    /**
771
     * Sets default values of an organizations job template
772
     *
773
     * @return self
774
     */
775
    public function setTemplate(TemplateInterface $template)
776
    {
777
        $this->template = $template;
778
779
        return $this;
780
    }
781
782
    /**
783
     * Gets Workflow Settings
784
     *
785
     * @return WorkflowSettings|WorkflowSettingsInterface
786
     */
787
    public function getWorkflowSettings()
788
    {
789
        if (null == $this->workflowSettings) {
790
            $this->workflowSettings = new WorkflowSettings();
791
        }
792
793
        return $this->workflowSettings;
794
    }
795
796
    /**
797
     * Sets Workflow Settings
798
     *
799
     * @param $workflowSettings
800
     *
801
     * @return self
802
     */
803
    public function setWorkflowSettings($workflowSettings)
804
    {
805
        $this->workflowSettings = $workflowSettings;
806
807
        return $this;
808
    }
809
}