protected function generatePointcutPointcut(array $pointcutNames, Aspect $aspect)
{
// there might be several pointcuts
// we have to look them up within the pointcuts we got here and the ones we already have in our register
$pointcutFactory = new PointcutFactory();
$referencedPointcuts = array();
$pointcutExpression = array();
foreach ($pointcutNames as $pointcutName) {
$pointcutName = (string) $pointcutName;
$referenceCount = count($referencedPointcuts);
// check if we recently parsed the referenced pointcut
if ($pointcut = $aspect->getPointcuts()->get($pointcutName)) {
$referencedPointcuts[] = $pointcut;
} else {
// or did we already know of it?
$referencedPointcuts = array_merge($referencedPointcuts, $this->getAspectRegister()->lookupPointcuts($pointcutName));
}
// build up the expression string for the PointcutPointcut instance
if ($referenceCount < count($referencedPointcuts)) {
$pointcutExpression[] = $pointcutName;
}
}
/** @var \AppserverIo\Doppelgaenger\Entities\Pointcuts\PointcutPointcut $pointcutPointcut */
$pointcutPointcut = $pointcutFactory->getInstance(PointcutPointcut::TYPE . '(' . implode(PointcutPointcut::EXPRESSION_CONNECTOR, $pointcutExpression) . ')');
$pointcutPointcut->setReferencedPointcuts($referencedPointcuts);
return $pointcutPointcut;
}