Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Decouple from Templating Component, Stage 1 (#517)
Browse files Browse the repository at this point in the history
* Switch all templates references to Twig namespaced syntax

* Switch from templating service to sonata.templating
  • Loading branch information
covex-nn authored and jordisala1991 committed Jan 26, 2018
1 parent 68f43b8 commit eba94a4
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"doctrine/phpcr-bundle": "^1.3 || ^2.0",
"doctrine/phpcr-odm": "^1.4 || ^2.0",
"sonata-project/admin-bundle": "^3.30.1",
"sonata-project/block-bundle": "^3.9",
"sonata-project/block-bundle": "^3.11",
"symfony-cmf/resource-rest-bundle": "^1.0.1",
"symfony-cmf/tree-browser-bundle": "^2.0",
"symfony/config": "^2.8 || ^3.2",
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ On this bundle, you can configure templates and the document tree.
templates:
form:
# Default:
- SonataDoctrinePHPCRAdminBundle:Form:form_admin_fields.html.twig
- "@SonataDoctrinePHPCRAdmin/Form/form_admin_fields.html.twig"
filter:
# Default:
- SonataDoctrinePHPCRAdminBundle:Form:filter_admin_fields.html.twig
- "@SonataDoctrinePHPCRAdmin/Form/filter_admin_fields.html.twig"
types:
list:
# Prototype
name: []
show:
# Prototype
name: []
pager_results: SonataDoctrinePHPCRAdminBundle:Pager:simple_pager_results.html.twig
pager_results: "@SonataDoctrinePHPCRAdmin/Pager/simple_pager_results.html.twig"
document_tree:
# See :doc:`document_tree`.
Expand Down
2 changes: 1 addition & 1 deletion src/Block/TreeBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function configureSettings(OptionsResolver $resolver)
// see https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle/pull/345
$resolver->setDefaults([
'template' => function (Options $options, $value) {
return $value ?: 'SonataDoctrinePHPCRAdminBundle:Block:tree.html.twig';
return $value ?: '@SonataDoctrinePHPCRAdmin/Block/tree.html.twig';
},
'id' => function (Options $options, $value) {
return $value ?: '/';
Expand Down
12 changes: 6 additions & 6 deletions src/Builder/ListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType()));

if (ClassMetadata::MANY_TO_ONE == $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_many_to_one.html.twig');
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_many_to_one.html.twig');
}

if (ClassMetadata::MANY_TO_MANY == $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_many_to_many.html.twig');
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_many_to_many.html.twig');
}

if ('child' == $fieldDescription->getMappingType() || 'parent' == $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_one_to_one.html.twig');
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_one_to_one.html.twig');
}

if ('children' == $fieldDescription->getMappingType() || 'referrers' == $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:list_one_to_many.html.twig');
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_one_to_many.html.twig');
}
}

Expand Down Expand Up @@ -202,7 +202,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
public function buildActionFieldDescription(FieldDescriptionInterface $fieldDescription)
{
if (null === $fieldDescription->getTemplate()) {
$fieldDescription->setTemplate('SonataAdminBundle:CRUD:list__action.html.twig');
$fieldDescription->setTemplate('@SonataAdmin/CRUD/list__action.html.twig');
}

if (null === $fieldDescription->getType()) {
Expand All @@ -221,7 +221,7 @@ public function buildActionFieldDescription(FieldDescriptionInterface $fieldDesc
$actions = $fieldDescription->getOption('actions');
foreach ($actions as $k => $action) {
if (!isset($action['template'])) {
$actions[$k]['template'] = sprintf('SonataAdminBundle:CRUD:list__action_%s.html.twig', $k);
$actions[$k]['template'] = sprintf('@SonataAdmin/CRUD/list__action_%s.html.twig', $k);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Builder/ShowBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType()));

if (ClassMetadata::MANY_TO_ONE == $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:show_many_to_one.html.twig');
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/show_many_to_one.html.twig');
}

if (ClassMetadata::MANY_TO_MANY == $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('SonataAdminBundle:CRUD/Association:show_many_to_many.html.twig');
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/show_many_to_many.html.twig');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/TreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TreeController extends Controller
/**
* @var string
*/
private $template = 'SonataDoctrinePHPCRAdminBundle:Tree:tree.html.twig';
private $template = '@SonataDoctrinePHPCRAdmin/Tree/tree.html.twig';

/**
* @var \PHPCR\SessionInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private function addAssetsToAdminPool(Definition $definition)
private function addFormResources(ContainerBuilder $container)
{
$resources = $container->getParameter('twig.form.resources');
$resources[] = 'SonataDoctrinePHPCRAdminBundle:Form:tree_browser_fields.html.twig';
$resources[] = '@SonataDoctrinePHPCRAdmin/Form/tree_browser_fields.html.twig';

$container->setParameter('twig.form.resources', $resources);
}
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public function getConfigTreeBuilder()
->children()
->arrayNode('form')
->prototype('scalar')->end()
->defaultValue(['SonataDoctrinePHPCRAdminBundle:Form:form_admin_fields.html.twig'])
->defaultValue(['@SonataDoctrinePHPCRAdmin/Form/form_admin_fields.html.twig'])
->end()
->arrayNode('filter')
->prototype('scalar')->end()
->defaultValue(['SonataDoctrinePHPCRAdminBundle:Form:filter_admin_fields.html.twig'])
->defaultValue(['@SonataDoctrinePHPCRAdmin/Form/filter_admin_fields.html.twig'])
->end()
->arrayNode('types')
->children()
Expand All @@ -59,7 +59,7 @@ public function getConfigTreeBuilder()
->end()
->end()
->end()
->scalarNode('pager_results')->defaultValue('SonataDoctrinePHPCRAdminBundle:Pager:simple_pager_results.html.twig')->cannotBeEmpty()->end()
->scalarNode('pager_results')->defaultValue('@SonataDoctrinePHPCRAdmin/Pager/simple_pager_results.html.twig')->cannotBeEmpty()->end()
->end()
->end()
->arrayNode('document_tree')
Expand Down
10 changes: 5 additions & 5 deletions src/DependencyInjection/SonataDoctrinePHPCRAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public function load(array $configs, ContainerBuilder $container)
'templates' => [
'types' => [
'list' => [
'node' => 'SonataDoctrinePHPCRAdminBundle:CRUD:list_node.html.twig',
'node' => '@SonataDoctrinePHPCRAdmin/CRUD/list_node.html.twig',
],
'show' => [
'doctrine_phpcr_many_to_many' => 'SonataAdminBundle:CRUD/Association:show_many_to_many.html.twig',
'doctrine_phpcr_many_to_one' => 'SonataAdminBundle:CRUD/Association:show_many_to_one.html.twig',
'doctrine_phpcr_one_to_many' => 'SonataAdminBundle:CRUD/Association:show_one_to_many.html.twig',
'doctrine_phpcr_one_to_one' => 'SonataAdminBundle:CRUD/Association:show_one_to_one.html.twig',
'doctrine_phpcr_many_to_many' => '@SonataAdmin/CRUD/Association/show_many_to_many.html.twig',
'doctrine_phpcr_many_to_one' => '@SonataAdmin/CRUD/Association/show_many_to_one.html.twig',
'doctrine_phpcr_one_to_many' => '@SonataAdmin/CRUD/Association/show_one_to_many.html.twig',
'doctrine_phpcr_one_to_one' => '@SonataAdmin/CRUD/Association/show_one_to_one.html.twig',
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<service id="sonata_admin_doctrine_phpcr.tree_block" class="Sonata\DoctrinePHPCRAdminBundle\Block\TreeBlockService">
<tag name="sonata.block"/>
<argument>sonata_admin_doctrine_phpcr.tree_block</argument>
<argument type="service" id="templating"/>
<argument type="service" id="sonata.templating"/>
<argument>%sonata_admin_doctrine_phpcr.tree_block.routing_defaults%</argument>
</service>
</services>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/CRUD/list_node.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ file that was distributed with this source code.
#}

{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}
{% extends '@SonataAdmin/CRUD/base_list_field.html.twig' %}

{% block field%}
{%- if value is empty -%}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/CRUD/locales.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ file that was distributed with this source code.
#}

{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}
{% extends '@SonataAdmin/CRUD/base_list_field.html.twig' %}

{% block field %}
<div>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Form/filter_admin_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ file that was distributed with this source code.
#}

{% extends 'SonataAdminBundle:Form:filter_admin_fields.html.twig' %}
{% extends '@SonataAdmin/Form/filter_admin_fields.html.twig' %}
14 changes: 7 additions & 7 deletions src/Resources/views/Form/form_admin_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ file that was distributed with this source code.
#}

{% extends 'SonataAdminBundle:Form:form_admin_fields.html.twig' %}
{% extends '@SonataAdmin/Form/form_admin_fields.html.twig' %}



{# Custom Sonata Admin Extension #}
{% block sonata_admin_phpcr_one_to_one_widget %}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_to_one.html.twig' %}
{% include '@SonataAdmin/CRUD/Association/edit_one_to_one.html.twig' %}
{% endblock %}

{% block sonata_admin_phpcr_many_to_many_widget %}
{% include 'SonataAdminBundle:CRUD/Association:edit_many_to_many.html.twig' %}
{% include '@SonataAdmin/CRUD/Association/edit_many_to_many.html.twig' %}
{% endblock %}

{% block sonata_admin_phpcr_many_to_one_widget %}
{% include 'SonataAdminBundle:CRUD/Association:edit_many_to_one.html.twig' %}
{% include '@SonataAdmin/CRUD/Association/edit_many_to_one.html.twig' %}
{% endblock %}

{% block sonata_admin_phpcr_one_to_many_widget %}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_to_many.html.twig' %}
{% include '@SonataAdmin/CRUD/Association/edit_one_to_many.html.twig' %}
{% endblock %}

{% block sonata_type_model_widget %}
Expand Down Expand Up @@ -131,7 +131,7 @@ file that was distributed with this source code.
</div>
</div>

{% include 'SonataAdminBundle:CRUD/Association:edit_many_script.html.twig' %}
{% include '@SonataAdmin/CRUD/Association/edit_many_script.html.twig' %}
{% endblock %}

{% block sonata_type_admin_widget %}
Expand Down Expand Up @@ -164,7 +164,7 @@ file that was distributed with this source code.
{% endblock %}

{% block doctrine_phpcr_odm_tree_widget %}
{% include 'CmfTreeBrowserBundle:Base:tree.html.twig' %}
{% include '@CmfTreeBrowser/Base/tree.html.twig' %}
<script>
jQuery(function ($) {
{% set routing_default_values = {} %}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Pager/simple_pager_results.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ file that was distributed with this source code.
#}

{% extends 'SonataAdminBundle:Pager:base_results.html.twig' %}
{% extends '@SonataAdmin/Pager/base_results.html.twig' %}

{% block num_results %}
{% if admin.datagrid.pager.lastPage != admin.datagrid.pager.page %}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Tree/tree.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ file that was distributed with this source code.
{% endif %}
{% endfor %}

{% include 'CmfTreeBrowserBundle:Base:tree.html.twig' %}
{% include '@CmfTreeBrowser/Base/tree.html.twig' %}
<script type="text/javascript">
var apiGetTemplate = '{{ path('_cmf_get_resource', {
repositoryName: repository_name,
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Builder/ListBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testAddListActionField()
->addField($list, 'actions', $fieldDescription, $this->admin);

$this->assertSame(
'SonataAdminBundle:CRUD:list__action.html.twig',
'@SonataAdmin/CRUD/list__action.html.twig',
$list->get('foo')->getTemplate(),
'Custom list action field has a default list action template assigned'
);
Expand Down

0 comments on commit eba94a4

Please sign in to comment.