Annotation.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Gedmo\SoftDeleteable\Mapping\Driver;
  3. use Gedmo\Mapping\Driver\AbstractAnnotationDriver,
  4. Doctrine\Common\Persistence\Mapping\ClassMetadata,
  5. Gedmo\Exception\InvalidMappingException,
  6. Gedmo\SoftDeleteable\Mapping\Validator;
  7. /**
  8. * This is an annotation mapping driver for SoftDeleteable
  9. * behavioral extension. Used for extraction of extended
  10. * metadata from Annotations specificaly for SoftDeleteable
  11. * extension.
  12. *
  13. * @author Gustavo Falco <comfortablynumb84@gmail.com>
  14. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  15. * @package Gedmo.SoftDeleteable.Mapping.Driver
  16. * @subpackage Annotation
  17. * @link http://www.gediminasm.org
  18. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  19. */
  20. class Annotation extends AbstractAnnotationDriver
  21. {
  22. /**
  23. * Annotation to define that this object is loggable
  24. */
  25. const SOFT_DELETEABLE = 'Gedmo\\Mapping\\Annotation\\SoftDeleteable';
  26. /**
  27. * {@inheritDoc}
  28. */
  29. public function readExtendedMetadata($meta, array &$config)
  30. {
  31. $class = $this->getMetaReflectionClass($meta);
  32. // class annotations
  33. if ($class !== null && $annot = $this->reader->getClassAnnotation($class, self::SOFT_DELETEABLE)) {
  34. $config['softDeleteable'] = true;
  35. Validator::validateField($meta, $annot->fieldName);
  36. $config['fieldName'] = $annot->fieldName;
  37. }
  38. $this->validateFullMetadata($meta, $config);
  39. }
  40. }