<?php

declare(strict_types=1);

/*
 * (c) Christian Gripp <mail@core23.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Core23\ShariffBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

final class Core23ShariffExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container): void
    {
        $configuration = new Configuration();
        $config        = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('action.xml');
        $loader->load('block.xml');
        $loader->load('services.xml');

        $options = $config['options'];

        if (empty($config['services']['facebook']['app_id']) || empty($config['services']['facebook']['secret'])) {
            $options['services'] = array_values(array_diff($options['services'], ['Facebook']));
        } else {
            $options['Facebook'] = $config['services']['facebook'];
        }

        $container->setParameter('core23_shariff.options', $options);
    }
}

<?php

declare(strict_types=1);

/*
 * (c) Christian Gripp <mail@core23.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Core23\ShariffBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

final class Core23ShariffExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container): void
    {
        $configuration = new Configuration();
        $config        = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('action.xml');
        $loader->load('block.xml');
        $loader->load('services.xml');

        $options = $config['options'];

        if (!isset($config['services']['facebook']['app_id'], $config['services']['facebook']['secret']) ||
            null === $config['services']['facebook']['app_id'] ||
            null === $config['services']['facebook']['secret']) {
            $options['services'] = array_values(array_diff($options['services'], ['Facebook']));
        } else {
            $options['Facebook'] = $config['services']['facebook'];
        }

        $container->setParameter('core23_shariff.options', $options);
    }
}

Use more precise null and type checks
[PATCH] Use more precise null and type checks
