public function updateFileTreeFields()
	{
		$processed = array();
		$arrFields = array();

		/** @var SplFileInfo[] $files */
		$files = System::getContainer()->get('contao.resource_finder')->findIn('dca')->depth(0)->files()->name('*.php');

		foreach ($files as $file)
		{
			if (\in_array($file->getBasename(), $processed))
			{
				continue;
			}

			$strTable = $file->getBasename('.php');

			try
			{
				$this->loadDataContainer($strTable);
			}
			catch (\Exception $e)
			{
				continue;
			}

			// Make sure the table exists (see #8304)
			if (!$this->Database->tableExists($strTable, null, true))
			{
				continue;
			}

			$arrConfig = &$GLOBALS['TL_DCA'][$strTable]['config'];

			// Skip non-database DCAs
			if ($arrConfig['dataContainer'] == 'File')
			{
				continue;
			}
			if ($arrConfig['dataContainer'] == 'Folder' && !$arrConfig['databaseAssisted'])
			{
				continue;
			}

			// Make sure there are fields (see #6437)
			if (\is_array($GLOBALS['TL_DCA'][$strTable]['fields']))
			{
				foreach ($GLOBALS['TL_DCA'][$strTable]['fields'] as $strField=>$arrField)
				{
					if ($arrField['inputType'] == 'fileTree')
					{
						if ($this->Database->fieldExists($strField, $strTable, true))
						{
							$key = $arrField['eval']['multiple'] ? 'multiple' : 'single';
							$arrFields[$key][] = $strTable . '.' . $strField;
						}

						// Convert the order fields as well
						if (isset($arrField['eval']['orderField']) && isset($GLOBALS['TL_DCA'][$strTable]['fields'][$arrField['eval']['orderField']]))
						{
							if ($this->Database->fieldExists($arrField['eval']['orderField'], $strTable, true))
							{
								$arrFields['order'][] = $strTable . '.' . $arrField['eval']['orderField'];
							}
						}
					}
				}
			}
		}

		// Update the existing singleSRC entries
		if (isset($arrFields['single']))
		{
			foreach ($arrFields['single'] as $val)
			{
				list($table, $field) = explode('.', $val);
				static::convertSingleField($table, $field);
			}
		}

		// Update the existing multiSRC entries
		if (isset($arrFields['multiple']))
		{
			foreach ($arrFields['multiple'] as $val)
			{
				list($table, $field) = explode('.', $val);
				static::convertMultiField($table, $field);
			}
		}

		// Update the existing orderField entries
		if (isset($arrFields['order']))
		{
			foreach ($arrFields['order'] as $val)
			{
				list($table, $field) = explode('.', $val);
				static::convertOrderField($table, $field);
			}
		}
	}
public function updateFileTreeFields()
	{
		$processed = array();
		$arrFields = array();

		
		$files = System::getContainer()->get('contao.resource_finder')->findIn('dca')->depth(0)->files()->name('*.php');

		foreach ($files as $file)
		{
			if (\in_array($file->getBasename(), $processed))
			{
				continue;
			}

			$strTable = $file->getBasename('.php');

			try
			{
				$this->loadDataContainer($strTable);
			}
			catch (\Exception $e)
			{
				continue;
			}

			
			if (!$this->Database->tableExists($strTable, null, true))
			{
				continue;
			}

			$arrConfig = &$GLOBALS['TL_DCA'][$strTable]['config'];

			
			if ($arrConfig['dataContainer'] == 'File')
			{
				continue;
			}
			if ($arrConfig['dataContainer'] == 'Folder' && !$arrConfig['databaseAssisted'])
			{
				continue;
			}

			
			if (\is_array($GLOBALS['TL_DCA'][$strTable]['fields']))
			{
				foreach ($GLOBALS['TL_DCA'][$strTable]['fields'] as $strField=>$arrField)
				{
					if ($arrField['inputType'] == 'fileTree')
					{
						if ($this->Database->fieldExists($strField, $strTable, true))
						{
							$key = $arrField['eval']['multiple'] ? 'multiple' : 'single';
							$arrFields[$key][] = $strTable . '.' . $strField;
						}

						
						if (isset($arrField['eval']['orderField']) && isset($GLOBALS['TL_DCA'][$strTable]['fields'][$arrField['eval']['orderField']]))
						{
							if ($this->Database->fieldExists($arrField['eval']['orderField'], $strTable, true))
							{
								$arrFields['order'][] = $strTable . '.' . $arrField['eval']['orderField'];
							}
						}
					}
				}
			}
		}

		
		if (isset($arrFields['single']))
		{
			foreach ($arrFields['single'] as $val)
			{
				list($table, $field) = explode('.', $val);
				static::convertSingleField($table, $field);
			}
		}

		
		if (isset($arrFields['multiple']))
		{
			foreach ($arrFields['multiple'] as $val)
			{
				list($table, $field) = explode('.', $val);
				static::convertMultiField($table, $field);
			}
		}

		
		if (isset($arrFields['order']))
		{
			foreach ($arrFields['order'] as $val)
			{
				list($table, $field) = explode('.', $val);
				static::convertOrderField($table, $field);
			}
		}
	}
