Completed
Pull Request — develop (#303)
by
unknown
10:41
created

OrganizationImage::getUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/** UserImage.php */
11
namespace Organizations\Entity;
12
13
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
14
use Zend\Permissions\Acl\Resource\ResourceInterface;
15
use Core\Entity\FileEntity;
16
use Organizations\Image\FileCache;
17
18
/**
19
 * Defines the logo of an organization.
20
 *
21
 * @ODM\HasLifecycleCallbacks()
22
 * @ODM\Document(collection="organizations.images", repositoryClass="Organizations\Repository\OrganizationImage")
23
 */
24
class OrganizationImage extends FileEntity implements ResourceInterface
25
{
26
    /**
27
     * Organization which belongs to the company logo
28
     *
29
     * @var Organization
30
     * @ODM\ReferenceOne(targetDocument="\Organizations\Entity\Organization", mappedBy="image")
31
     */
32
    protected $organization;
33
34
    /**
35
     * {@inheritDoc}
36
     * @see \Zend\Permissions\Acl\Resource\ResourceInterface::getResourceId()
37
     */
38
    public function getResourceId()
39
    {
40
        return 'Entity/OrganizationImage';
41
    }
42
43
    /**
44
     * Gets the URI of an attachment
45
     *
46
     * @return string
47
     */
48
    function getUri()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
49
    {
50
        return '/' . trim('file/Organizations.OrganizationImage/' . $this->id . "/" . urlencode($this->name),'/');
51
    }
52
    
53
    /**
54
     * Gets the cached URI of an attachment
55
     *
56
     * @param FileCache $cache
57
     * @return string
58
     * @since 0.28
59
     */
60
    function getUriCached(FileCache $cache)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
61
    {
62
        return $cache->getUri($this);
63
    }
64
65
    /**
66
     * Gets the organization of an company logo
67
     *
68
     * @return Organization
69
     */
70
    public function getOrganization()
71
    {
72
        return $this->organization;
73
    }
74
75
    /**
76
     * @param Organization $organization
77
     */
78
    public function setOrganization(Organization $organization)
79
    {
80
        $this->organization = $organization;
81
    }
82
83
    /**
84
     * Tells Doctrine to delete the image reference, if the image is deleted.
85
     *
86
     * @ODM\PreRemove()
87
     */
88
    public function preRemove()
89
    {
90
        $this->getOrganization()->setImage(null);
91
    }
92
}
93