Completed
Push — master ( b27204...a2c64d )
by Nate
05:15 queued 02:48
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
        $organization = Organization::findOne([
39
            is_numeric($identifier) ? 'id' : 'slug' => $identifier,
40
            'siteId' => $site ? $site->id : null
41
        ]);
42
43
        $organization->setScenario(Organization::SCENARIO_LIVE);
44
45
        return $organization;
46
    }
47
48
    /**
49
     * @inheritdoc
50
     * @param Organization $object
51
     * @return Organization
52
     * @throws \flipbox\craft\ember\exceptions\RecordNotFoundException
53
     */
54
    protected function populate(BaseObject $object): BaseObject
55
    {
56
        parent::populate($object);
57
        $this->populateFromRequest($object);
58
59
        return $object;
60
    }
61
}
62