本文整理汇总了PHP中TYPO3\Flow\Reflection\ReflectionService::getClassNamesByAnnotation方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionService::getClassNamesByAnnotation方法的具体用法?PHP ReflectionService::getClassNamesByAnnotation怎么用?PHP ReflectionService::getClassNamesByAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Reflection\ReflectionService
的用法示例。
在下文中一共展示了ReflectionService::getClassNamesByAnnotation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reduceTargetClassNames
/**
* This method is used to optimize the matching process.
*
* @param \TYPO3\Flow\Aop\Builder\ClassNameIndex $classNameIndex
* @return \TYPO3\Flow\Aop\Builder\ClassNameIndex
*/
public function reduceTargetClassNames(\TYPO3\Flow\Aop\Builder\ClassNameIndex $classNameIndex)
{
$classNames = $this->reflectionService->getClassNamesByAnnotation(Flow\ValueObject::class);
$annotatedIndex = new \TYPO3\Flow\Aop\Builder\ClassNameIndex();
$annotatedIndex->setClassNames($classNames);
return $classNameIndex->intersect($annotatedIndex);
}
示例2: getAllClassNames
/**
* Returns the names of all mapped (non-transient) classes known to this driver.
*
* @return array
*/
public function getAllClassNames()
{
if (is_array($this->classNames)) {
return $this->classNames;
}
$this->classNames = array_merge($this->reflectionService->getClassNamesByAnnotation(\TYPO3\Flow\Annotations\ValueObject::class), $this->reflectionService->getClassNamesByAnnotation(\TYPO3\Flow\Annotations\Entity::class), $this->reflectionService->getClassNamesByAnnotation('Doctrine\\ORM\\Mapping\\Entity'), $this->reflectionService->getClassNamesByAnnotation('Doctrine\\ORM\\Mapping\\MappedSuperclass'));
$this->classNames = array_filter($this->classNames, function ($className) {
return !interface_exists($className, false) && strpos($className, Compiler::ORIGINAL_CLASSNAME_SUFFIX) === false;
});
return $this->classNames;
}
示例3: getAllClassNames
/**
* Returns the names of all mapped (non-transient) classes known to this driver.
*
* @return array
*/
public function getAllClassNames()
{
if (is_array($this->classNames)) {
return $this->classNames;
}
$this->classNames = array_merge($this->reflectionService->getClassNamesByAnnotation(Flow\ValueObject::class), $this->reflectionService->getClassNamesByAnnotation(Flow\Entity::class), $this->reflectionService->getClassNamesByAnnotation(ORM\Entity::class), $this->reflectionService->getClassNamesByAnnotation(ORM\MappedSuperclass::class), $this->reflectionService->getClassNamesByAnnotation(ORM\Embeddable::class));
$this->classNames = array_filter($this->classNames, function ($className) {
return !interface_exists($className, false) && strpos($className, Compiler::ORIGINAL_CLASSNAME_SUFFIX) === false;
});
return $this->classNames;
}
示例4: registerEntityAuditEventListenerToEventManager
/**
* @Flow\Around("method(TYPO3\Flow\Persistence\Doctrine\EntityManagerFactory->getEventManager())")
* @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
* @return \Doctrine\Common\EventManager
*/
public function registerEntityAuditEventListenerToEventManager(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
{
$eventManager = $joinPoint->getAdviceChain()->proceed($joinPoint);
$classNamesAnnotatedAsVersionable = $this->reflectionService->getClassNamesByAnnotation('TYPO3\\Doctrine\\Versionable\\Annotations\\Versionable');
if (!is_array($classNamesAnnotatedAsVersionable)) {
return;
}
foreach ($classNamesAnnotatedAsVersionable as $index => $className) {
if (!$this->reflectionService->isClassAnnotatedWith($className, 'TYPO3\\Flow\\Annotations\\Entity')) {
unset($classNamesAnnotatedAsVersionable[$index]);
}
}
if ($classNamesAnnotatedAsVersionable !== array()) {
$auditConfiguration = new \SimpleThings\EntityAudit\AuditConfiguration();
$auditConfiguration->setAuditedEntityClasses($classNamesAnnotatedAsVersionable);
$auditManager = new \SimpleThings\EntityAudit\AuditManager($auditConfiguration);
$auditManager->registerEvents($eventManager);
}
return $eventManager;
}
示例5: build
/**
* Builds proxy class code which weaves advices into the respective target classes.
*
* The object configurations provided by the Compiler are searched for possible aspect
* annotations. If an aspect class is found, the pointcut expressions are parsed and
* a new aspect with one or more advisors is added to the aspect registry of the AOP framework.
* Finally all advices are woven into their target classes by generating proxy classes.
*
* In general, the command typo3.flow:core:compile is responsible for compilation
* and calls this method to do so.
*
* In order to distinguish between an emerged / changed possible target class and
* a class which has been matched previously but just didn't have to be proxied,
* the latter are kept track of by an "unproxiedClass-*" cache entry.
*
* @return void
*/
public function build()
{
$allAvailableClassNamesByPackage = $this->objectManager->getRegisteredClassNames();
$possibleTargetClassNames = $this->getProxyableClasses($allAvailableClassNamesByPackage);
$actualAspectClassNames = $this->reflectionService->getClassNamesByAnnotation(Flow\Aspect::class);
sort($possibleTargetClassNames);
sort($actualAspectClassNames);
$this->aspectContainers = $this->buildAspectContainers($actualAspectClassNames);
$rebuildEverything = false;
if ($this->objectConfigurationCache->has('allAspectClassesUpToDate') === false) {
$rebuildEverything = true;
$this->systemLogger->log('Aspects have been modified, therefore rebuilding all target classes.', LOG_INFO);
$this->objectConfigurationCache->set('allAspectClassesUpToDate', true);
}
$possibleTargetClassNameIndex = new ClassNameIndex();
$possibleTargetClassNameIndex->setClassNames($possibleTargetClassNames);
$targetClassNameCandidates = new ClassNameIndex();
foreach ($this->aspectContainers as $aspectContainer) {
$targetClassNameCandidates->applyUnion($aspectContainer->reduceTargetClassNames($possibleTargetClassNameIndex));
}
$targetClassNameCandidates->sort();
$treatedSubClasses = new ClassNameIndex();
foreach ($targetClassNameCandidates->getClassNames() as $targetClassName) {
$isUnproxied = $this->objectConfigurationCache->has('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
$hasCacheEntry = $this->compiler->hasCacheEntryForClass($targetClassName) || $isUnproxied;
if ($rebuildEverything === true || $hasCacheEntry === false) {
$proxyBuildResult = $this->buildProxyClass($targetClassName, $this->aspectContainers);
if ($proxyBuildResult === false) {
// In case the proxy was not build because there was nothing adviced,
// it might be an advice in the parent and so we need to try to treat this class.
$treatedSubClasses = $this->addBuildMethodsAndAdvicesCodeToClass($targetClassName, $treatedSubClasses);
}
$treatedSubClasses = $this->proxySubClassesOfClassToEnsureAdvices($targetClassName, $targetClassNameCandidates, $treatedSubClasses);
if ($proxyBuildResult !== false) {
if ($isUnproxied) {
$this->objectConfigurationCache->remove('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
}
$this->systemLogger->log(sprintf('Built AOP proxy for class "%s".', $targetClassName), LOG_DEBUG);
} else {
$this->objectConfigurationCache->set('unproxiedClass-' . str_replace('\\', '_', $targetClassName), true);
}
}
}
}
示例6: build
/**
* Builds proxy class code which weaves advices into the respective target classes.
*
* The object configurations provided by the Compiler are searched for possible aspect
* annotations. If an aspect class is found, the pointcut expressions are parsed and
* a new aspect with one or more advisors is added to the aspect registry of the AOP framework.
* Finally all advices are woven into their target classes by generating proxy classes.
*
* In general, the command typo3.flow:core:compile is responsible for compilation
* and calls this method to do so.
*
* In order to distinguish between an emerged / changed possible target class and
* a class which has been matched previously but just didn't have to be proxied,
* the latter are kept track of by an "unproxiedClass-*" cache entry.
*
* @return void
*/
public function build()
{
$allAvailableClassNamesByPackage = $this->objectManager->getRegisteredClassNames();
$possibleTargetClassNames = $this->getProxyableClasses($allAvailableClassNamesByPackage);
$actualAspectClassNames = $this->reflectionService->getClassNamesByAnnotation('TYPO3\\Flow\\Annotations\\Aspect');
sort($possibleTargetClassNames);
sort($actualAspectClassNames);
$this->aspectContainers = $this->buildAspectContainers($actualAspectClassNames);
$rebuildEverything = FALSE;
if ($this->objectConfigurationCache->has('allAspectClassesUpToDate') === FALSE) {
$rebuildEverything = TRUE;
$this->systemLogger->log('Aspects have been modified, therefore rebuilding all target classes.', LOG_INFO);
$this->objectConfigurationCache->set('allAspectClassesUpToDate', TRUE);
}
$possibleTargetClassNameIndex = new ClassNameIndex();
$possibleTargetClassNameIndex->setClassNames($possibleTargetClassNames);
$targetClassNameCandidates = new ClassNameIndex();
foreach ($this->aspectContainers as $aspectContainer) {
$targetClassNameCandidates->applyUnion($aspectContainer->reduceTargetClassNames($possibleTargetClassNameIndex));
}
$targetClassNameCandidates->sort();
foreach ($targetClassNameCandidates->getClassNames() as $targetClassName) {
$isUnproxied = $this->objectConfigurationCache->has('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
$hasCacheEntry = $this->compiler->hasCacheEntryForClass($targetClassName) || $isUnproxied;
if ($rebuildEverything === TRUE || $hasCacheEntry === FALSE) {
$proxyBuildResult = $this->buildProxyClass($targetClassName, $this->aspectContainers);
if ($proxyBuildResult !== FALSE) {
if ($isUnproxied) {
$this->objectConfigurationCache->remove('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
}
$this->systemLogger->log(sprintf('Built AOP proxy for class "%s".', $targetClassName), LOG_DEBUG);
} else {
$this->objectConfigurationCache->set('unproxiedClass-' . str_replace('\\', '_', $targetClassName), TRUE);
}
}
}
}
示例7: getModelNames
/**
* @return array
*/
protected function getModelNames()
{
return $this->reflectionService->getClassNamesByAnnotation('TYPO3\\Flow\\Annotations\\Entity');
}