Configuration.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\DBAL;
  20. use Doctrine\DBAL\Logging\SQLLogger;
  21. use Doctrine\Common\Cache\Cache;
  22. /**
  23. * Configuration container for the Doctrine DBAL.
  24. *
  25. * @since 2.0
  26. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  27. * @author Jonathan Wage <jonwage@gmail.com>
  28. * @author Roman Borschel <roman@code-factory.org>
  29. * @internal When adding a new configuration option just write a getter/setter
  30. * pair and add the option to the _attributes array with a proper default value.
  31. */
  32. class Configuration
  33. {
  34. /**
  35. * The attributes that are contained in the configuration.
  36. * Values are default values.
  37. *
  38. * @var array
  39. */
  40. protected $_attributes = array();
  41. /**
  42. * Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
  43. *
  44. * @param \Doctrine\DBAL\Logging\SQLLogger|null $logger
  45. *
  46. * @return void
  47. */
  48. public function setSQLLogger(SQLLogger $logger = null)
  49. {
  50. $this->_attributes['sqlLogger'] = $logger;
  51. }
  52. /**
  53. * Gets the SQL logger that is used.
  54. *
  55. * @return \Doctrine\DBAL\Logging\SQLLogger
  56. */
  57. public function getSQLLogger()
  58. {
  59. return isset($this->_attributes['sqlLogger']) ?
  60. $this->_attributes['sqlLogger'] : null;
  61. }
  62. /**
  63. * Gets the cache driver implementation that is used for query result caching.
  64. *
  65. * @return \Doctrine\Common\Cache\Cache|null
  66. */
  67. public function getResultCacheImpl()
  68. {
  69. return isset($this->_attributes['resultCacheImpl']) ?
  70. $this->_attributes['resultCacheImpl'] : null;
  71. }
  72. /**
  73. * Sets the cache driver implementation that is used for query result caching.
  74. *
  75. * @param \Doctrine\Common\Cache\Cache $cacheImpl
  76. *
  77. * @return void
  78. */
  79. public function setResultCacheImpl(Cache $cacheImpl)
  80. {
  81. $this->_attributes['resultCacheImpl'] = $cacheImpl;
  82. }
  83. /**
  84. * Sets the filter schema assets expression.
  85. *
  86. * Only include tables/sequences matching the filter expression regexp in
  87. * schema instances generated for the active connection when calling
  88. * {AbstractSchemaManager#createSchema()}.
  89. *
  90. * @param string $filterExpression
  91. *
  92. * @return void
  93. */
  94. public function setFilterSchemaAssetsExpression($filterExpression)
  95. {
  96. $this->_attributes['filterSchemaAssetsExpression'] = $filterExpression;
  97. }
  98. /**
  99. * Returns filter schema assets expression.
  100. *
  101. * @return string|null
  102. */
  103. public function getFilterSchemaAssetsExpression()
  104. {
  105. if (isset($this->_attributes['filterSchemaAssetsExpression'])) {
  106. return $this->_attributes['filterSchemaAssetsExpression'];
  107. }
  108. return null;
  109. }
  110. }