Skip to content

Commit

Permalink
Updated config and paramconverter to work with symfony 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Scholten committed Jul 16, 2018
1 parent b82f5d3 commit 04de3ef
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class SalesforceMapperExtension extends Extension
class LogicItLabSalesforceMapperExtension extends Extension
{
/**
* {@inheritDoc}
Expand All @@ -23,7 +23,10 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);

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

$yamlLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$yamlLoader->load('services.yaml');

if (isset($config['cache_driver'])) {
switch ($config['cache_driver']) {
Expand Down
5 changes: 3 additions & 2 deletions Request/ParamConverter/SalesforceParamConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use LogicItLab\Salesforce\MapperBundle\Mapper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;

/**
* This param converter convers a Salesforce id into a Salesforce object, using
Expand Down Expand Up @@ -40,7 +41,7 @@ public function __construct(Mapper $mapper, array $mappings)
/**
* {@inheritdoc}
*/
public function apply(Request $request, ConfigurationInterface $configuration)
public function apply(Request $request, ParamConverter $configuration)
{
// @todo Is it smart to do this based on variable name? Perhaps it's
// better to, here also, look at class name?
Expand All @@ -63,7 +64,7 @@ public function apply(Request $request, ConfigurationInterface $configuration)
/**
* {@inheritdoc}
*/
public function supports(ConfigurationInterface $configuration)
public function supports(ParamConverter $configuration)
{
return in_array($configuration->getClass(), $this->mappings);
}
Expand Down
32 changes: 32 additions & 0 deletions Resources/config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.

LogicItLab\Salesforce\MapperBundle\:
resource: '../../*'
exclude: '../../{Tests}'

LogicItLab\Salesforce\MapperBundle\Mapper:
arguments:
- '@phpforce.soap_client'
- '@LogicItLab\Salesforce\MapperBundle\Annotation\AnnotationReader'
- '@LogicItLab\Salesforce\MapperBundle\Cache\FileCache'

LogicItLab\Salesforce\MapperBundle\Cache\FileCache:
arguments:
- '%kernel.cache_dir%/salesforce'

LogicItLab\Salesforce\MapperBundle\Annotation\AnnotationReader:
arguments:
- '@annotation_reader'

LogicItLab\Salesforce\MapperBundle\MappedBulkSaver:
arguments:
- '@phpforce.soap_client.bulk_saver'
- '@LogicItLab\Salesforce\MapperBundle\Mapper'
- '@LogicItLab\Salesforce\MapperBundle\Annotation\AnnotationReader'

0 comments on commit 04de3ef

Please sign in to comment.