예제 #1
0
 private function readConfig($type, FileLoader $fileLoader, $configDir)
 {
     $finder = new Finder();
     $finder->name('*.' . $type)->in($configDir);
     $config = array();
     foreach ($finder as $file) {
         $config[$file->getBasename('.' . $type)] = $fileLoader->load($file->getRealPath());
         $this->resources[] = new FileResource($file->getRealPath());
     }
     return $config;
 }
 /**
  * @param AttributeRepositoryInterface $attributeRepository
  * @param AttributeOptionRepositoryInterface $attributeOptionRepository
  * @param string $attributeCode
  * @param FileLoader $loader
  * @param string $mappingFile
  */
 public function __construct(AttributeRepositoryInterface $attributeRepository, AttributeOptionRepositoryInterface $attributeOptionRepository, $attributeCode, FileLoader $loader = null, $mappingFile = null)
 {
     $this->attributeRepository = $attributeRepository;
     $this->attributeOptionRepository = $attributeOptionRepository;
     $this->mapping = [];
     $this->attribute = $this->attributeRepository->findOneByIdentifier($attributeCode);
     if ($this->attribute) {
         $this->attributeOptions = $this->attribute->getOptions();
     } else {
         $this->attributeOptions = new ArrayCollection();
     }
     if ($mappingFile !== null && $loader !== null) {
         foreach ($loader->load($mappingFile) as $rawValue => $optionCode) {
             $this->mapTo($rawValue, $optionCode);
         }
     }
 }