Completed
Push — develop ( fcce06...87d9a9 )
by Nate
02:07
created

UpdateOrganization::populate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/organization/license
6
 * @link       https://www.flipboxfactory.com/software/organization/
7
 */
8
9
namespace flipbox\organizations\actions\organizations;
10
11
use flipbox\craft\ember\actions\elements\UpdateElement;
12
use flipbox\organizations\elements\Organization;
13
use yii\base\BaseObject;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class UpdateOrganization extends UpdateElement
20
{
21
    use PopulateOrganizationTrait;
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function run($organization)
27
    {
28
        return parent::run($organization);
29
    }
30
31
    /**
32
     * @inheritdoc
33
     * @return Organization
34
     */
35
    public function find($identifier)
36
    {
37
        $site = $this->resolveSiteFromRequest();
38
        return Organization::findOne([
0 ignored issues
show
Bug Compatibility introduced by
The expression \flipbox\organizations\e...e ? $site->id : null)); of type craft\base\Element|null|craft\base\Element[] adds the type craft\base\Element[] to the return on line 38 which is incompatible with the return type documented by flipbox\organizations\ac...pdateOrganization::find of type flipbox\organizations\elements\Organization|null.
Loading history...
39
            is_numeric($identifier) ? 'id' : 'slug' => $identifier,
40
            'siteId' => $site ? $site->id : null
41
        ]);
42
    }
43
44
    /**
45
     * @inheritdoc
46
     * @param Organization $object
47
     * @return Organization
48
     * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException
49
     */
50
    protected function populate(BaseObject $object): BaseObject
51
    {
52
        parent::populate($object);
53
        $this->populateFromRequest($object);
54
55
        return $object;
56
    }
57
}
58