AbstractAnnotationDriver.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * @author Derek J. Lambert <dlambert@dereklambert.com>
  9. * @package Gedmo.Mapping.Driver
  10. * @subpackage AnnotationDriverInterface
  11. * @link http://www.gediminasm.org
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  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 $driver
  43. *
  44. * @return void
  45. */
  46. public function setOriginalDriver($driver)
  47. {
  48. $this->_originalDriver = $driver;
  49. }
  50. /**
  51. * @param object $meta
  52. *
  53. * @return array
  54. */
  55. public function getMetaReflectionClass($meta)
  56. {
  57. $class = $meta->getReflectionClass();
  58. if (!$class) {
  59. // based on recent doctrine 2.3.0-DEV maybe will be fixed in some way
  60. // this happens when running annotation driver in combination with
  61. // static reflection services. This is not the nicest fix
  62. $class = new \ReflectionClass($meta->name);
  63. }
  64. return $class;
  65. }
  66. }