src/yimaTheme/Manager/DefaultListenerAggregate.php
public function onMvcBootstrapLast(MvcEvent $e)
    {
        $this->checkMVC(); // test application startup config to match our need

        /** @var $themeLocator Locator */
        $themeLocator = clone $this->getThemeLocator(); // we have to detach strategies
        // Attain to Base ViewModel to Children Themes Append To ... {
        $themAsViewModel = false;
        while($theme = $themeLocator->getPreparedThemeObject())
        {
            // store attained themes list
            $this->attainedThemes[] = $theme;

            $this->pathStacks[] = $theme->getThemesPath().DIRECTORY_SEPARATOR. $theme->getName();

            // initialize theme bootstrap, also we can know theme final after initialize
            if (!$theme->isInitialized())
                $theme->init();

            if ($theme->isFinalTheme()) {
                $themAsViewModel = spl_object_hash($theme); // use to add children themes to final
                $defTemplate = $e->getViewModel()->getTemplate();
                if (!$theme->getTemplate())
                    $theme->setTemplate($defTemplate); // set default template name

                // set themeObject as ViewModel
                $e->setViewModel($theme);
                break;
            }

            // attain to next template
            $lastStrategy = $themeLocator->getResolverObject()
                ->getLastStrategyFound();
            $themeLocator->getResolverObject()
                ->dettach($lastStrategy); // remove last detector
        }

        /** @var Theme $t */
        foreach($this->attainedThemes as $t) {
            if ($themAsViewModel && spl_object_hash($t) === $themAsViewModel)
                continue; // This is a Final Theme Child will added to

            if ($t->getTemplate())
                // if child theme has a template to render
                $e->getViewModel()->addChild($t, null, true);
        }
        // ... }


        // TODO sometimes we need to render a widget in action, and with current template viewScript file
        $viewTemplatePathStack = $this->sm->get('ViewTemplatePathStack');
        foreach (array_reverse($this->pathStacks) as $path) { // child top and final theme must list last
            $viewTemplatePathStack->addPath($path);
        }
    }
public function onMvcBootstrapLast(MvcEvent $e)
    {
        $this->checkMVC(); // test application startup config to match our need

        /** @var $themeLocator Locator */
        $themeLocator = clone $this->getThemeLocator(); // we have to detach strategies
        // Attain to Base ViewModel to Children Themes Append To ... {
        $themAsViewModel = false;
        while($theme = $themeLocator->getPreparedThemeObject())
        {
            // store attained themes list
            $this->attainedThemes[] = $theme;

            $this->pathStacks[] = $theme->getThemesPath().DIRECTORY_SEPARATOR. $theme->getName();

            // initialize theme bootstrap, also we can know theme final after initialize
            if (!$theme->isInitialized())
                $theme->init();

            if ($theme->isFinalTheme()) {
                $themAsViewModel = spl_object_hash($theme); // use to add children themes to final
                $defTemplate = $e->getViewModel()->getTemplate();
                if (!$theme->getTemplate())
                    $theme->setTemplate($defTemplate); // set default template name

                // set themeObject as ViewModel
                $e->setViewModel($theme);
                break;
            }

            // attain to next template
            $lastStrategy = $themeLocator->getResolverObject()
                ->getLastStrategyFound();
            $themeLocator->getResolverObject()
                ->dettach($lastStrategy); // remove last detector
        }

        /** @var Theme $t */
        foreach($this->attainedThemes as $t) {
            if ($themAsViewModel && spl_object_hash($t) === $themAsViewModel)
                continue; // This is a Final Theme Child will added to

            if ($t->getTemplate())
                // if child theme has a template to render
                $e->getViewModel()->addChild($t, null, true);
        }
        // ... }


        // TODO sometimes we need to render a widget in action, and with current template viewScript file
        $viewTemplatePathStack = $this->sm->get('ViewTemplatePathStack');
        foreach (array_reverse($this->pathStacks) as $path) { // child top and final theme must list last
            $viewTemplatePathStack->addPath($path);
        }
    }
public function onMvcBootstrapLast ( MvcEvent $ e ) { $ this -> checkMVC ( ) ; // test application startup config to match our need /** @var $themeLocator Locator */ $ themeLocator = clone $ this -> getThemeLocator ( ) ; // we have to detach strategies // Attain to Base ViewModel to Children Themes Append To ... { $ themAsViewModel = false ; while ( $ theme = $ themeLocator -> getPreparedThemeObject ( ) ) { // store attained themes list $ this -> attainedThemes [ ] = $ theme ; $ this -> pathStacks [ ] = $ theme -> getThemesPath ( ) . DIRECTORY_SEPARATOR . $ theme -> getName ( ) ; // initialize theme bootstrap, also we can know theme final after initialize if ( ! $ theme -> isInitialized ( ) ) $ theme -> init ( ) ; if ( $ theme -> isFinalTheme ( ) ) { $ themAsViewModel = spl_object_hash ( $ theme ) ; // use to add children themes to final $ defTemplate = $ e -> getViewModel ( ) -> getTemplate ( ) ; if ( ! $ theme -> getTemplate ( ) ) $ theme -> setTemplate ( $ defTemplate ) ; // set default template name // set themeObject as ViewModel $ e -> setViewModel ( $ theme ) ; break ; } // attain to next template $ lastStrategy = $ themeLocator -> getResolverObject ( ) -> getLastStrategyFound ( ) ; $ themeLocator -> getResolverObject ( ) -> dettach ( $ lastStrategy ) ; // remove last detector } /** @var Theme $t */ foreach ( $ this -> attainedThemes as $ t ) { if ( $ themAsViewModel && spl_object_hash ( $ t ) === $ themAsViewModel ) continue ; // This is a Final Theme Child will added to if ( $ t -> getTemplate ( ) ) // if child theme has a template to render $ e -> getViewModel ( ) -> addChild ( $ t , null , true ) ; } // ... } // TODO sometimes we need to render a widget in action, and with current template viewScript file $ viewTemplatePathStack = $ this -> sm -> get ( 'ViewTemplatePathStack' ) ; foreach ( array_reverse ( $ this -> pathStacks ) as $ path ) { // child top and final theme must list last $ viewTemplatePathStack -> addPath ( $ path ) ; } }
MVC Event Listener

- get Theme From Locator
- initialize theme if not
- set theme template to default viewModel template name
if not exists
- set Resolved Theme to Event as ViewModel

@param MvcEvent $e
MVC Event Listener