public function updateFileTreeFields ( ) { $ processed = array ( ) ; $ arrFields = array ( ) ; /** @var SplFileInfo[] $files */ $ files = System :: getContainer ( ) -> get ( 'contao.resource_finder' ) -> findIn ( 'dca' ) -> depth ( 0 ) -> files ( ) -> name ( '*.php' ) ; foreach ( $ files as $ file ) { if ( \ in_array ( $ file -> getBasename ( ) , $ processed ) ) { continue ; } $ strTable = $ file -> getBasename ( '.php' ) ; try { $ this -> loadDataContainer ( $ strTable ) ; } catch ( \ Exception $ e ) { continue ; } // Make sure the table exists (see #8304) if ( ! $ this -> Database -> tableExists ( $ strTable , null , true ) ) { continue ; } $ arrConfig = & $ GLOBALS [ 'TL_DCA' ] [ $ strTable ] [ 'config' ] ; // Skip non-database DCAs if ( $ arrConfig [ 'dataContainer' ] == 'File' ) { continue ; } if ( $ arrConfig [ 'dataContainer' ] == 'Folder' && ! $ arrConfig [ 'databaseAssisted' ] ) { continue ; } // Make sure there are fields (see #6437) if ( \ is_array ( $ GLOBALS [ 'TL_DCA' ] [ $ strTable ] [ 'fields' ] ) ) { foreach ( $ GLOBALS [ 'TL_DCA' ] [ $ strTable ] [ 'fields' ] as $ strField => $ arrField ) { if ( $ arrField [ 'inputType' ] == 'fileTree' ) { if ( $ this -> Database -> fieldExists ( $ strField , $ strTable , true ) ) { $ key = $ arrField [ 'eval' ] [ 'multiple' ] ? 'multiple' : 'single' ; $ arrFields [ $ key ] [ ] = $ strTable . '.' . $ strField ; } // Convert the order fields as well if ( isset ( $ arrField [ 'eval' ] [ 'orderField' ] ) && isset ( $ GLOBALS [ 'TL_DCA' ] [ $ strTable ] [ 'fields' ] [ $ arrField [ 'eval' ] [ 'orderField' ] ] ) ) { if ( $ this -> Database -> fieldExists ( $ arrField [ 'eval' ] [ 'orderField' ] , $ strTable , true ) ) { $ arrFields [ 'order' ] [ ] = $ strTable . '.' . $ arrField [ 'eval' ] [ 'orderField' ] ; } } } } } } // Update the existing singleSRC entries if ( isset ( $ arrFields [ 'single' ] ) ) { foreach ( $ arrFields [ 'single' ] as $ val ) { list ( $ table , $ field ) = explode ( '.' , $ val ) ; static :: convertSingleField ( $ table , $ field ) ; } } // Update the existing multiSRC entries if ( isset ( $ arrFields [ 'multiple' ] ) ) { foreach ( $ arrFields [ 'multiple' ] as $ val ) { list ( $ table , $ field ) = explode ( '.' , $ val ) ; static :: convertMultiField ( $ table , $ field ) ; } } // Update the existing orderField entries if ( isset ( $ arrFields [ 'order' ] ) ) { foreach ( $ arrFields [ 'order' ] as $ val ) { list ( $ table , $ field ) = explode ( '.' , $ val ) ; static :: convertOrderField ( $ table , $ field ) ; } } }
Update all FileTree fields
Update all FileTree fields