Skip to content

Commit

Permalink
Merge f9df139 into 959a3d8
Browse files Browse the repository at this point in the history
  • Loading branch information
alterphp committed Mar 31, 2018
2 parents 959a3d8 + f9df139 commit 6a4cd1d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,35 @@
* Initializes the configuration for all the views of each entity, which is
* needed when some entity relies on the default configuration for some view.
*/
class EmbeddedListSortConfigPass implements ConfigPassInterface
class EmbeddedListViewConfigPass implements ConfigPassInterface
{
private $defaultOpenInNewTabLink;

public function __construct($defaultOpenInNewTabLink)
{
$this->defaultOpenInNewTabLink = $defaultOpenInNewTabLink;
}

public function process(array $backendConfig)
{
$backendConfig = $this->processSortingConfig($backendConfig);
$backendConfig = $this->processOpenInNewTabLinkConfig($backendConfig);

return $backendConfig;
}

/**
* @param array $backendConfig
*
* @return array
*/
private function processOpenInNewTabLinkConfig(array $backendConfig)
{
foreach ($backendConfig['entities'] as $entityName => $entityConfig) {
if (!isset($entityConfig['embeddedList']['open_in_new_tab_link'])) {
$backendConfig['entities'][$entityName]['embeddedList']['open_in_new_tab_link'] = $this->defaultOpenInNewTabLink;
}
}

return $backendConfig;
}
Expand Down
8 changes: 8 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public function getConfigTreeBuilder()
->scalarNode('minimum_role')
->defaultNull()
->end()
->arrayNode('embedded_list')
->addDefaultsIfNotSet()
->children()
->booleanNode('open_in_new_tab_link')
->defaultTrue()
->end()
->end()
->end()
->end()
;

Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/EasyAdminExtensionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter('easy_admin_extension.custom_form_types', $config['custom_form_types']);
$container->setParameter('easy_admin_extension.minimum_role', $config['minimum_role']);
$container->setParameter(
'easy_admin_extension.embedded_list.open_in_new_tab_link',
$config['embedded_list']['open_in_new_tab_link']
);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<!-- Makes it process just before PropertyConfigPass -->
<tag name="easyadmin.config_pass" priority="41"/>
</service>
<service id="alterphp.easyadmin_extension.config_pass.embedded_list_sort" class="AlterPHP\EasyAdminExtensionBundle\Configuration\EmbeddedListSortConfigPass">
<service id="alterphp.easyadmin_extension.config_pass.embedded_list_view" class="AlterPHP\EasyAdminExtensionBundle\Configuration\EmbeddedListViewConfigPass">
<argument>%easy_admin_extension.embedded_list.open_in_new_tab_link%</argument>
<!-- Makes it process just after ViewConfigPass -->
<tag name="easyadmin.config_pass" priority="29"/>
</service>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/views/default/embedded_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
{% endblock table_body %}
</tbody>

{% if _entity_config.embeddedList.open_in_new_tab_link %}
<tfoot>
<tr>
<td colspan="{{ _columns_count }}" class="text-center">
Expand All @@ -110,6 +111,7 @@
</td>
</tr>
</tfoot>
{% endif %}
</table>
</div>

Expand Down

0 comments on commit 6a4cd1d

Please sign in to comment.