Example #1
0
 /**
  * Prepare configuration from entity config
  *
  * @return array
  */
 private function prepareConfiguration()
 {
     $configuration = [];
     $configuration['formatters'] = [];
     $allGetters = $this->variablesProvider->getEntityVariableGetters();
     foreach ($allGetters as $className => $getters) {
         $properties = [];
         $methods = [];
         $formatters = [];
         $defaultFormatters = [];
         foreach ($getters as $varName => $getter) {
             if (empty($getter)) {
                 $properties[] = $varName;
             } else {
                 if (!is_array($getter)) {
                     $methods[] = $getter;
                 } else {
                     $methods[] = $getter['property_path'];
                     $formatters[$varName] = $getter['formatters'];
                     $defaultFormatters[$varName] = $getter['default_formatter'];
                 }
             }
         }
         $configuration['properties'][$className] = $properties;
         $configuration['methods'][$className] = $methods;
         $configuration['formatters'][$className] = $formatters;
         $configuration['default_formatter'][$className] = $defaultFormatters;
     }
     return $configuration;
 }
Example #2
0
 /**
  * Prepare configuration from entity config
  *
  * @return array
  */
 private function prepareConfiguration()
 {
     $configuration = array();
     $allGetters = $this->variablesProvider->getEntityVariableGetters();
     foreach ($allGetters as $className => $getters) {
         $properties = [];
         $methods = [];
         foreach ($getters as $varName => $getter) {
             if (empty($getter)) {
                 $properties[] = $varName;
             } else {
                 $methods[] = $getter;
             }
         }
         $configuration['properties'][$className] = $properties;
         $configuration['methods'][$className] = $methods;
     }
     return $configuration;
 }
 public function testGetEntityVariableGettersForAllEntities()
 {
     $entity1Class = 'TestEntity1';
     $entity2Class = 'TestEntity2';
     $provider1 = $this->getMock('Oro\\Bundle\\EmailBundle\\Provider\\EntityVariablesProviderInterface');
     $provider1->expects($this->once())->method('getVariableGetters')->with(null)->will($this->returnValue([$entity1Class => ['var1' => 'getVar1']]));
     $provider2 = $this->getMock('Oro\\Bundle\\EmailBundle\\Provider\\EntityVariablesProviderInterface');
     $provider2->expects($this->once())->method('getVariableGetters')->with(null)->will($this->returnValue([$entity1Class => ['var2' => 'getVar2']]));
     $provider3 = $this->getMock('Oro\\Bundle\\EmailBundle\\Provider\\EntityVariablesProviderInterface');
     $provider3->expects($this->once())->method('getVariableGetters')->with(null)->will($this->returnValue([$entity2Class => ['var1' => 'getVar1']]));
     $this->provider->addEntityVariablesProvider($provider1);
     $this->provider->addEntityVariablesProvider($provider2);
     $this->provider->addEntityVariablesProvider($provider3);
     $result = $this->provider->getEntityVariableGetters();
     $this->assertEquals([$entity1Class => ['var1' => 'getVar1', 'var2' => 'getVar2'], $entity2Class => ['var1' => 'getVar1']], $result);
 }