vendor/pimcore/customer-management-framework-bundle/src/DependencyInjection/Configuration.php line 472

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Enterprise License (PEL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  *  @license    http://www.pimcore.org/license     GPLv3 and PEL
  14.  */
  15. namespace CustomerManagementFrameworkBundle\DependencyInjection;
  16. use Pimcore\Model\DataObject\AbstractObject;
  17. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  18. use Symfony\Component\Config\Definition\ConfigurationInterface;
  19. class Configuration implements ConfigurationInterface
  20. {
  21.     public function getConfigTreeBuilder()
  22.     {
  23.         $treeBuilder = new TreeBuilder();
  24.         $rootNode $treeBuilder->root('pimcore_customer_management_framework');
  25.         $rootNode->addDefaultsIfNotSet();
  26.         $rootNode
  27.             ->children()
  28.                 ->arrayNode('oauth_client')
  29.                     ->canBeEnabled()
  30.                 ->end()
  31.             ->end();
  32.         $rootNode->append($this->buildGeneralNode());
  33.         $rootNode->append($this->buildEncryptionNode());
  34.         $rootNode->append($this->buildCustomerSaveManagerNode());
  35.         $rootNode->append($this->buildCustomerProviderNode());
  36.         $rootNode->append($this->buildCustomerSaveValidatorNode());
  37.         $rootNode->append($this->buildImportNode());
  38.         $rootNode->append($this->buildSegmentManagerNode());
  39.         $rootNode->append($this->buildCustomerListNode());
  40.         $rootNode->append($this->buildCustomerDuplicatesServicesNode());
  41.         $rootNode->append($this->buildNewsletterNode());
  42.         $rootNode->append($this->buildActivityUrlTrackerNode());
  43.         $rootNode->append($this->buildSegmentAssignmentClassPermission());
  44.         $rootNode->append($this->buildGDPRConfigNode());
  45.         return $treeBuilder;
  46.     }
  47.     private function buildGeneralNode()
  48.     {
  49.         $treeBuilder = new TreeBuilder();
  50.         $general $treeBuilder->root('general');
  51.         $general
  52.             ->addDefaultsIfNotSet()
  53.             ->info('Configuration of general settings');
  54.         $general
  55.             ->children()
  56.                 ->scalarNode('customerPimcoreClass')
  57.                     ->defaultValue('Customer')
  58.                 ->end()
  59.                 ->scalarNode('mailBlackListFile')
  60.                     ->defaultValue(PIMCORE_CONFIGURATION_DIRECTORY '/cmf/mail-blacklist.txt')
  61.                 ->end()
  62.             ->end()
  63.         ;
  64.         $general
  65.             ->children()
  66.             ->scalarNode('customerPimcoreClass')
  67.             ->defaultValue('Customer')
  68.             ->end()
  69.             ->scalarNode('mailBlackListFile')
  70.             ->defaultValue(PIMCORE_CONFIGURATION_DIRECTORY '/cmf/mail-blacklist.txt')
  71.             ->end()
  72.             ->end();
  73.         return $general;
  74.     }
  75.     private function buildEncryptionNode()
  76.     {
  77.         $treeBuilder = new TreeBuilder();
  78.         $general $treeBuilder->root('encryption');
  79.         $general
  80.             ->addDefaultsIfNotSet()
  81.             ->info('Configuration of EncryptionService');
  82.         $general
  83.             ->children()
  84.             ->scalarNode('secret')
  85.                 ->info(
  86.                     'echo \Defuse\Crypto\Key::createNewRandomKey()->saveToAsciiSafeString();' PHP_EOL .
  87.                     'keep it secret'
  88.                 )
  89.                 ->defaultValue('')
  90.             ->end()
  91.         ;
  92.         return $general;
  93.     }
  94.     private function buildCustomerSaveManagerNode()
  95.     {
  96.         $treeBuilder = new TreeBuilder();
  97.         $customerSaveManager $treeBuilder->root('customer_save_manager');
  98.         $customerSaveManager
  99.             ->addDefaultsIfNotSet()
  100.             ->info('Configuration of customer save manager');
  101.         $customerSaveManager
  102.             ->children()
  103.                 ->booleanNode('enableAutomaticObjectNamingScheme')
  104.                     ->defaultFalse()
  105.                     ->info('If enabled the automatic object naming scheme will be applied on each customer save. See: customer_provider -> namingScheme option')
  106.                 ->end()
  107.         ;
  108.         return $customerSaveManager;
  109.     }
  110.     private function buildCustomerSaveValidatorNode()
  111.     {
  112.         $treeBuilder = new TreeBuilder();
  113.         $customerSaveValidator $treeBuilder->root('customer_save_validator');
  114.         $customerSaveValidator
  115.             ->addDefaultsIfNotSet()
  116.             ->info('Configuration of customer save manager');
  117.         $customerSaveValidator
  118.             ->children()
  119.                 ->booleanNode('checkForDuplicates')
  120.                 ->info('If enabled an exception will be thrown when saving a customer object if duplicate customers exist.')
  121.                     ->defaultFalse()
  122.                 ->end()
  123.                 ->arrayNode('requiredFields')
  124.                         ->prototype('array')
  125.                             ->prototype('scalar')->end()
  126.                         ->info('Provide valid field combinations. The customer object then is valid as soon as at least one of these field combinations is filled up.')
  127.                         ->example([
  128.                             ['email'],
  129.                             ['firstname''lastname''zip''city'],
  130.                         ])
  131.                 ->end()
  132.         ;
  133.         return $customerSaveValidator;
  134.     }
  135.     private function buildSegmentManagerNode()
  136.     {
  137.         $treeBuilder = new TreeBuilder();
  138.         $segmentManager $treeBuilder->root('segment_manager');
  139.         $segmentManager
  140.             ->addDefaultsIfNotSet()
  141.             ->info('Configuration of segment manager');
  142.         $segmentManager
  143.             ->children()
  144.                 ->arrayNode('segmentFolder')
  145.                 ->addDefaultsIfNotSet()
  146.                     ->children()
  147.                         ->scalarNode('manual')
  148.                             ->defaultValue('/segments/manual')
  149.                             ->info('parent folder of manual segments + segment groups')
  150.                         ->end()
  151.                         ->scalarNode('calculated')
  152.                             ->defaultValue('/segments/calculated')
  153.                             ->info('parent folder of calculated segments + segment groups')
  154.                         ->end()
  155.                 ->end()
  156.         ;
  157.         return $segmentManager;
  158.     }
  159.     private function buildCustomerProviderNode()
  160.     {
  161.         $treeBuilder = new TreeBuilder();
  162.         $customerProvider $treeBuilder->root('customer_provider');
  163.         $customerProvider
  164.             ->addDefaultsIfNotSet()
  165.             ->info('Configuration of customer provider');
  166.         $customerProvider
  167.             ->children()
  168.                 ->scalarNode('parentPath')
  169.                     ->defaultValue('/customers')
  170.                     ->info('parent folder for active customers')
  171.                 ->end()
  172.                 ->scalarNode('archiveDir')
  173.                     ->defaultValue('/customers/_archive')
  174.                     ->info('parent folder for customers which are unpublished and inactive')
  175.                 ->end()
  176.                 ->scalarNode('namingScheme')
  177.                     ->defaultNull()
  178.                     ->example('{countryCode}/{zip}/{firstname}-{lastname}')
  179.                     ->info('If a naming scheme is configured customer objects will be automatically renamend and moved to the configured folder structure as soon as the naming scheme gets applied.')
  180.                 ->end()
  181.                 ->scalarNode('newCustomersTempDir')
  182.                     ->defaultValue('/customers/_temp')
  183.                     ->info('parent folder for customers which are created via the "new customer" button in the customer list view')
  184.                 ->end()
  185.         ;
  186.         return $customerProvider;
  187.     }
  188.     private function buildCustomerListNode()
  189.     {
  190.         $treeBuilder = new TreeBuilder();
  191.         $customerList $treeBuilder->root('customer_list');
  192.         $customerList
  193.             ->addDefaultsIfNotSet()
  194.             ->info('Configuration of customer list view');
  195.         $defaultExporters = [
  196.             'csv' => [
  197.                 'name' => 'CSV',
  198.                 'icon' => 'fa fa-file-text-o',
  199.                 'exporter' => \CustomerManagementFrameworkBundle\CustomerList\Exporter\Csv::class,
  200.                 'properties' => [
  201.                     'id',
  202.                     'active',
  203.                     'gender',
  204.                     'email',
  205.                     'phone',
  206.                     'firstname',
  207.                     'lastname',
  208.                     'street',
  209.                     'zip',
  210.                     'city',
  211.                     'countryCode',
  212.                     'idEncoded',
  213.                 ],
  214.                 'exportSegmentsAsColumns' => true
  215.             ],
  216.             'xlsx' => [
  217.                 'name' => 'XLSX',
  218.                 'icon' => 'fa fa-file-excel-o',
  219.                 'exporter' => \CustomerManagementFrameworkBundle\CustomerList\Exporter\Xlsx::class,
  220.                 'properties' => [
  221.                     'id',
  222.                     'active',
  223.                     'gender',
  224.                     'email',
  225.                     'phone',
  226.                     'firstname',
  227.                     'lastname',
  228.                     'street',
  229.                     'zip',
  230.                     'city',
  231.                     'countryCode',
  232.                     'idEncoded',
  233.                 ],
  234.                 'exportSegmentsAsColumns' => true
  235.             ],
  236.         ];
  237.         $defaultFilterPropertiesEquals = [
  238.             'id' => 'o_id',
  239.             'active' => 'active',
  240.         ];
  241.         $defaultFilterPropertiesSearch = [
  242.             'email' => [
  243.                 'email'
  244.             ],
  245.             'name' => [
  246.                 'firstname',
  247.                 'lastname'
  248.             ],
  249.             'search' => [
  250.                 'o_id',
  251.                 'idEncoded',
  252.                 'firstname',
  253.                 'lastname',
  254.                 'email',
  255.                 'zip',
  256.                 'city'
  257.             ]
  258.         ];
  259.         $customerList
  260.             ->children()
  261.                 ->arrayNode('exporters')
  262.                     ->prototype('array')
  263.                         ->children()
  264.                             ->scalarNode('name')->isRequired()->end()
  265.                             ->scalarNode('icon')->isRequired()->end()
  266.                             ->scalarNode('exporter')->isRequired()->end()
  267.                             ->booleanNode('exportSegmentsAsColumns')->defaultFalse()->end()
  268.                             ->arrayNode('properties')->isRequired()->prototype('scalar')->end()
  269.                         ->end()
  270.                     ->end()
  271.                 ->end()
  272.                 ->defaultValue($defaultExporters)
  273.                 ->end()
  274.                 ->arrayNode('filter_properties')
  275.                     ->addDefaultsIfNotSet()
  276.                     ->children()
  277.                         ->arrayNode('equals')
  278.                             ->defaultValue($defaultFilterPropertiesEquals)
  279.                             ->prototype('scalar')->end()
  280.                         ->end()
  281.                         ->arrayNode('search')
  282.                             ->defaultValue($defaultFilterPropertiesSearch)
  283.                             ->prototype('array')
  284.                                 ->prototype('scalar')
  285.                     ->end()
  286.                 ->end()
  287.                 ->end()
  288.         ;
  289.         return $customerList;
  290.     }
  291.     private function buildCustomerDuplicatesServicesNode()
  292.     {
  293.         $treeBuilder = new TreeBuilder();
  294.         $customerList $treeBuilder->root('customer_duplicates_services');
  295.         $customerList
  296.             ->addDefaultsIfNotSet()
  297.             ->info('Configuration of customer duplicates services');
  298.         $defaultListFields = [
  299.             ['id'],
  300.             ['email'],
  301.             ['firstname''lastname'],
  302.             ['street'],
  303.             ['zip''city']
  304.         ];
  305.         $customerList
  306.             ->children()
  307.                 ->arrayNode('duplicateCheckFields')
  308.                     ->defaultValue([])
  309.                     ->prototype('array')
  310.                         ->prototype('scalar')->end()
  311.                     ->end()
  312.                 ->end()
  313.                 ->arrayNode('duplicateCheckTrimmedFields')
  314.                     ->info('Performance improvement: add duplicate check fields which are trimmed (trim() called on the field value) by a customer save handler. No trim operation will be needed in the resulting query.')
  315.                     ->prototype('scalar')->end()
  316.                 ->end()
  317.                 ->arrayNode('duplicates_view')
  318.                     ->children()
  319.                         ->booleanNode('enabled')->defaultFalse()->end()
  320.                         ->arrayNode('listFields')
  321.                             ->prototype('array')
  322.                                 ->prototype('scalar')
  323.                                 ->end()
  324.                             ->end()
  325.                             ->defaultValue($defaultListFields)
  326.                         ->end()
  327.                     ->end()
  328.                 ->end()
  329.                 ->arrayNode('duplicates_index')
  330.                     ->children()
  331.                         ->booleanNode('enableDuplicatesIndex')
  332.                             ->defaultFalse()
  333.                         ->end()
  334.                         ->arrayNode('duplicateCheckFields')
  335.                             ->prototype('array')
  336.                                 ->prototype('array')
  337.                                     ->children()
  338.                                         ->booleanNode('soundex')->defaultFalse()->end()
  339.                                         ->booleanNode('metaphone')->defaultFalse()->end()
  340.                                         ->scalarNode('similarity')->defaultValue('\CustomerManagementFrameworkBundle\DataSimilarityMatcher\SimilarText')->end()
  341.                                         ->scalarNode('similarityThreshold')->defaultNull()->end()
  342.                                     ->end()
  343.                                 ->end()
  344.                             ->end()
  345.                         ->end()
  346.                         ->arrayNode('dataTransformers')
  347.                             ->prototype('scalar')->end()
  348.                         ->end()
  349.                     ->end()
  350.                 ->end()
  351.             ->end()
  352.         ;
  353.         return $customerList;
  354.     }
  355.     private function buildNewsletterNode()
  356.     {
  357.         $treeBuilder = new TreeBuilder();
  358.         $newsletter $treeBuilder->root('newsletter');
  359.         $newsletter
  360.             ->addDefaultsIfNotSet()
  361.             ->info('Configuration of newsletter services');
  362.         $newsletter
  363.             ->children()
  364.                 ->booleanNode('newsletterSyncEnabled')->defaultFalse()->end()
  365.                 ->booleanNode('newsletterQueueImmediateAsyncExecutionEnabled')->defaultTrue()->end()
  366.                 ->arrayNode('mailchimp')
  367.                     ->children()
  368.                         ->scalarNode('apiKey')->end()
  369.                         ->scalarNode('cliUpdatesPimcoreUserName')->end()
  370.                     ->end()
  371.                 ->end()
  372.             ->end();
  373.         return $newsletter;
  374.     }
  375.     private function buildActivityUrlTrackerNode()
  376.     {
  377.         $treeBuilder = new TreeBuilder();
  378.         $tracker $treeBuilder->root('activity_url_tracker');
  379.         $tracker
  380.             ->addDefaultsIfNotSet()
  381.             ->info('Configuration of activity url tracker services');
  382.         $tracker
  383.             ->children()
  384.                 ->booleanNode('enabled')->defaultTrue()->end()
  385.                 ->scalarNode('linkCmfcPlaceholder')->defaultValue('*|ID_ENCODED|*')->info('used for automatic link generation of LinkActivityDefinition data objects')->end()
  386.             ->end();
  387.         return $tracker;
  388.     }
  389.     private function buildSegmentAssignmentClassPermission()
  390.     {
  391.         $treeBuilder = new TreeBuilder();
  392.         $assignment $treeBuilder->root('segment_assignment_classes');
  393.         $assignment
  394.             ->addDefaultsIfNotSet()
  395.             ->children()
  396.                 ->arrayNode('types')
  397.                     ->addDefaultsIfNotSet()
  398.                     ->children()
  399.                         ->arrayNode('document')->info('expects sub types of document')
  400.                             ->addDefaultsIfNotSet()
  401.                             ->children()
  402.                                 ->scalarNode('folder')->defaultFalse()->end()
  403.                                 ->scalarNode('page')->defaultFalse()->end()
  404.                                 ->scalarNode('snippet')->defaultFalse()->end()
  405.                                 ->scalarNode('link')->defaultFalse()->end()
  406.                                 ->scalarNode('hardlink')->defaultFalse()->end()
  407.                                 ->scalarNode('email')->defaultFalse()->end()
  408.                                 ->scalarNode('newsletter')->defaultFalse()->end()
  409.                                 ->scalarNode('printpage')->defaultFalse()->end()
  410.                                 ->scalarNode('printcontainer')->defaultFalse()->end()
  411.                             ->end()
  412.                         ->end()
  413.                         ->arrayNode('asset')->info('expects sub types of asset')
  414.                             ->addDefaultsIfNotSet()
  415.                             ->children()
  416.                                 ->scalarNode('folder')->defaultFalse()->end()
  417.                                 ->scalarNode('image')->defaultFalse()->end()
  418.                                 ->scalarNode('text')->defaultFalse()->end()
  419.                                 ->scalarNode('audio')->defaultFalse()->end()
  420.                                 ->scalarNode('video')->defaultFalse()->end()
  421.                                 ->scalarNode('document')->defaultFalse()->end()
  422.                                 ->scalarNode('archive')->defaultFalse()->end()
  423.                                 ->scalarNode('unknown')->defaultFalse()->end()
  424.                             ->end()
  425.                         ->end()
  426.                         ->arrayNode('object')->info('expects sub types of object')
  427.                             ->addDefaultsIfNotSet()
  428.                             ->children()
  429.                                 ->scalarNode(AbstractObject::OBJECT_TYPE_FOLDER)->defaultFalse()->end()
  430.                                 ->arrayNode(AbstractObject::OBJECT_TYPE_OBJECT)
  431.                                     ->prototype('boolean')->end()
  432.                                 ->end()
  433.                                 ->arrayNode(AbstractObject::OBJECT_TYPE_VARIANT)
  434.                                     ->prototype('boolean')->end()
  435.                                 ->end()
  436.                             ->end()
  437.                         ->end()
  438.                     ->end()
  439.                 ->end()
  440.             ->end();
  441.         return $assignment;
  442.     }
  443.     private function buildGDPRConfigNode() {
  444.         $treeBuilder = new TreeBuilder();
  445.         $dataObjects $treeBuilder->root('gdprDataProvider');
  446.         $dataObjects
  447.             ->addDefaultsIfNotSet()
  448.             ->info('Settings for GDPR DataProvider for customers');
  449.         $dataObjects
  450.             ->children()
  451.                 ->arrayNode('customer')
  452.                     ->addDefaultsIfNotSet()
  453.                     ->info('Configure which classes should be considered, array key is class name')
  454.                     ->children()
  455.                         ->booleanNode("allowDelete")
  456.                             ->info("Allow delete of objects directly in preview grid.")
  457.                             ->defaultFalse()
  458.                         ->end()
  459.                         ->arrayNode('includedRelations')
  460.                             ->info('List relation attributes that should be included recursively into export.')
  461.                             ->prototype('scalar')->end()
  462.                         ->end()
  463.                     ->end()
  464.                 ->end()
  465.             ->end()
  466.         ;
  467.         return $dataObjects;
  468.     }
  469.     private function buildImportNode()
  470.     {
  471.         $treeBuilder = new TreeBuilder();
  472.         $general $treeBuilder->root('import');
  473.         $general
  474.             ->addDefaultsIfNotSet()
  475.             ->info('Configuration of CSV importer');
  476.         $general
  477.             ->children()
  478.                 ->integerNode('customerImporterId')
  479.                     ->info(
  480.                         'Pimcore CSV importer ID. Share the configuration with this ID with all users which should get access to the CSV import button in the customer list and in CustomerSegment objects.'
  481.                     )
  482.                     ->defaultValue(0)
  483.                 ->end()
  484.                 ->integerNode('customerImportParentId')
  485.                     ->info(
  486.                         'Default Parent ID of customer CSV importer. Only relevant when automatic naming scheme is disabled.'
  487.                     )
  488.                     ->defaultValue(1)
  489.                 ->end()
  490.         ;
  491.         return $general;
  492.     }
  493. }