Completed
Branch EDTR/master (7a3fe8)
by
unknown
10:11 queued 01:18
created

BlockRenderer::parseGUID()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace EventEspresso\core\services\blocks;
3
4
use EventEspresso\core\domain\DomainInterface;
5
use GraphQLRelay\Relay;
6
7
/**
8
 * BlockRenderer
9
 *
10
 *
11
 * @package EventEspresso\core\services\blocks
12
 * @author  Darren Ethier
13
 * @since   4.9.71.p
14
 */
15
abstract class BlockRenderer implements BlockRendererInterface
16
{
17
18
    /**
19
     * @var DomainInterface
20
     */
21
    protected $domain;
22
23
    /**
24
     * @var string
25
     */
26
    private $template_root_path;
27
28
29
    /**
30
     * BlockRenderer constructor.
31
     *
32
     * @param DomainInterface $domain
33
     */
34
    public function __construct(DomainInterface $domain)
35
    {
36
        $this->domain = $domain;
37
        $this->setTemplateRootPath();
38
    }
39
40
41
    /**
42
     * Sets the root path to the main block template.
43
     */
44
    private function setTemplateRootPath()
45
    {
46
        $this->template_root_path = $this->domain->pluginPath() . 'ui/blocks/';
47
    }
48
49
50
    /**
51
     * Exposes the root path for the main block template.
52
     * @return string
53
     */
54
    public function templateRootPath()
55
    {
56
        return $this->template_root_path;
57
    }
58
59
60
    /**
61
     * converts GraphQL GUID into EE DB ID
62
     *
63
     * @param string $GUID
64
     * @return int
65
     */
66
    protected function parseGUID($GUID)
67
    {
68
        $parts = Relay::fromGlobalId($GUID);
69
        return ! empty($parts['id']) ? $parts['id'] : 0;
70
    }
71
}
72