dfeyer

Untitled

Sep 25th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. <?php
  2. namespace Ttree\Medialib\Core\Persistence\Aspect;
  3.  
  4. /*                                                                        *
  5.  * This script belongs to the FLOW3 package "Ttree.Medialib".             *
  6.  *                                                                        *
  7.  *                                                                        */
  8.  
  9. use Doctrine\ORM\Mapping as ORM;
  10. use TYPO3\FLOW3\Annotations as FLOW3;
  11.  
  12. /**
  13.  * Adds the aspect to force owner field for all persited object
  14.  *
  15.  * @FLOW3\Aspect
  16.  * @FLOW3\Introduce("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isPrivateEntityOrPrivateValueObject", interfaceName="Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerInterface")
  17.  */
  18. class PersistenceOwnerAspect {
  19.  
  20.     /**
  21.      * @FLOW3\Pointcut("classAnnotatedWith(TYPO3\FLOW3\Annotations\Entity) || classAnnotatedWith(Doctrine\ORM\Mapping\Entity)")
  22.      */
  23.     public function isEntity() {}
  24.  
  25.     /**
  26.      * @FLOW3\Pointcut("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isEntity || classAnnotatedWith(TYPO3\FLOW3\Annotations\ValueObject)")
  27.      */
  28.     public function isEntityOrValueObject() {}
  29.  
  30.     /**
  31.      * @FLOW3\Pointcut("classAnnotatedWith(Ttree\Medialib\Core\Annotations\PrivateEntity) && Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isEntity")
  32.      */
  33.     public function isPrivateEntity() {}
  34.  
  35.     /**
  36.      * @FLOW3\Pointcut("classAnnotatedWith(Ttree\Medialib\Core\Annotations\PrivateEntity) && Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isEntityOrValueObject")
  37.      */
  38.     public function isPrivateEntityOrPrivateValueObject() {}
  39.  
  40.     /**
  41.      * @FLOW3\Inject
  42.      * @var \TYPO3\FLOW3\Security\Context
  43.      */
  44.     protected $securityContext;
  45.  
  46.     /**
  47.      * @var \Ttree\Medialib\Core\Domain\Model\Domain
  48.      * @ORM\ManyToOne
  49.      * @FLOW3\Introduce("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isPrivateEntityOrPrivateValueObject")
  50.      */
  51.     protected $medialib_owner;
  52.  
  53.     /**
  54.      * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current join point
  55.      * @return void
  56.      * @FLOW3\Before("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isPrivateEntityOrPrivateValueObject && method(.*->(__construct|__clone)())")
  57.      */
  58.     public function prepareEntityOwner(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint) {
  59.         $proxy = $joinPoint->getProxy();
  60.         \TYPO3\FLOW3\Reflection\ObjectAccess::setProperty($proxy, 'medialib_owner', $this->securityContext->getDomain(), TRUE);
  61.     }
  62.  
  63.  
  64. }
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment