Maslosoft Mangan API
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
<?php
/**
* This software package is licensed under AGPL or Commercial license.
*
* @package maslosoft/mangan
* @licence AGPL or Commercial
* @copyright Copyright (c) Piotr Masełkowski <pmaselkowski@gmail.com>
* @copyright Copyright (c) Maslosoft
* @copyright Copyright (c) Others as mentioned in code
* @link https://maslosoft.com/mangan/
*/
namespace Maslosoft\Mangan\Meta;
use Maslosoft\Addendum\Collections\MetaType;
use Maslosoft\Mangan\Annotations\AliasAnnotation;
use Maslosoft\Mangan\Annotations\ClientFlagAnnotation;
use Maslosoft\Mangan\Annotations\CollectionNameAnnotation;
use Maslosoft\Mangan\Annotations\ConnectionIdAnnotation;
use Maslosoft\Mangan\Annotations\EntityManagerAnnotation;
use Maslosoft\Mangan\Annotations\FinderAnnotation;
use Maslosoft\Mangan\Annotations\HomogenousAnnotation;
use Maslosoft\Mangan\Annotations\LabelAnnotation;
use Maslosoft\Mangan\Annotations\PrimaryKeyAnnotation;
use Maslosoft\Mangan\EntityManager;
use Maslosoft\Mangan\Exceptions\ManganException;
use Maslosoft\Mangan\Helpers\PropertyMaker;
use Maslosoft\Mangan\Mangan;
use ReflectionClass;
use Symfony\Component\Finder\Finder;
/**
* Model meta container
*
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
class DocumentTypeMeta extends MetaType
{
use \Maslosoft\Mangan\Traits\Defaults\MongoClientOptions,
\Maslosoft\Mangan\Traits\Access\GetSet;
/**
* Field label
* @see LabelAnnotation
* @var string
*/
public $label = '';
/**
* Description
* @var string
*/
public $description = '';
/**
* Collection name
* @see CollectionNameAnnotation
* @var string
*/
public $collectionName = '';
/**
* Connection ID
* @see ConnectionIdAnnotation
* @var string
*/
public $connectionId = Mangan::DefaultConnectionId;
/**
* Annotation defined client connection flags
* @see ClientFlagAnnotation
* @var mixed[]
*/
public $clientFlags = [];
/**
* Primary key field or fields
* @see PrimaryKeyAnnotation
* @var string|array
*/
public $primaryKey = null;
/**
* Whenever to use cursors
* @var bool
*/
public $useCursor = false;
/**
* Whenever colleciton is homogenous
* @see HomogenousAnnotation
* @var bool
*/
public $homogenous = true;
/**
* Finder class name to return by Finder from create method
* @see Finder::create()
* @see FinderAnnotation
* @var string
*/
public $finder = null;
/**
* Entity Manager class name to return by EntityManager from create method
* @see EntityManager::create()
* @see EntityManagerAnnotation
* @var string
*/
public $entityManager = null;
/**
* Property aliases. This consists of source property name as key, and destination property as value.
* @var string[]
* @see AliasAnnotation
*/
public $aliases = [];
/**
* Validators configuration
* @var ValidatorMeta[]
*/
public $validators = [];
/**
* Values of properties
* @var mixed
*/
private $_values = [];
private $_defaults = [];
public function __construct(ReflectionClass $info = null)
{
// Client Options must be unset to allow cascading int EntityOptions
parent::__construct($info);
foreach ($this->_getOptionNames() as $name)
{
PropertyMaker::defineProperty($this, $name, $this->_values);
$this->_defaults[$name] = true;
}
}
public function __get($name)
{
if ($this->_hasGetter($name))
{
return parent::__get($name);
}
if (!array_key_exists($name, $this->_values))
{
throw new ManganException(sprintf('Trying to read unitialized property `%s`', $name));
}
return $this->_values[$name];
}
public function __set($name, $value)
{
if ($this->_hasSetter($name))
{
return parent::__set($name);
}
$this->_values[$name] = $value;
$this->_defaults[$name] = false;
}
public function __isset($name)
{
return array_key_exists($name, $this->_defaults) && $this->_defaults[$name] === false;
}
}
API documentation generated by ApiGen