12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace Gedmo\SoftDeleteable\Mapping\Driver;
- use Gedmo\Mapping\Driver\AnnotationDriverInterface,
- Doctrine\Common\Persistence\Mapping\ClassMetadata,
- Gedmo\Exception\InvalidMappingException,
- Gedmo\SoftDeleteable\Mapping\Validator;
- /**
- * This is an annotation mapping driver for SoftDeleteable
- * behavioral extension. Used for extraction of extended
- * metadata from Annotations specificaly for SoftDeleteable
- * extension.
- *
- * @author Gustavo Falco <comfortablynumb84@gmail.com>
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
- * @package Gedmo.SoftDeleteable.Mapping.Driver
- * @subpackage Annotation
- * @link http://www.gediminasm.org
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
- class Annotation implements AnnotationDriverInterface
- {
- /**
- * Annotation to define that this object is loggable
- */
- const SOFT_DELETEABLE = 'Gedmo\\Mapping\\Annotation\\SoftDeleteable';
- /**
- * Annotation reader instance
- *
- * @var object
- */
- private $reader;
- /**
- * original driver if it is available
- */
- protected $_originalDriver = null;
- /**
- * {@inheritDoc}
- */
- public function setAnnotationReader($reader)
- {
- $this->reader = $reader;
- }
- /**
- * {@inheritDoc}
- */
- public function validateFullMetadata(ClassMetadata $meta, array $config)
- {
- // Nothing here for now
- }
- /**
- * {@inheritDoc}
- */
- public function readExtendedMetadata($meta, array &$config)
- {
- $class = $meta->getReflectionClass();
- // class annotations
- if ($class !== null && $annot = $this->reader->getClassAnnotation($class, self::SOFT_DELETEABLE)) {
- $config['softDeleteable'] = true;
- Validator::validateField($meta, $annot->fieldName);
-
- $config['fieldName'] = $annot->fieldName;
- }
- $this->validateFullMetadata($meta, $config);
- }
- /**
- * Passes in the mapping read by original driver
- *
- * @param $driver
- * @return void
- */
- public function setOriginalDriver($driver)
- {
- $this->_originalDriver = $driver;
- }
- }
|