doctrine /
couchdb-odm
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Doctrine\ODM\CouchDB; |
||
| 4 | |||
| 5 | use Doctrine\Common\Cache\Cache; |
||
| 6 | use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; |
||
| 7 | |||
| 8 | use Doctrine\CouchDB\HTTP\Client; |
||
| 9 | use Doctrine\CouchDB\HTTP\SocketClient; |
||
| 10 | use Doctrine\CouchDB\HTTP\LoggingClient; |
||
| 11 | |||
| 12 | use Doctrine\ODM\CouchDB\Mapping\MetadataResolver\MetadataResolver; |
||
| 13 | use Doctrine\ODM\CouchDB\Mapping\MetadataResolver\DoctrineResolver; |
||
| 14 | use Doctrine\ODM\CouchDB\Migrations\DocumentMigration; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Configuration class |
||
| 18 | * |
||
| 19 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL |
||
| 20 | * @link www.doctrine-project.com |
||
| 21 | * @since 1.0 |
||
| 22 | * @author Benjamin Eberlei <[email protected]> |
||
| 23 | * @author Lukas Kahwe Smith <[email protected]> |
||
| 24 | */ |
||
| 25 | class Configuration |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * Array of attributes for this configuration instance. |
||
| 29 | * |
||
| 30 | * @var array $attributes |
||
| 31 | */ |
||
| 32 | private $attributes = array( |
||
| 33 | 'designDocuments' => array( |
||
| 34 | 'doctrine_associations' => array( |
||
| 35 | 'className' => 'Doctrine\ODM\CouchDB\View\DoctrineAssociations', |
||
| 36 | 'options' => array(), |
||
| 37 | ), |
||
| 38 | 'doctrine_repositories' => array( |
||
| 39 | 'className' => 'Doctrine\ODM\CouchDB\View\DoctrineRepository', |
||
| 40 | 'options' => array(), |
||
| 41 | ), |
||
| 42 | ), |
||
| 43 | 'writeDoctrineMetadata' => true, |
||
| 44 | 'validateDoctrineMetadata' => true, |
||
| 45 | 'UUIDGenerationBufferSize' => 20, |
||
| 46 | 'proxyNamespace' => 'MyCouchDBProxyNS', |
||
| 47 | 'allOrNothingFlush' => true, |
||
| 48 | 'luceneHandlerName' => false, |
||
| 49 | 'metadataResolver' => null, |
||
| 50 | 'autoGenerateProxyClasses' => false, |
||
| 51 | ); |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Sets the default UUID Generator buffer size |
||
| 55 | * |
||
| 56 | * @param integer $UUIDGenerationBufferSize |
||
| 57 | */ |
||
| 58 | public function setUUIDGenerationBufferSize($UUIDGenerationBufferSize) |
||
| 59 | { |
||
| 60 | $this->attributes['UUIDGenerationBufferSize'] = $UUIDGenerationBufferSize; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Gets the default UUID Generator buffer size |
||
| 65 | * |
||
| 66 | * @return integer |
||
| 67 | */ |
||
| 68 | public function getUUIDGenerationBufferSize() |
||
| 69 | { |
||
| 70 | return $this->attributes['UUIDGenerationBufferSize']; |
||
| 71 | } |
||
| 72 | /** |
||
| 73 | * Sets if all CouchDB document metadata should be validated on read |
||
| 74 | * |
||
| 75 | * @param boolean $validateDoctrineMetadata |
||
| 76 | */ |
||
| 77 | public function setValidateDoctrineMetadata($validateDoctrineMetadata) |
||
| 78 | { |
||
| 79 | $this->attributes['validateDoctrineMetadata'] = $validateDoctrineMetadata; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Gets if all CouchDB document metadata should be validated on read |
||
| 84 | * |
||
| 85 | * @return boolean |
||
| 86 | */ |
||
| 87 | public function getValidateDoctrineMetadata() |
||
| 88 | { |
||
| 89 | return $this->attributes['validateDoctrineMetadata']; |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Adds a namespace under a certain alias. |
||
| 94 | * |
||
| 95 | * @param string $alias |
||
| 96 | * @param string $namespace |
||
| 97 | */ |
||
| 98 | public function addDocumentNamespace($alias, $namespace) |
||
| 99 | { |
||
| 100 | $this->attributes['documentNamespaces'][$alias] = $namespace; |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Resolves a registered namespace alias to the full namespace. |
||
| 105 | * |
||
| 106 | * @param string $documentNamespaceAlias |
||
| 107 | * @return string |
||
| 108 | * @throws CouchDBException |
||
| 109 | */ |
||
| 110 | public function getDocumentNamespace($documentNamespaceAlias) |
||
| 111 | { |
||
| 112 | if ( ! isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) { |
||
| 113 | throw CouchDBException::unknownDocumentNamespace($documentNamespaceAlias); |
||
| 114 | } |
||
| 115 | |||
| 116 | return trim($this->attributes['documentNamespaces'][$documentNamespaceAlias], '\\'); |
||
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Set the document alias map |
||
| 121 | * |
||
| 122 | * @param array $documentNamespaces |
||
| 123 | * @return void |
||
| 124 | */ |
||
| 125 | public function setDocumentNamespaces(array $documentNamespaces) |
||
| 126 | { |
||
| 127 | $this->attributes['documentNamespaces'] = $documentNamespaces; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Sets the cache driver implementation that is used for metadata caching. |
||
| 132 | * |
||
| 133 | * @param MappingDriver $driverImpl |
||
| 134 | * @todo Force parameter to be a Closure to ensure lazy evaluation |
||
| 135 | * (as soon as a metadata cache is in effect, the driver never needs to initialize). |
||
| 136 | */ |
||
| 137 | public function setMetadataDriverImpl(MappingDriver $driverImpl) |
||
| 138 | { |
||
| 139 | $this->attributes['metadataDriverImpl'] = $driverImpl; |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Add a new default annotation driver with a correctly configured annotation reader. |
||
| 144 | * |
||
| 145 | * @param array $paths |
||
| 146 | * @return Mapping\Driver\AnnotationDriver |
||
| 147 | */ |
||
| 148 | public function newDefaultAnnotationDriver($paths = array()) |
||
| 149 | { |
||
| 150 | $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); |
||
| 151 | $reader->addNamespace('Doctrine\ODM\CouchDB\Mapping\Annotations'); |
||
| 152 | |||
| 153 | return new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader, (array) $paths); |
||
| 154 | } |
||
| 155 | |||
| 156 | public function setMetadataResolverImpl(MetadataResolver $resolver) |
||
| 157 | { |
||
| 158 | $this->attributes['metadataResolver'] = $resolver; |
||
| 159 | } |
||
| 160 | |||
| 161 | public function getMetadataResolverImpl() |
||
| 162 | { |
||
| 163 | if (!$this->attributes['metadataResolver']) { |
||
| 164 | return new DoctrineResolver(); |
||
| 165 | } |
||
| 166 | return $this->attributes['metadataResolver']; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Gets the cache driver implementation that is used for the mapping metadata. |
||
| 171 | * |
||
| 172 | * @return MappingDriver |
||
| 173 | */ |
||
| 174 | public function getMetadataDriverImpl() |
||
| 175 | { |
||
| 176 | if (!isset($this->attributes['metadataDriverImpl'])) { |
||
| 177 | $this->attributes['metadataDriverImpl'] = $this->newDefaultAnnotationDriver(); |
||
| 178 | } |
||
| 179 | return $this->attributes['metadataDriverImpl']; |
||
| 180 | } |
||
| 181 | |||
| 182 | /** |
||
| 183 | * Gets the cache driver implementation that is used for metadata caching. |
||
| 184 | * |
||
| 185 | * @return \Doctrine\Common\Cache\Cache |
||
| 186 | */ |
||
| 187 | public function getMetadataCacheImpl() |
||
| 188 | { |
||
| 189 | return isset($this->attributes['metadataCacheImpl']) ? |
||
| 190 | $this->attributes['metadataCacheImpl'] : null; |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Sets the cache driver implementation that is used for metadata caching. |
||
| 195 | * |
||
| 196 | * @param \Doctrine\Common\Cache\Cache $cacheImpl |
||
| 197 | */ |
||
| 198 | public function setMetadataCacheImpl(Cache $cacheImpl) |
||
| 199 | { |
||
| 200 | $this->attributes['metadataCacheImpl'] = $cacheImpl; |
||
| 201 | } |
||
| 202 | |||
| 203 | /** |
||
| 204 | * Sets the directory where Doctrine generates any necessary proxy class files. |
||
| 205 | * |
||
| 206 | * @param string $dir |
||
| 207 | */ |
||
| 208 | public function setProxyDir($dir) |
||
| 209 | { |
||
| 210 | $this->attributes['proxyDir'] = $dir; |
||
| 211 | } |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Gets the directory where Doctrine generates any necessary proxy class files. |
||
| 215 | * |
||
| 216 | * @return string |
||
| 217 | */ |
||
| 218 | public function getProxyDir() |
||
| 219 | { |
||
| 220 | if (!isset($this->attributes['proxyDir'])) { |
||
| 221 | $this->attributes['proxyDir'] = \sys_get_temp_dir(); |
||
| 222 | } |
||
| 223 | |||
| 224 | return $this->attributes['proxyDir']; |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Sets the namespace for Doctrine proxy class files. |
||
| 229 | * |
||
| 230 | * @param string $namespace |
||
| 231 | */ |
||
| 232 | public function setProxyNamespace($namespace) |
||
| 233 | { |
||
| 234 | $this->attributes['proxyNamespace'] = $namespace; |
||
| 235 | } |
||
| 236 | |||
| 237 | /** |
||
| 238 | * Gets the namespace for Doctrine proxy class files. |
||
| 239 | * |
||
| 240 | * @return string |
||
| 241 | */ |
||
| 242 | public function getProxyNamespace() |
||
| 243 | { |
||
| 244 | return $this->attributes['proxyNamespace']; |
||
| 245 | } |
||
| 246 | |||
| 247 | public function setAutoGenerateProxyClasses($bool) |
||
| 248 | { |
||
| 249 | $this->attributes['autoGenerateProxyClasses'] = $bool; |
||
| 250 | } |
||
| 251 | |||
| 252 | public function getAutoGenerateProxyClasses() |
||
| 253 | { |
||
| 254 | return $this->attributes['autoGenerateProxyClasses']; |
||
| 255 | } |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @param string $name |
||
| 259 | * @param string $className |
||
| 260 | * @param array $options |
||
| 261 | */ |
||
| 262 | public function addDesignDocument($name, $className, $options) |
||
| 263 | { |
||
| 264 | $this->attributes['designDocuments'][$name] = array( |
||
| 265 | 'className' => $className, |
||
| 266 | 'options' => $options, |
||
| 267 | ); |
||
| 268 | } |
||
| 269 | |||
| 270 | /** |
||
| 271 | * @return array |
||
| 272 | */ |
||
| 273 | public function getDesignDocumentNames() |
||
| 274 | { |
||
| 275 | return array_keys($this->attributes['designDocuments']); |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @param string $name |
||
| 280 | * @return array |
||
| 281 | */ |
||
| 282 | public function getDesignDocument($name) |
||
| 283 | { |
||
| 284 | if (isset($this->attributes['designDocuments'][$name])) { |
||
| 285 | return $this->attributes['designDocuments'][$name]; |
||
| 286 | } |
||
| 287 | return null; |
||
| 288 | } |
||
| 289 | |||
| 290 | /** |
||
| 291 | * @param bool $allOrNothing |
||
| 292 | */ |
||
| 293 | public function setAllOrNothingFlush($allOrNothing) |
||
| 294 | { |
||
| 295 | $this->attributes['allOrNothingFlush'] = (bool)$allOrNothing; |
||
| 296 | } |
||
| 297 | |||
| 298 | /** |
||
| 299 | * @return bool |
||
| 300 | */ |
||
| 301 | public function getAllOrNothingFlush() |
||
| 302 | { |
||
| 303 | return $this->attributes['allOrNothingFlush']; |
||
| 304 | } |
||
| 305 | |||
| 306 | public function setLuceneHandlerName($handlerName = '_fti') |
||
| 307 | { |
||
| 308 | $this->attributes['luceneHandlerName'] = $handlerName; |
||
| 309 | } |
||
| 310 | |||
| 311 | public function getLuceneHandlerName() |
||
| 312 | { |
||
| 313 | if (!$this->attributes['luceneHandlerName']) { |
||
| 314 | throw CouchDBException::luceneNotConfigured(); |
||
| 315 | } |
||
| 316 | |||
| 317 | return $this->attributes['luceneHandlerName']; |
||
| 318 | } |
||
| 319 | |||
| 320 | /** |
||
| 321 | * @return \Doctrine\ODM\CouchDB\Migrations\NullMigration; |
||
|
0 ignored issues
–
show
|
|||
| 322 | */ |
||
| 323 | public function getMigrations() |
||
| 324 | { |
||
| 325 | if (!isset($this->attributes['migrations'])) { |
||
| 326 | $this->attributes['migrations'] = new Migrations\NullMigration(); |
||
| 327 | } |
||
| 328 | |||
| 329 | return $this->attributes['migrations']; |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @param DocumentMigration $migration |
||
| 334 | */ |
||
| 335 | public function setMigrations(DocumentMigration $migration) |
||
| 336 | { |
||
| 337 | $this->attributes['migrations'] = $migration; |
||
| 338 | } |
||
| 339 | } |
||
| 340 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.