Commit d308fba8 authored by jaapjansma's avatar jaapjansma
Browse files

Compatibility fix for Symfony 2.8, 3.4 and 4.0

parent 52dec7b0
......@@ -9,7 +9,7 @@ namespace Civi\DataProcessorTokenOutput;
use CRM_DataprocessorTokenOutput_ExtensionUtil as E;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Civi\DataProcessorTokenOutput\Symfony\Component\DependencyInjection\DefinitionAdapter;
class CompilerPass implements CompilerPassInterface {
......@@ -22,8 +22,7 @@ class CompilerPass implements CompilerPassInterface {
}
$factoryDefinition = $container->getDefinition('data_processor_factory');
$tokenFactoryDefinition = new Definition('Civi\DataProcessorTokenOutput\TokenFactory');
$tokenFactoryDefinition->setPrivate(FALSE);
$tokenFactoryDefinition = DefinitionAdapter::createDefinitionClass('Civi\DataProcessorTokenOutput\TokenFactory');
$factoryDefinition->addMethodCall('addOutput', array(
'token', 'Civi\DataProcessorTokenOutput\Output\ContactToken', E::ts('Tokens')
......
<?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\DataProcessorTokenOutput\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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment