Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function setServiceContainer(IMetaModelsServiceContainer $serviceContainer)
 {
     $this->serviceContainer = $serviceContainer;
     $this->typeFactories = array();
     $this->serviceContainer->getEventDispatcher()->dispatch(MetaModelsEvents::FILTER_SETTING_FACTORY_CREATE, new CreateFilterSettingFactoryEvent($this));
     return $this;
 }
Esempio n. 2
0
File: Boot.php Progetto: zonky2/core
 /**
  * Register the loadDataContainer HOOK for the given table name to create the DcGeneral etc.
  *
  * @param string                      $tableName The name of the table to be loaded.
  *
  * @param IMetaModelsServiceContainer $container The MetaModels service container.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 private function attachLoadDataContainerHook($tableName, $container)
 {
     LoadDataContainerHookListener::attachFor($tableName, function ($tableName) use($container) {
         $dispatcher = $container->getEventDispatcher();
         $event = new LoadDataContainerEvent('tl_metamodel_item');
         $dispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('tl_metamodel_item'));
         $dispatcher->dispatch(ContaoEvents::CONTROLLER_LOAD_DATA_CONTAINER, $event);
         if (!isset($GLOBALS['TL_DCA'][$tableName])) {
             $GLOBALS['TL_DCA'][$tableName] = array();
         }
         $GLOBALS['TL_DCA'][$tableName] = array_replace_recursive((array) $GLOBALS['TL_DCA']['tl_metamodel_item'], (array) $GLOBALS['TL_DCA'][$tableName]);
     });
 }
Esempio n. 3
0
 /**
  * Create a new instance.
  *
  * @param IMetaModelsServiceContainer $serviceContainer The MetaModel service container.
  */
 public function __construct(IMetaModelsServiceContainer $serviceContainer)
 {
     $this->serviceContainer = $serviceContainer;
     $this->dispatcher = $serviceContainer->getEventDispatcher();
     $this->database = $serviceContainer->getDatabase();
 }
Esempio n. 4
0
 /**
  * Set the service container.
  *
  * @param IMetaModelsServiceContainer $serviceContainer The service container to use.
  *
  * @return RenderSettingFactory
  */
 public function setServiceContainer(IMetaModelsServiceContainer $serviceContainer)
 {
     $this->serviceContainer = $serviceContainer;
     $this->serviceContainer->getEventDispatcher()->dispatch(MetaModelsEvents::RENDER_SETTING_FACTORY_CREATE, new CreateRenderSettingFactoryEvent($this));
     return $this;
 }
Esempio n. 5
0
 /**
  * Retrieve the event dispatcher from the DIC.
  *
  * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function getDispatcher()
 {
     return $this->container->getEventDispatcher();
 }
Esempio n. 6
0
 /**
  * Parse the defined properties and populate the definition.
  *
  * @param IMetaModelDataDefinition $container The data container.
  *
  * @return void
  */
 protected function parseProperties(IMetaModelDataDefinition $container)
 {
     if ($container->hasPropertiesDefinition()) {
         $definition = $container->getPropertiesDefinition();
     } else {
         $definition = new DefaultPropertiesDefinition();
         $container->setPropertiesDefinition($definition);
     }
     $metaModel = $this->getMetaModel();
     $inputScreen = $this->getInputScreenDetails();
     // If the current metamodels has variants add the varbase and vargroup to the definition.
     if ($metaModel->hasVariants()) {
         $this->buildPropertyFromDca($definition, 'varbase', $inputScreen);
         $this->buildPropertyFromDca($definition, 'vargroup', $inputScreen);
     }
     foreach ($metaModel->getAttributes() as $attribute) {
         $this->buildPropertyFromDca($definition, $attribute->getColName(), $inputScreen);
         $event = new BuildAttributeEvent($metaModel, $attribute, $container, $inputScreen, $this);
         // Trigger BuildAttribute Event.
         $this->serviceContainer->getEventDispatcher()->dispatch($event::NAME, $event);
     }
 }