Skip to content
Snippets Groups Projects
Commit 8eca4fe6 authored by jaapjansma's avatar jaapjansma
Browse files

Compatibility fix for Symfony 2.8, 3.4 and 4.0

parent 6e4ba3a0
No related branches found
No related tags found
No related merge requests found
# Version 1.35 (not yet released)
* Fixed #87 Dataprocessors with required contact id filters throws "One of parameters (value: ) is not of the type Int" error for anonymous users by !77
* Compatibility fix for Symfony 2.8, 3.4 and 4.0
# Version 1.34
......
......@@ -6,10 +6,10 @@
namespace Civi\DataProcessor\Source\CompilerPass;
use Civi\DataProcessor\Symfony\Component\DependencyInjection\DefinitionAdapter;
use CRM_Dataprocessor_ExtensionUtil as E;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
class MultipleCustomGroupSource implements CompilerPassInterface {
......@@ -29,8 +29,7 @@ class MultipleCustomGroupSource implements CompilerPassInterface {
'\Civi\DataProcessor\Source\Contact\MultipleCustomGroupSource',
[$dao->name, $dao->title, $dao->table_name],
];
$definition = new Definition('Civi\DataProcessor\Factory\Definition', $arguments);
$definition->setPrivate(FALSE);
$definition = DefinitionAdapter::createDefinitionClass('Civi\DataProcessor\Factory\Definition', $arguments);
$factoryDefinition->addMethodCall('addDataSource', array('multi_custom_group_'.$dao->name, $definition, E::ts('Custom group: %1', [1=>$dao->title])));
}
} catch (\CiviCRM_API3_Exception $e) {
......
<?php
/**
* Copyright (C) 2021 Jaap Jansma (jaap.jansma@civicoop.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Civi\DataProcessor\Symfony\Component\DependencyInjection;
use Symfony\Component\DependencyInjection\Definition;
class DefinitionAdapter extends Definition {
/**
* Returns a definition class.
* We have to set is private to false on the definition class
* with newer versions of civicrm (especially with civicrm and drupal 9)
* with older versions of civicrm the setPrivate method is not available so we cannot set it.
*
* @param null $class
* @param array $arguments
* @return \Symfony\Component\DependencyInjection\Definition
*/
public static function createDefinitionClass($class = null, array $arguments = array()) {
$definition = new Definition($class, $arguments);
$definition->setPublic(true);
if (method_exists(Definition::class, 'setPrivate')) {
$definition->setPrivate(FALSE);
}
return $definition;
}
}
......@@ -4,7 +4,7 @@ require_once 'dataprocessor.civix.php';
use CRM_Dataprocessor_ExtensionUtil as E;
use \Symfony\Component\DependencyInjection\ContainerBuilder;
use \Symfony\Component\DependencyInjection\Definition;
use \Civi\DataProcessor\Symfony\Component\DependencyInjection\DefinitionAdapter;
/**
* @return \Civi\DataProcessor\Factory
......@@ -24,13 +24,11 @@ function dataprocessor_get_factory() {
*/
function dataprocessor_civicrm_container(ContainerBuilder $container) {
// Register the TypeFactory
$factoryDefinition = new Definition('Civi\DataProcessor\Factory');
$factoryDefinition->setPrivate(FALSE);
$factoryDefinition = DefinitionAdapter::createDefinitionClass('Civi\DataProcessor\Factory');
$container->setDefinition('data_processor_factory', $factoryDefinition);
$apiKernelDefinition = $container->getDefinition('civi_api_kernel');
$apiProviderDefinition = new Definition('Civi\DataProcessor\Output\Api');
$apiProviderDefinition->setPrivate(FALSE);
$apiProviderDefinition = DefinitionAdapter::createDefinitionClass('Civi\DataProcessor\Output\Api');
$apiKernelDefinition->addMethodCall('registerApiProvider', array($apiProviderDefinition));
// Add the data source for custom groups with multiple set.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment