/**
  * @param string $entityClass
  *
  * @return array
  */
 protected function getEntityVariableGetters($entityClass)
 {
     $entityClass = ClassUtils::getRealClass($entityClass);
     if (!$this->emailConfigProvider->hasConfig($entityClass)) {
         return [];
     }
     $result = [];
     $reflClass = new \ReflectionClass($entityClass);
     $fieldConfigs = $this->emailConfigProvider->getConfigs($entityClass);
     foreach ($fieldConfigs as $fieldConfig) {
         if (!$fieldConfig->is('available_in_template')) {
             continue;
         }
         /** @var FieldConfigId $fieldId */
         $fieldId = $fieldConfig->getId();
         list($varName, $getter) = $this->getFieldAccessInfo($reflClass, $fieldId->getFieldName());
         if (!$varName) {
             continue;
         }
         $resultGetter = $getter;
         $formatters = $this->formatterManager->guessFormatters($fieldId);
         if ($formatters && count($formatters)) {
             $resultGetter = array_merge(['property_path' => $getter], $formatters);
         }
         $result[$varName] = $resultGetter;
     }
     return $result;
 }
 /**
  * @dataProvider guessFormattersDataProvider
  * @param FieldConfigId $fieldConfigId
  * @param               $expected
  */
 public function testGuessFormatters(FieldConfigId $fieldConfigId, $expected)
 {
     $this->assertEquals($expected, $this->manager->guessFormatters($fieldConfigId));
 }
Exemple #3
0
 /**
  * @param mixed  $parameter
  * @param string $formatterName
  * @param array  $formatterArguments
  *
  * @return mixed
  */
 public function format($parameter, $formatterName, array $formatterArguments = [])
 {
     return $this->formatterManager->format($parameter, $formatterName, $formatterArguments);
 }