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

Entity::createRow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 17
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
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