Ejemplo n.º 1
0
 /**
  * Register to the event dispatcher in the provided service container.
  *
  * @param MetaModelsBootEvent $event The event.
  *
  * @return void
  */
 public function handleEvent(MetaModelsBootEvent $event)
 {
     $this->serviceContainer = $event->getServiceContainer();
     $dispatcher = $this->getServiceContainer()->getEventDispatcher();
     $dispatcher->addListener(CollectMetaModelAttributeInformationEvent::NAME, array($this, 'collectMetaModelAttributeInformation'));
     $dispatcher->addListener(CollectMetaModelTableNamesEvent::NAME, array($this, 'collectMetaModelTableNames'));
     $dispatcher->addListener(CreateMetaModelEvent::NAME, array($this, 'createMetaModel'));
     $dispatcher->addListener(GetMetaModelNameFromIdEvent::NAME, array($this, 'getMetaModelNameFromId'));
 }
Ejemplo n.º 2
0
Archivo: Boot.php Proyecto: zonky2/core
 /**
  * Boot the system in the backend.
  *
  * @param MetaModelsBootEvent $event The event.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public function perform(MetaModelsBootEvent $event)
 {
     $container = $event->getServiceContainer();
     $viewCombinations = new ViewCombinations($container, $GLOBALS['container']['user']);
     $container->setService($viewCombinations, 'metamodels-view-combinations');
     $menuBuilder = new BackendModuleBuilder($container, $viewCombinations);
     $menuBuilder->export();
     // Prepare lazy loading of the data containers.
     foreach ($viewCombinations->getParentedInputScreenNames() as $metaModelName) {
         $parent = $viewCombinations->getParentOf($metaModelName);
         if (substr($parent, 0, 3) === 'mm_') {
             continue;
         }
         LoadDataContainerHookListener::attachFor($parent, function () use($metaModelName, $viewCombinations, $container) {
             $inputScreen = $viewCombinations->getInputScreenDetails($metaModelName);
             $builder = new MetaModelDcaBuilder($container);
             $builder->injectOperationButton($inputScreen);
         });
     }
     $dispatcher = $container->getEventDispatcher();
     foreach ($container->getFactory()->collectNames() as $metaModelName) {
         $this->attachLoadDataContainerHook($metaModelName, $container);
         $dispatcher->addListener(PreCreateDcGeneralEvent::NAME, function (PreCreateDcGeneralEvent $event) use($metaModelName, $viewCombinations, $container) {
             $factory = $event->getFactory();
             $name = $factory->getContainerName();
             if ($name !== $metaModelName) {
                 return;
             }
             $inputScreen = $viewCombinations->getInputScreenDetails($metaModelName);
             $factory->setContainerClassName('MetaModels\\DcGeneral\\DataDefinition\\MetaModelDataDefinition');
             $dispatcher = $container->getEventDispatcher();
             $generator = new Builder($container, $inputScreen);
             $dispatcher->addListener(BuildDataDefinitionEvent::NAME, function (BuildDataDefinitionEvent $event) use($metaModelName, $generator) {
                 if ($event->getContainer()->getName() !== $metaModelName) {
                     return;
                 }
                 $generator->build($event);
             }, $generator::PRIORITY);
             $dispatcher->addListener(PopulateEnvironmentEvent::NAME, function (PopulateEnvironmentEvent $event) use($metaModelName, $generator) {
                 if ($event->getEnvironment()->getDataDefinition()->getName() !== $metaModelName) {
                     return;
                 }
                 $generator->populate($event);
                 $GLOBALS['TL_CSS'][] = 'system/modules/metamodels/assets/css/style.css';
             }, $generator::PRIORITY);
         });
     }
     // Register the global subscriber.
     new Subscriber($container);
     $this->overrideFilePicker();
 }