SaveElementTrait::runInternal()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 11
cp 0
rs 9.7333
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-ember/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-ember/
7
 */
8
9
namespace flipbox\craft\ember\actions\elements;
10
11
use craft\base\ElementInterface;
12
use flipbox\craft\ember\actions\PopulateTrait;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 *
18
 * @method ElementInterface populate(ElementInterface $object);
19
 */
20
trait SaveElementTrait
21
{
22
    use PopulateTrait, ManageElementTrait;
23
24
    /**
25
     * @inheritdoc
26
     * @param ElementInterface $element
27
     * @throws \yii\base\Exception
28
     * @throws \yii\web\UnauthorizedHttpException
29
     */
30
    public function runInternal(ElementInterface $element)
31
    {
32
        // Populate
33
        $this->populate($element);
34
35
        // Check access
36
        if (($access = $this->checkAccess($element)) !== true) {
37
            return $access;
38
        }
39
40
        if (!$this->performAction($element)) {
41
            return $this->handleFailResponse($element);
42
        }
43
44
        return $this->handleSuccessResponse($element);
45
    }
46
}
47