Configuration.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 LGPL. 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 SQLLogger $logger
  45. */
  46. public function setSQLLogger(SQLLogger $logger = null)
  47. {
  48. $this->_attributes['sqlLogger'] = $logger;
  49. }
  50. /**
  51. * Gets the SQL logger that is used.
  52. *
  53. * @return SQLLogger
  54. */
  55. public function getSQLLogger()
  56. {
  57. return isset($this->_attributes['sqlLogger']) ?
  58. $this->_attributes['sqlLogger'] : null;
  59. }
  60. /**
  61. * Gets the cache driver implementation that is used for query result caching.
  62. *
  63. * @return \Doctrine\Common\Cache\Cache
  64. */
  65. public function getResultCacheImpl()
  66. {
  67. return isset($this->_attributes['resultCacheImpl']) ?
  68. $this->_attributes['resultCacheImpl'] : null;
  69. }
  70. /**
  71. * Sets the cache driver implementation that is used for query result caching.
  72. *
  73. * @param \Doctrine\Common\Cache\Cache $cacheImpl
  74. */
  75. public function setResultCacheImpl(Cache $cacheImpl)
  76. {
  77. $this->_attributes['resultCacheImpl'] = $cacheImpl;
  78. }
  79. /**
  80. * Filter schema assets expression.
  81. *
  82. * Only include tables/sequences matching the filter expression regexp in
  83. * schema instances generated for the active connection when calling
  84. * {AbstractSchemaManager#createSchema()}.
  85. *
  86. * @param string $filterExpression
  87. */
  88. public function setFilterSchemaAssetsExpression($filterExpression)
  89. {
  90. $this->_attributes['filterSchemaAssetsExpression'] = $filterExpression;
  91. }
  92. /**
  93. * Return filter schema assets expression.
  94. *
  95. * @return string|null
  96. */
  97. public function getFilterSchemaAssetsExpression()
  98. {
  99. if (isset($this->_attributes['filterSchemaAssetsExpression'])) {
  100. return $this->_attributes['filterSchemaAssetsExpression'];
  101. }
  102. return null;
  103. }
  104. }