Skip to content

Commit

Permalink
Adding support for config files from vendor bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
doishub committed Jan 24, 2020
1 parent 3a37710 commit 6c7ac64
Showing 1 changed file with 48 additions and 26 deletions.
74 changes: 48 additions & 26 deletions src/Resources/contao/drivers/DC_Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Contao;

use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;

/**
Expand Down Expand Up @@ -98,41 +99,45 @@ public function __construct($strTable)
}
}

/**
* Automatically switch to edit mode
*
* @return string
*/
/**
* Automatically switch to edit mode
*
* @return string
* @throws \Exception
*/
public function create()
{
return $this->edit();
}

/**
* Automatically switch to edit mode
*
* @return string
*/
/**
* Automatically switch to edit mode
*
* @return string
* @throws \Exception
*/
public function cut()
{
return $this->edit();
}

/**
* Automatically switch to edit mode
*
* @return string
*/
/**
* Automatically switch to edit mode
*
* @return string
* @throws \Exception
*/
public function copy()
{
return $this->edit();
}

/**
* Automatically switch to edit mode
*
* @return string
*/
/**
* Automatically switch to edit mode
*
* @return string
* @throws \Exception
*/
public function move()
{
return $this->edit();
Expand All @@ -145,7 +150,23 @@ public function move()
*/
private function generateDcaFieldsFromConfig()
{
$strFilePath = TL_ROOT . '/templates/' . $GLOBALS['TL_DCA'][$this->strTable]['config']['configFile'] . '.php';
// search config file
$strFile = $GLOBALS['TL_DCA'][$this->strTable]['config']['configFile'] . '.php';
$strFilePath = TL_ROOT . '/templates/' . $strFile;

if(!file_exists($strFilePath))
{
try
{
// Search for the template if it is not in the lookup array (last match wins)
foreach (\System::getContainer()->get('contao.resource_finder')->findIn('templates')->name($strFile) as $file)
{
/** @var SplFileInfo $file */
$strFilePath = $file->getPathname();
}
}
catch (\InvalidArgumentException $e){}
}

if(!file_exists($strFilePath))
{
Expand All @@ -170,11 +191,12 @@ private function generateDcaFieldsFromConfig()
return true;
}

/**
* Auto-generate a form to edit the local configuration file
*
* @return string
*/
/**
* Auto-generate a form to edit the local configuration file
*
* @return string
* @throws \Exception
*/
public function edit()
{
$return = '';
Expand Down

0 comments on commit 6c7ac64

Please sign in to comment.