Example #1
0
 public function __construct(NavigationInterface $navigation, PlatformSettings $adminSettings, SessionInterface $session)
 {
     parent::__construct();
     $this->navigation = $navigation;
     $this->adminSettings = $adminSettings;
     $this->session = $session;
 }
    protected function init()
    {
        parent::init();
        $this->context->getAssetsService()->addInlineScript(<<<JS
      selenia.on ('languageChanged', function (lang) {
        \$ ('.LanguageSelector li').removeClass ('active');
        \$ ('#btn-' + lang).addClass ('active');
      }).setLang ('{$this->locale->locale()}');
JS
, 'initLanguageSelector');
    }
Example #3
0
 protected function viewModel(ViewModel $viewModel)
 {
     parent::viewModel($viewModel);
     // Import the container's model (if any) to the macro's view model
     $viewModel->model = $this->context->getDataBinder()->getViewModel()->model;
     $this->macroInstance->importServices($viewModel);
 }
Example #4
0
 protected function init()
 {
     parent::init();
     $prop = $this->props;
     // Validate dynamic properties and rename them.
     $extra = $prop->getDynamic();
     if ($extra) {
         foreach ($extra as $k => $v) {
             if ($k[0] != '@') {
                 throw new ComponentException($this, "Invalid property name: <kbd>{$k}</kbd>");
             } else {
                 $o = substr($k, 1);
                 if (isset($prop->{$o})) {
                     throw new ComponentException($this, "Dynamic property <kbd>{$k}</kbd> conflicts with predefined property <kbd>{$o}</kbd>.");
                 }
                 $prop->{$o} = $v;
                 unset($prop->{$k});
             }
         }
     }
 }
 /**
  * Sets a reference to the model on the view model, allowing the view to access the model for redndering.
  */
 protected function afterPreRun()
 {
     parent::afterPreRun();
     $this->getViewModel()->model = $this->model;
 }
 protected function afterRender()
 {
     parent::afterRender();
     //----------------------------------------------------------------------------------------
     // View Model panel
     // (MUST run before the DOM panel to capture the data-binding stack at its current state)
     //----------------------------------------------------------------------------------------
     DebugConsole::registerPanel('view', new ConsoleLogger('View', 'fa fa-eye'));
     $VMFilter = function ($k, $v, $o) {
         if ($v instanceof DocumentContext || $v instanceof Component || $k === 'parent' || $k === 'model') {
             return '...';
         }
         return true;
     };
     $expMap = Expression::$inspectionMap;
     ksort($expMap);
     DebugConsole::logger('view')->withFilter($VMFilter, $this->context)->write('<#section|Compiled expressions>')->inspect($expMap)->write('</#section>');
     //------------
     // Model panel
     //------------
     DebugConsole::registerPanel('model', new ConsoleLogger('Model', 'fa fa-table'));
     $shadowDOM = $this->getShadowDOM();
     if ($shadowDOM) {
         $VMFilter = function ($k, $v, $o) {
             if ($v instanceof KernelSettings || $v instanceof NavigationInterface || $v instanceof NavigationLinkInterface || $v instanceof SessionInterface || $v instanceof ServerRequestInterface || $v instanceof DocumentContext || $v instanceof Component) {
                 return '...';
             }
             return true;
         };
         $binder = $shadowDOM->getDataBinder();
         DebugConsole::logger('model')->write('<#i>PAGE DATA BINDER: ' . Debug::getType($binder) . "</#i>")->write("<#section|PAGE VIEW MODEL>")->withFilter($VMFilter, $binder->getViewModel())->write("</#section>");
     }
     //-----------
     // DOM panel
     //-----------
     if ($this->matisseSettings->inspectDOM()) {
         DebugConsole::registerPanel('DOM', new ConsoleLogger('Server-side DOM', 'fa fa-sitemap'));
         $insp = $this->inspect(true);
         DebugConsole::logger('DOM')->write($insp);
     }
 }