Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Ttree\Medialib\Core\Persistence\Aspect;
- /* *
- * This script belongs to the FLOW3 package "Ttree.Medialib". *
- * *
- * */
- use Doctrine\ORM\Mapping as ORM;
- use TYPO3\FLOW3\Annotations as FLOW3;
- /**
- * Adds the aspect to force owner field for all persited object
- *
- * @FLOW3\Aspect
- * @FLOW3\Introduce("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isPrivateEntityOrPrivateValueObject", interfaceName="Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerInterface")
- */
- class PersistenceOwnerAspect {
- /**
- * @FLOW3\Pointcut("classAnnotatedWith(TYPO3\FLOW3\Annotations\Entity) || classAnnotatedWith(Doctrine\ORM\Mapping\Entity)")
- */
- public function isEntity() {}
- /**
- * @FLOW3\Pointcut("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isEntity || classAnnotatedWith(TYPO3\FLOW3\Annotations\ValueObject)")
- */
- public function isEntityOrValueObject() {}
- /**
- * @FLOW3\Pointcut("classAnnotatedWith(Ttree\Medialib\Core\Annotations\PrivateEntity) && Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isEntity")
- */
- public function isPrivateEntity() {}
- /**
- * @FLOW3\Pointcut("classAnnotatedWith(Ttree\Medialib\Core\Annotations\PrivateEntity) && Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isEntityOrValueObject")
- */
- public function isPrivateEntityOrPrivateValueObject() {}
- /**
- * @FLOW3\Inject
- * @var \TYPO3\FLOW3\Security\Context
- */
- protected $securityContext;
- /**
- * @var \Ttree\Medialib\Core\Domain\Model\Domain
- * @ORM\ManyToOne
- * @FLOW3\Introduce("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isPrivateEntityOrPrivateValueObject")
- */
- protected $medialib_owner;
- /**
- * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current join point
- * @return void
- * @FLOW3\Before("Ttree\Medialib\Core\Persistence\Aspect\PersistenceOwnerAspect->isPrivateEntityOrPrivateValueObject && method(.*->(__construct|__clone)())")
- */
- public function prepareEntityOwner(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint) {
- $proxy = $joinPoint->getProxy();
- \TYPO3\FLOW3\Reflection\ObjectAccess::setProperty($proxy, 'medialib_owner', $this->securityContext->getDomain(), TRUE);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment