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

Commit

Permalink
Merge bb453a1 into 81cc0d1
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricMaxxx committed Jun 29, 2018
2 parents 81cc0d1 + bb453a1 commit 90d3558
Show file tree
Hide file tree
Showing 32 changed files with 150 additions and 112 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Expand Up @@ -2,7 +2,8 @@
/docs/_build
/vendor
.php_cs.cache
.phpunit
composer.lock
phpunit.xml
tests/Resources/app/cache/
tests/Resources/app/logs/
tests/Fixtures/App/var/cache/
tests/Fixtures/App/var/logs/
2 changes: 2 additions & 0 deletions .travis/before_script_test.sh 100644 → 100755
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
set -ev

vendor/symfony-cmf/testing/bin/console doctrine:phpcr:init:dbal --drop --force
vendor/symfony-cmf/testing/bin/console doctrine:phpcr:repository:init
26 changes: 15 additions & 11 deletions composer.json
Expand Up @@ -23,19 +23,19 @@
"require": {
"php": "^5.6 || ^7.0",
"doctrine/phpcr-bundle": "^1.3 || ^2.0",
"doctrine/phpcr-odm": "^1.4 || ^2.0",
"doctrine/phpcr-odm": "^1.4",
"sonata-project/admin-bundle": "^3.30.1",
"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",
"symfony/dependency-injection": "^2.8 || ^3.2",
"symfony/form": "^2.8 || ^3.2",
"symfony/framework-bundle": "^2.8 || ^3.2",
"symfony/http-foundation": "^2.8 || ^3.2",
"symfony/http-kernel": "^2.8 || ^3.2",
"symfony/options-resolver": "^2.8 || ^3.2",
"symfony/property-access": "^2.8 || ^3.2"
"symfony/config": "^2.8 || ^3.2 || ^4.0",
"symfony/dependency-injection": "^2.8 || ^3.2 || ^4.0",
"symfony/form": "^2.8 || ^3.2 || ^4.0",
"symfony/framework-bundle": "^2.8 || ^3.2 || ^4.0",
"symfony/http-foundation": "^2.8 || ^3.2 || ^4.0",
"symfony/http-kernel": "^2.8 || ^3.2 || ^4.0",
"symfony/options-resolver": "^2.8 || ^3.2 || ^4.0",
"symfony/property-access": "^2.8 || ^3.2 || ^4.0"
},
"provide": {
"sonata-project/admin-bundle-persistency-layer": "1.0.0"
Expand All @@ -47,9 +47,9 @@
"sonata-project/core-bundle": "^3.8",
"symfony-cmf/resource": "^1.0",
"symfony-cmf/resource-bundle": "^1.0",
"symfony-cmf/testing": "^2.0.1",
"symfony-cmf/testing": "2.1.x-dev",
"symfony/phpunit-bridge": "^4.0",
"symfony/routing": "^2.8 || ^3.2",
"symfony/routing": "^2.8 || ^3.2 || ^4.0",
"symfony/security-acl": "^2.8 || ^3.0"
},
"config": {
Expand All @@ -69,5 +69,9 @@
"psr-4": {
"Sonata\\DoctrinePHPCRAdminBundle\\Tests\\": "tests/"
}
},
"conflict": {
"sebastian/environment": "<1.3.4",
"sebastian/exporter": "<2.0.0"
}
}
4 changes: 2 additions & 2 deletions docs/reference/document_tree.rst
Expand Up @@ -220,7 +220,7 @@ like this:
.. code-block:: jinja
{% render(controller(
'sonata.admin.doctrine_phpcr.tree_controller:treeAction',
'sonata.admin.doctrine_phpcr.tree_controller::treeAction',
{
'root': basePath ~ "/menu",
'selected': menuNodeId,
Expand All @@ -231,7 +231,7 @@ like this:
.. code-block:: php
<?php echo $view['actions']->render(new ControllerReference(
'sonata.admin.doctrine_phpcr.tree_controller:treeAction',
'sonata.admin.doctrine_phpcr.tree_controller::treeAction',
array(
'root' => $basePath . '/menu',
'selected' => $menuNodeId,
Expand Down
22 changes: 5 additions & 17 deletions phpunit.xml.dist
Expand Up @@ -11,19 +11,11 @@
syntaxCheck="false"
bootstrap="vendor/symfony-cmf/testing/bootstrap/bootstrap.php"
>
<php>
<server name="KERNEL_DIR" value="tests/Resources/app" />
</php>

<testsuites>
<testsuite name="SonataDoctrinePHPCRAdminBundle Unit Test Suite">
<testsuite name="SonataDoctrinePHPCRAdminBundle Test Suite">
<directory>./tests/Unit</directory>
</testsuite>

<!-- SonataDoctrinePHPCRAdminBundle Integration Test Suite – The name has to be "phpcr" to trigger db listener.-->
<testsuite name="phpcr">
<directory>./tests/WebTest</directory>
<directory>./Tests</directory>
</testsuite>
</testsuites>

Expand All @@ -33,20 +25,16 @@
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
<directory>./Resources</directory>
<directory>./DependencyInjection</directory>
<file>./SonataDoctrinePHPCRAdminBundle.php</file>
<directory>./src/Resources</directory>
<directory>./src/DependencyInjection</directory>
<file>./src/SonataDoctrinePHPCRAdminBundle.php</file>
<directory>./coverage/</directory>
</exclude>
</whitelist>
</filter>

<listeners>
<listener class="Symfony\Cmf\Component\Testing\Phpunit\DatabaseTestListener" />
</listeners>

<php>
<ini name="precision" value="8"/>
<env name="KERNEL_CLASS" value="Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Kernel" />
</php>

</phpunit>
4 changes: 2 additions & 2 deletions src/Block/TreeBlockService.php
Expand Up @@ -12,15 +12,15 @@
namespace Sonata\DoctrinePHPCRAdminBundle\Block;

use Sonata\AdminBundle\Form\FormMapper;
use Sonata\BlockBundle\Block\BaseBlockService;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
use Sonata\BlockBundle\Model\BlockInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TreeBlockService extends BaseBlockService
class TreeBlockService extends AbstractBlockService
{
/**
* @var array
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/DatagridBuilder.php
Expand Up @@ -101,7 +101,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
if (isset($metadata->mappings[$fieldDescription->getName()])) {
$fieldDescription->setFieldMapping($metadata->mappings[$fieldDescription->getName()]);

if ($metadata->mappings[$fieldDescription->getName()]['type'] == 'string') {
if ('string' == $metadata->mappings[$fieldDescription->getName()]['type']) {
$fieldDescription->setOption('global_search', $fieldDescription->getOption('global_search', true)); // always search on string field only
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Builder/ListBuilder.php
Expand Up @@ -17,6 +17,7 @@
use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
use Sonata\AdminBundle\Builder\ListBuilderInterface;
use Sonata\AdminBundle\Guesser\TypeGuesserInterface;
use Symfony\Component\Form\Guess\TypeGuess;

class ListBuilder implements ListBuilderInterface
{
Expand Down Expand Up @@ -55,7 +56,7 @@ public function buildField($type, FieldDescriptionInterface $fieldDescription, A
{
if (null == $type) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
$fieldDescription->setType($guessType->getType());
$fieldDescription->setType(($guessType instanceof TypeGuess ? $guessType->getType() : null));
} else {
$fieldDescription->setType($type);
}
Expand Down
Expand Up @@ -27,7 +27,7 @@ public function process(ContainerBuilder $container)
{
$settings = $this->fixSettings($container);
foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
if (!isset($attributes[0]['manager_type']) || $attributes[0]['manager_type'] != 'doctrine_phpcr') {
if (!isset($attributes[0]['manager_type']) || 'doctrine_phpcr' != $attributes[0]['manager_type']) {
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Form/Type/ChoiceFieldMaskType.php
Expand Up @@ -12,6 +12,7 @@
namespace Sonata\DoctrinePHPCRAdminBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return 'choice';
return ChoiceType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/doctrine_phpcr_form_types.xml
Expand Up @@ -10,7 +10,7 @@
<service id="sonata.admin.doctrine_phpcr.form.type.phpcr_odm_tree_manager" class="Sonata\DoctrinePHPCRAdminBundle\Form\Type\TreeManagerType">
<tag name="form.type" alias="doctrine_phpcr_odm_tree_manager"/>
</service>
<service id="sonata.admin.doctrine_phpcr.form.collection_type_extension" class="Sonata\DoctrinePHPCRAdminBundle\Form\Extension\CollectionTypeExtension">
<service id="sonata.admin.doctrine_phpcr.form.collection_type_extension" class="Sonata\DoctrinePHPCRAdminBundle\Form\Extension\CollectionTypeExtension" public="true">
<tag name="form.type_extension" extended-type="Sonata\CoreBundle\Form\Type\CollectionType" alias="sonata_type_collection"/>
</service>
</services>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routing/tree.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="sonata_admin_tree" path="/tree">
<default key="_controller">sonata.admin.doctrine_phpcr.tree_controller:treeAction</default>
<default key="_controller">sonata.admin.doctrine_phpcr.tree_controller::treeAction</default>
</route>
<route id="sonata_admin_tree_reorder" path="/tree/reorder">
<default key="_controller">sonata.admin.doctrine_phpcr.tree_controller:reorderAction</default>
Expand Down
3 changes: 1 addition & 2 deletions src/Resources/config/tree.xml
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sonata.admin.doctrine_phpcr.tree_controller" class="Sonata\DoctrinePHPCRAdminBundle\Controller\TreeController">
<service id="sonata.admin.doctrine_phpcr.tree_controller" class="Sonata\DoctrinePHPCRAdminBundle\Controller\TreeController" public="true">
<argument type="service" id="doctrine_phpcr"/>
<argument>%doctrine_phpcr.default_session%</argument>
<argument>%sonata_admin_doctrine_phpcr.tree_block.configuration%</argument>
<argument>%cmf_resource.repositories.default_name%</argument>
<argument/>
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Admin;
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Admin;

use Doctrine\Bundle\PHPCRBundle\Form\DataTransformer\DocumentToPathTransformer;
use Doctrine\Common\Persistence\ManagerRegistry;
Expand All @@ -18,7 +18,12 @@
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content;
use Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document\Content;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Sonata\CoreBundle\Form\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Sonata\AdminBundle\Form\Type\ModelType;
use Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType;

/**
* @author Maximilian Berghoff <Maximilian.Berghoff@mayflower.de>
Expand Down Expand Up @@ -96,41 +101,43 @@ protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('form.group_general')
->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->add('title', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->add('name', TextType::class)
->add('title', TextType::class)
->add(
'children',
'Sonata\CoreBundle\Form\Type\CollectionType',
CollectionType::class,
['label' => false, 'type_options' => [
'delete' => true,
'delete_options' => [
'type' => 'Symfony\Component\Form\Extension\Core\Type\CheckboxType',
'type' => CheckboxType::class,
'type_options' => ['required' => false, 'mapped' => false],
], ],
],
['edit' => 'inline', 'inline' => 'table', 'admin_code' => 'sonata_admin_doctrine_phpcr.test.admin']
)
->add(
'routes',
'Sonata\AdminBundle\Form\Type\ModelType',
ModelType::class,
['property' => 'title', 'multiple' => true, 'expanded' => false]
)
->add('parentDocument', 'Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType', [
->add('parentDocument',
TreeSelectType::class, [
'widget' => 'browser',
'root_node' => $this->getRootPath(),
])
->add(
'child',
'Sonata\AdminBundle\Form\Type\ModelType',
ModelType::class,
[
'property' => 'title',
'class' => 'Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content',
'class' => Content::class,
'btn_catalogue' => 'List',
'required' => false,
],
['admin_code' => 'sonata_admin_doctrine_phpcr.test.admin']
)
->add('singleRoute', 'Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType', [
->add('singleRoute',
TreeSelectType::class, [
'widget' => 'browser',
'root_node' => $this->getRootPath(),
])
Expand Down
Expand Up @@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/

namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\DataFixtures\Phpcr;
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\DataFixtures\Phpcr;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use PHPCR\Util\NodeHelper;
use Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content;
use Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document\Content;

class LoadTreeData implements FixtureInterface
{
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document;
namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
Expand Down Expand Up @@ -60,14 +60,14 @@ class Content
protected $children;

/**
* @PHPCRODM\ReferenceOne(targetDocument="Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content")
* @PHPCRODM\ReferenceOne(targetDocument="Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document\Content")
*
* @var Content
*/
protected $singleRoute;

/**
* @PHPCRODM\ReferenceMany(targetDocument="Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content")
* @PHPCRODM\ReferenceMany(targetDocument="Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App\Document\Content")
*
* @var ArrayCollection|Content[]
*/
Expand Down
Expand Up @@ -9,30 +9,25 @@
* file that was distributed with this source code.
*/

namespace Sonata\DoctrinePHPCRAdminBundle\Tests\Fixtures\App;

use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends TestKernel
class Kernel extends TestKernel
{
public function configure()
{
$this->registerConfiguredBundles();
$this->requireBundleSet('default');

$this->requireBundleSets([
'phpcr_odm',
'sonata_admin_phpcr',
]);

$this->addBundles([
new Symfony\Cmf\Bundle\ResourceBundle\CmfResourceBundle(),
new Symfony\Cmf\Bundle\ResourceRestBundle\CmfResourceRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
]);
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.php');
$loader->load(__DIR__.'/config/admin-test.xml');
$loader->load(__DIR__ . '/config/config.php');
$loader->load(__DIR__ . '/config/admin-test.xml');
}
}

0 comments on commit 90d3558

Please sign in to comment.