Contao\DcaLoader::load PHP Method

load() public method

Load a set of DCA files
public load ( boolean $blnNoCache = false )
$blnNoCache boolean If true, the cache will be bypassed
    public function load($blnNoCache = false)
    {
        // Return if the data has been loaded already
        if (isset($GLOBALS['loadDataContainer'][$this->strTable]) && !$blnNoCache) {
            return;
        }
        $GLOBALS['loadDataContainer'][$this->strTable] = true;
        // see #6145
        $strCacheDir = \System::getContainer()->getParameter('kernel.cache_dir');
        // Try to load from cache
        if (file_exists($strCacheDir . '/contao/dca/' . $this->strTable . '.php')) {
            include $strCacheDir . '/contao/dca/' . $this->strTable . '.php';
        } else {
            try {
                $files = \System::getContainer()->get('contao.resource_locator')->locate('dca/' . $this->strTable . '.php', null, false);
            } catch (\InvalidArgumentException $e) {
                $files = array();
            }
            foreach ($files as $file) {
                include $file;
            }
        }
        // HOOK: allow to load custom settings
        if (isset($GLOBALS['TL_HOOKS']['loadDataContainer']) && is_array($GLOBALS['TL_HOOKS']['loadDataContainer'])) {
            foreach ($GLOBALS['TL_HOOKS']['loadDataContainer'] as $callback) {
                $this->import($callback[0]);
                $this->{$callback[0]}->{$callback[1]}($this->strTable);
            }
        }
        // Local configuration file
        if (file_exists(TL_ROOT . '/system/config/dcaconfig.php')) {
            @trigger_error('Using the dcaconfig.php file has been deprecated and will no longer work in Contao 5.0. Create one or more DCA files in app/Resources/contao/dca instead.', E_USER_DEPRECATED);
            include TL_ROOT . '/system/config/dcaconfig.php';
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * Load a set of DCA files
  *
  * @param string  $strTable   The table name
  * @param boolean $blnNoCache If true, the cache will be bypassed
  */
 public static function loadDataContainer($strTable, $blnNoCache = false)
 {
     $loader = new \DcaLoader($strTable);
     $loader->load($blnNoCache);
 }