|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This software package is licensed under `AGPL-3.0-only, proprietary` license[s]. |
|
5
|
|
|
* |
|
6
|
|
|
* @package maslosoft/signals |
|
7
|
|
|
* @license AGPL-3.0-only, proprietary |
|
8
|
|
|
* |
|
9
|
|
|
* @copyright Copyright (c) Peter Maselkowski <[email protected]> |
|
10
|
|
|
* @link https://maslosoft.com/signals/ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Maslosoft\Signals\Meta; |
|
14
|
|
|
|
|
15
|
|
|
use Maslosoft\Addendum\Collections\Meta; |
|
16
|
|
|
use Maslosoft\Addendum\Interfaces\AnnotatedInterface; |
|
17
|
|
|
use Maslosoft\Addendum\Options\MetaOptions; |
|
18
|
|
|
use Maslosoft\Signals\Options\SignalsMetaOptions; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Signals metadata container class |
|
22
|
|
|
* @codeCoverageIgnore |
|
23
|
|
|
* @author Piotr Maselkowski <pmaselkowski at gmail.com> |
|
24
|
|
|
*/ |
|
25
|
|
|
class SignalsMeta extends Meta |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Create instance of Metadata specifically designed for Signals |
|
30
|
|
|
* @param string|object|AnnotatedInterface $model |
|
31
|
|
|
* @param MetaOptions $options |
|
32
|
|
|
* @return SignalsMeta |
|
33
|
|
|
*/ |
|
34
|
|
|
public static function create($model, MetaOptions $options = null) |
|
35
|
|
|
{ |
|
36
|
|
|
if (null === $options) |
|
37
|
|
|
{ |
|
38
|
|
|
$options = new SignalsMetaOptions(); |
|
39
|
|
|
} |
|
40
|
|
|
$meta = parent::create($model, $options); |
|
41
|
|
|
assert($meta instanceof SignalsMeta); |
|
42
|
|
|
return $meta; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Get field by name |
|
47
|
|
|
* @param string $name |
|
48
|
|
|
* @return DocumentPropertyMeta |
|
49
|
|
|
*/ |
|
50
|
|
|
public function field($name) |
|
51
|
|
|
{ |
|
52
|
|
|
$meta = parent::field($name); |
|
53
|
|
|
assert($meta instanceof DocumentPropertyMeta); |
|
54
|
|
|
return $meta; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Get document type meta |
|
59
|
|
|
* @return DocumentTypeMeta |
|
60
|
|
|
*/ |
|
61
|
|
|
public function type() |
|
62
|
|
|
{ |
|
63
|
|
|
$meta = parent::type(); |
|
64
|
|
|
assert($meta instanceof DocumentTypeMeta); |
|
65
|
|
|
return $meta; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|