Overview

Namespaces

  • DcGeneral
    • Clipboard
    • Contao
      • Callback
      • Compatibility
      • DataDefinition
        • Definition
      • Dca
        • Builder
          • Legacy
        • Definition
        • Palette
        • Populator
      • Event
      • View
        • Contao2BackendView
          • Event
    • Controller
    • Data
    • DataDefinition
      • Builder
      • Definition
        • Properties
        • View
          • Panel
      • ModelRelationship
      • Palette
        • Builder
          • Event
        • Condition
          • Palette
          • Property
    • EnvironmentPopulator
    • Event
    • Exception
    • Factory
      • Event
    • Panel
    • View
      • Event

Classes

  • DcaReadingDataDefinitionBuilder
  • ExtendedLegacyDcaDataDefinitionBuilder
  • LegacyDcaDataDefinitionBuilder
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: /**
 3:  * PHP version 5
 4:  * @package    generalDriver
 5:  * @author     Christian Schiffler <c.schiffler@cyberspectrum.de>
 6:  * @author     Stefan Heimes <stefan_heimes@hotmail.com>
 7:  * @author     Tristan Lins <tristan.lins@bit3.de>
 8:  * @copyright  The MetaModels team.
 9:  * @license    LGPL.
10:  * @filesource
11:  */
12: 
13: namespace DcGeneral\Contao\Dca\Builder\Legacy;
14: 
15: use ContaoCommunityAlliance\Contao\Bindings\ContaoEvents;
16: use ContaoCommunityAlliance\Contao\Bindings\Events\Controller\LoadDataContainerEvent;
17: use ContaoCommunityAlliance\Contao\Bindings\Events\System\LoadLanguageFileEvent;
18: use DcGeneral\DataDefinition\Builder\AbstractEventDrivenDataDefinitionBuilder;
19: use Symfony\Component\EventDispatcher\EventDispatcherInterface;
20: 
21: /**
22:  * Build the container config from legacy DCA syntax.
23:  */
24: abstract class DcaReadingDataDefinitionBuilder extends AbstractEventDrivenDataDefinitionBuilder
25: {
26:     /**
27:      * Buffer for the DCA.
28:      *
29:      * @var array
30:      */
31:     protected $dca;
32: 
33:     /**
34:      * {@inheritdoc}
35:      */
36:     public function loadDca($dcaName, EventDispatcherInterface $dispatcher)
37:     {
38:         $this->dca         = null;
39:         $previousDca       = isset($GLOBALS['TL_DCA']) ? $GLOBALS['TL_DCA'] : null;
40:         $GLOBALS['TL_DCA'] = array();
41: 
42:         $event = new LoadDataContainerEvent($dcaName, true);
43:         $dispatcher->dispatch(ContaoEvents::CONTROLLER_LOAD_DATA_CONTAINER, $event);
44: 
45:         if (isset($GLOBALS['TL_DCA'][$dcaName]))
46:         {
47:             $this->dca = $GLOBALS['TL_DCA'][$dcaName];
48:         }
49: 
50:         $GLOBALS['TL_DCA'] = $previousDca;
51:         unset($GLOBALS['loadDataContainer'][$dcaName]);
52: 
53:         $event = new LoadLanguageFileEvent($dcaName);
54:         $dispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event);
55: 
56:         return $this->dca !== null;
57:     }
58: 
59:     /**
60:      * Read the specified sub path from the dca.
61:      *
62:      * @param string $path The path from the Dca to read.
63:      *
64:      * @return mixed
65:      *
66:      * @internal
67:      */
68:     protected function getFromDca($path)
69:     {
70:         $chunks = explode('/', trim($path, '/'));
71:         $dca    = $this->dca;
72: 
73:         while (($chunk = array_shift($chunks)) !== null)
74:         {
75:             if (!array_key_exists($chunk, $dca))
76:             {
77:                 return null;
78:             }
79: 
80:             $dca = $dca[$chunk];
81:         }
82: 
83:         return $dca;
84:     }
85: }
86: 
contao-community-alliance/dc-general API documentation generated by ApiGen 2.8.0