Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6436 from kuzmany/import-theme-settings-extensions
Allowed file extensions configuration for installed theme
- Loading branch information
Showing
8 changed files
with
203 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
app/bundles/CoreBundle/EventListener/ConfigThemeSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* @copyright 2014 Mautic Contributors. All rights reserved | ||
* @author Mautic | ||
* | ||
* @link http://mautic.org | ||
* | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace Mautic\CoreBundle\EventListener; | ||
|
||
use Mautic\ConfigBundle\ConfigEvents; | ||
use Mautic\ConfigBundle\Event\ConfigBuilderEvent; | ||
|
||
/** | ||
* Class ConfigSubscriber. | ||
*/ | ||
class ConfigThemeSubscriber extends CommonSubscriber | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
ConfigEvents::CONFIG_ON_GENERATE => ['onConfigGenerate', 0], | ||
]; | ||
} | ||
|
||
public function onConfigGenerate(ConfigBuilderEvent $event) | ||
{ | ||
$event->addForm([ | ||
'bundle' => 'CoreBundle', | ||
'formAlias' => 'themeconfig', | ||
'formTheme' => 'MauticCoreBundle:FormTheme\Config', | ||
'parameters' => [ | ||
'theme' => $event->getParametersFromConfig('MauticCoreBundle')['theme'], | ||
'theme_import_allowed_extensions' => $event->getParametersFromConfig('MauticCoreBundle')['theme_import_allowed_extensions'], | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/* | ||
* @copyright 2014 Mautic Contributors. All rights reserved | ||
* @author Mautic | ||
* | ||
* @link http://mautic.org | ||
* | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace Mautic\CoreBundle\Form\Type; | ||
|
||
use Mautic\CoreBundle\Form\DataTransformer\ArrayStringTransformer; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
/** | ||
* Class ConfigType. | ||
*/ | ||
class ConfigThemeType extends AbstractType | ||
{ | ||
/** | ||
* @param FormBuilderInterface $builder | ||
* @param array $options | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder->add( | ||
'theme', | ||
'theme_list', | ||
[ | ||
'label' => 'mautic.core.config.form.theme', | ||
'attr' => [ | ||
'class' => 'form-control', | ||
'tooltip' => 'mautic.page.form.template.help', | ||
], | ||
] | ||
); | ||
$arrayStringTransformer = new ArrayStringTransformer(); | ||
$builder->add( | ||
$builder->create('theme_import_allowed_extensions', 'text', [ | ||
'label' => 'mautic.core.config.form.theme.import.allowed.extensions', | ||
'label_attr' => ['class' => 'control-label'], | ||
'attr' => [ | ||
'class' => 'form-control', | ||
], | ||
'required' => false, | ||
])->addViewTransformer($arrayStringTransformer) | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'themeconfig'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
app/bundles/CoreBundle/Views/FormTheme/Config/_config_themeconfig_widget.html.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* @copyright 2014 Mautic Contributors. All rights reserved | ||
* @author Mautic | ||
* | ||
* @link http://mautic.org | ||
* | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
?> | ||
|
||
<div class="panel panel-primary"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title"><?php echo $view['translator']->trans('mautic.config.tab.themeconfig'); ?></h3> | ||
</div> | ||
<div class="panel-body"> | ||
<?php foreach ($form->children as $name => $f): ?> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<?php echo $view['form']->row($f); ?> | ||
</div> | ||
</div> | ||
<?php endforeach; ?> | ||
</div> | ||
</div> |