Completed
Pull Request — master (#52)
by Olexandr
03:33
created

Entity   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createRow() 0 17 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: VITALYIEGOROV
5
 * Date: 09.12.15
6
 * Time: 12:10
7
 */
8
namespace samsoncms\api\table;
9
10
/**
11
 * SamsonCMS Entity table.
12
 *
13
 * @package samsoncms\api
14
 */
15
class Entity extends \samsoncms\api\Entity
16
{
17
    /** @var int Parent table structure identifier */
18
    protected $structureID;
19
20
    public function createRow()
21
    {
22
        // Create row table material
23
        $row = new Material();
24
        $row->parent_id = $this->id;
25
        $row->Active = 1;
26
        $row->save();
27
28
        // Create row material relation to specific table
29
        $structureMaterial = new NavigationMaterial();
30
        $structureMaterial->MaterialID = $row->id;
31
        $structureMaterial->StructureID = $this->structureID;
32
        $structureMaterial->Active = 1;
33
        $structureMaterial->save();
34
35
        return $row;
36
    }
37
}
38