Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php
public function parse(\ReflectionClass $class)
    {
        $classPath = dirname($class->getFileName());
        $inPaths = false;

        foreach ($this->paths as $key => $_path) {
            //Check the entity path is in watching paths
            if (strpos($classPath, realpath($_path)) === 0) {
                $inPaths = true;
            }
        }

        if ($inPaths) {
            $classAnnotations = $this->reader->getClassAnnotations($class);

            if (!empty($classAnnotations)) {
                foreach ($classAnnotations as $key => $annot) {
                    if (!is_numeric($key)) {
                        continue;
                    }

                    $classAnnotations[get_class($annot)] = $annot;
                }
            }

            // Evaluate Entity annotation
            if (isset($classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'])) {
                /** @var BusinessEntity $annotationObj */
                $annotationObj = $classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'];
                $businessEntity = BusinessEntityHelper::createBusinessEntity(
                    $class->getName(),
                    $this->loadBusinessProperties($class)
                );

                $event = new BusinessEntityAnnotationEvent(
                    $businessEntity,
                    $annotationObj->getWidgets()
                );

                //do what you want (caching BusinessEntity...)
                $this->eventDispatcher->dispatch('victoire.business_entity_annotation_load', $event);
            }

            //check if the entity is a widget (extends (in depth) widget class)
            $parentClass = $class->getParentClass();
            $isWidget = false;
            while ($parentClass && ($parentClass = $parentClass->getParentClass()) && !$isWidget && $parentClass->name != null) {
                $isWidget = $parentClass->name === 'Victoire\\Bundle\\WidgetBundle\\Model\\Widget';
            }

            if ($isWidget) {
                if ($this->widgetHelper->isEnabled(new $class->name())) {
                    $event = new WidgetAnnotationEvent(
                        $this->widgetHelper->getWidgetName(new $class->name()),
                        $this->loadReceiverProperties($class)
                    );

                    //dispatch victoire.widget_annotation_load to save receiverProperties in cache
                    $this->eventDispatcher->dispatch('victoire.widget_annotation_load', $event);
                } else {
                    error_log(sprintf('Widget name not found for widget %s. Is this widget declared in AppKernel ?', $class->name));
                }
            }
        }
    }
public function parse(\ReflectionClass $class)
    {
        $classPath = dirname($class->getFileName());
        $inPaths = false;

        foreach ($this->paths as $key => $_path) {
            //Check the entity path is in watching paths
            if (strpos($classPath, realpath($_path)) === 0) {
                $inPaths = true;
            }
        }

        if ($inPaths) {
            $classAnnotations = $this->reader->getClassAnnotations($class);

            if (!empty($classAnnotations)) {
                foreach ($classAnnotations as $key => $annot) {
                    if (!is_numeric($key)) {
                        continue;
                    }

                    $classAnnotations[get_class($annot)] = $annot;
                }
            }

            // Evaluate Entity annotation
            if (isset($classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'])) {
                /** @var BusinessEntity $annotationObj */
                $annotationObj = $classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'];
                $businessEntity = BusinessEntityHelper::createBusinessEntity(
                    $class->getName(),
                    $this->loadBusinessProperties($class)
                );

                $event = new BusinessEntityAnnotationEvent(
                    $businessEntity,
                    $annotationObj->getWidgets()
                );

                //do what you want (caching BusinessEntity...)
                $this->eventDispatcher->dispatch('victoire.business_entity_annotation_load', $event);
            }

            //check if the entity is a widget (extends (in depth) widget class)
            $parentClass = $class->getParentClass();
            $isWidget = false;
            while ($parentClass && ($parentClass = $parentClass->getParentClass()) && !$isWidget && $parentClass->name != null) {
                $isWidget = $parentClass->name === 'Victoire\\Bundle\\WidgetBundle\\Model\\Widget';
            }

            if ($isWidget) {
                if ($this->widgetHelper->isEnabled(new $class->name())) {
                    $event = new WidgetAnnotationEvent(
                        $this->widgetHelper->getWidgetName(new $class->name()),
                        $this->loadReceiverProperties($class)
                    );

                    //dispatch victoire.widget_annotation_load to save receiverProperties in cache
                    $this->eventDispatcher->dispatch('victoire.widget_annotation_load', $event);
                } else {
                    error_log(sprintf('Widget name not found for widget %s. Is this widget declared in AppKernel ?', $class->name));
                }
            }
        }
    }
public function parse ( \ ReflectionClass $ class ) { $ classPath = dirname ( $ class -> getFileName ( ) ) ; $ inPaths = false ; foreach ( $ this -> paths as $ key => $ _path ) { //Check the entity path is in watching paths if ( strpos ( $ classPath , realpath ( $ _path ) ) === 0 ) { $ inPaths = true ; } } if ( $ inPaths ) { $ classAnnotations = $ this -> reader -> getClassAnnotations ( $ class ) ; if ( ! empty ( $ classAnnotations ) ) { foreach ( $ classAnnotations as $ key => $ annot ) { if ( ! is_numeric ( $ key ) ) { continue ; } $ classAnnotations [ get_class ( $ annot ) ] = $ annot ; } } // Evaluate Entity annotation if ( isset ( $ classAnnotations [ 'Victoire\Bundle\CoreBundle\Annotations\BusinessEntity' ] ) ) { /** @var BusinessEntity $annotationObj */ $ annotationObj = $ classAnnotations [ 'Victoire\Bundle\CoreBundle\Annotations\BusinessEntity' ] ; $ businessEntity = BusinessEntityHelper :: createBusinessEntity ( $ class -> getName ( ) , $ this -> loadBusinessProperties ( $ class ) ) ; $ event = new BusinessEntityAnnotationEvent ( $ businessEntity , $ annotationObj -> getWidgets ( ) ) ; //do what you want (caching BusinessEntity...) $ this -> eventDispatcher -> dispatch ( 'victoire.business_entity_annotation_load' , $ event ) ; } //check if the entity is a widget (extends (in depth) widget class) $ parentClass = $ class -> getParentClass ( ) ; $ isWidget = false ; while ( $ parentClass && ( $ parentClass = $ parentClass -> getParentClass ( ) ) && ! $ isWidget && $ parentClass -> name != null ) { $ isWidget = $ parentClass -> name === 'Victoire\\Bundle\\WidgetBundle\\Model\\Widget' ; } if ( $ isWidget ) { if ( $ this -> widgetHelper -> isEnabled ( new $ class -> name ( ) ) ) { $ event = new WidgetAnnotationEvent ( $ this -> widgetHelper -> getWidgetName ( new $ class -> name ( ) ) , $ this -> loadReceiverProperties ( $ class ) ) ; //dispatch victoire.widget_annotation_load to save receiverProperties in cache $ this -> eventDispatcher -> dispatch ( 'victoire.widget_annotation_load' , $ event ) ; } else { error_log ( sprintf ( 'Widget name not found for widget %s. Is this widget declared in AppKernel ?' , $ class -> name ) ) ; } } } }
Parse the given Class to find some annotations related to BusinessEntities.
Parse the given Class to find some annotations related to BusinessEntities .