Completed
Branch FET/cascade-deletion (d58b4b)
by
unknown
31:20 queued 23:22
created

RelationNode::isDiscovered()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 4
c 0
b 0
f 0
cc 1
nop 0
rs 10
1
<?php
2
3
namespace EventEspresso\core\services\orm\tree_traversal;
4
5
use EE_Base_Class;
6
use EventEspresso\core\libraries\rest_api\controllers\Base;
7
8
/**
9
 * Class RelationNode
10
 *
11
 * Description
12
 *
13
 * @package     Event Espresso
14
 * @author         Mike Nelson
15
 * @since         $VID:$
16
 *
17
 */
18
class RelationNode extends BaseNode
19
{
20
    /**
21
     * @var EE_Base_Class
22
     */
23
    protected $mainEntity;
24
25
    /**
26
     * @var int
27
     */
28
    protected $count;
29
30
    /**
31
     * @var \EE_Model_Relation_Base
32
     */
33
    protected $relation;
34
35
36
    protected $itemNodes;
37
38
    public function __construct($mainEntity, $relation)
39
    {
40
        $this->mainEntity = $mainEntity;
41
        $this->relation = $relation;
42
    }
43
44
45
46
    protected function work($work_to_do){
47
        $items = $this->relation->get_this_model()->get_all_related(
48
            $this->mainEntity,
49
            $this->relation->get_other_model(),
50
            [
51
                'limit' => $work_to_do
52
            ]
53
        );
54
        foreach($items as $item){
55
            $this->itemNodes[] = new EntityNode($item);
56
        }
57
    }
58
59
    /**
60
     * Whether this item has already been initialized
61
     */
62
    public function isDiscovered()
63
    {
64
        // TODO: Implement isDiscovered() method.
65
    }
66
67
    /**
68
     * @since $VID:$
69
     * @return boolean
70
     */
71
    public function isComplete()
72
    {
73
        // TODO: Implement isComplete() method.
74
    }
75
76
    public function discover()
77
    {
78
        $this->count = $this->relation->get_this_model()->count_related($this->mainEntity, $this->relation->get_other_model());
79
    }
80
}
81
// End of file RelationNode.php
82
// Location: EventEspresso\core\services\orm\tree_traversal/RelationNode.php
83