-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathNodeHelper.php
52 lines (46 loc) · 1.11 KB
/
NodeHelper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
* This file is part of the PHPCR Shell package
*
* (c) Daniel Leech <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PHPCR\Shell\Console\Helper;
use PHPCR\NodeInterface;
use Symfony\Component\Console\Helper\Helper;
/**
* Helper for nodes.
*
* @author Daniel Leech <[email protected]>
*/
class NodeHelper extends Helper
{
/**
* Return true if the given node has the given mixinType.
*
* @return bool
*/
public function nodeHasMixinType($node, $mixinTypeName)
{
return $node->isNodeType($mixinTypeName);
}
/**
* Return true if the given node is versionable.
*/
public function assertNodeIsVersionable(NodeInterface $node)
{
if (!$this->nodeHasMixinType($node, 'mix:versionable')) {
throw new \OutOfBoundsException(sprintf(
'Node "%s" is not versionable',
$node->getPath()
));
}
}
public function getName(): string
{
return 'node';
}
}