AbstractAnnotationDriver.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Gedmo\Mapping\Driver;
  3. use Gedmo\Mapping\Driver\AnnotationDriverInterface;
  4. /**
  5. * This is an abstract class to implement common functionality
  6. * for extension annotation mapping drivers.
  7. *
  8. * @package Gedmo.Mapping.Driver
  9. * @subpackage AnnotationDriverInterface
  10. * @author Derek J. Lambert <dlambert@dereklambert.com>
  11. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  12. * @link http://www.gediminasm.org
  13. */
  14. abstract class AbstractAnnotationDriver implements AnnotationDriverInterface
  15. {
  16. /**
  17. * Annotation reader instance
  18. *
  19. * @var object
  20. */
  21. protected $reader;
  22. /**
  23. * Original driver if it is available
  24. */
  25. protected $_originalDriver = null;
  26. /**
  27. * List of types which are valid for extension
  28. *
  29. * @var array
  30. */
  31. protected $validTypes = array();
  32. /**
  33. * {@inheritDoc}
  34. */
  35. public function setAnnotationReader($reader)
  36. {
  37. $this->reader = $reader;
  38. }
  39. /**
  40. * Passes in the mapping read by original driver
  41. *
  42. * @param object $driver
  43. */
  44. public function setOriginalDriver($driver)
  45. {
  46. $this->_originalDriver = $driver;
  47. }
  48. /**
  49. * @param object $meta
  50. *
  51. * @return array
  52. */
  53. public function getMetaReflectionClass($meta)
  54. {
  55. $class = $meta->getReflectionClass();
  56. if (!$class) {
  57. // based on recent doctrine 2.3.0-DEV maybe will be fixed in some way
  58. // this happens when running annotation driver in combination with
  59. // static reflection services. This is not the nicest fix
  60. $class = new \ReflectionClass($meta->name);
  61. }
  62. return $class;
  63. }
  64. /**
  65. * Checks if $field type is valid
  66. *
  67. * @param object $meta
  68. * @param string $field
  69. *
  70. * @return boolean
  71. */
  72. protected function isValidField($meta, $field)
  73. {
  74. $mapping = $meta->getFieldMapping($field);
  75. return $mapping && in_array($mapping['type'], $this->validTypes);
  76. }
  77. /**
  78. * @param Doctrine\ORM\Mapping\ClassMetadata $meta
  79. * @param array $config
  80. */
  81. public function validateFullMetadata(\Doctrine\ORM\Mapping\ClassMetadata $meta, array $config)
  82. {
  83. }
  84. }