Puli\Manager\Api\Container::getLegacyModuleFileConverter PHP Метод

getLegacyModuleFileConverter() публичный Метод

Returns the module file serializer with support for legacy versions.
public getLegacyModuleFileConverter ( ) : Webmozart\Json\Conversion\JsonConverter
Результат Webmozart\Json\Conversion\JsonConverter The module file converter.
    public function getLegacyModuleFileConverter()
    {
        if (!$this->legacyModuleFileConverter) {
            $this->legacyModuleFileConverter = $this->createValidatingConverter(new MigratingConverter($this->getModuleFileConverter(), ModuleFileConverter::VERSION, $this->getModuleFileMigrationManager()), function (stdClass $jsonData) {
                if (isset($jsonData->{'$schema'})) {
                    return $jsonData->{'$schema'};
                }
                // BC with 1.0
                return 'http://puli.io/schema/1.0/manager/module';
            });
        }
        return $this->legacyModuleFileConverter;
    }

Usage Example

Пример #1
0
 /**
  * @param string $className The name of the class to convert.
  *
  * @return JsonConverter The JSON converter.
  */
 public function getJsonConverter($className)
 {
     switch ($className) {
         case 'Puli\\Manager\\Api\\Config\\ConfigFile':
             return $this->container->getConfigFileConverter();
         case 'Puli\\Manager\\Api\\Module\\ModuleFile':
             return $this->container->getLegacyModuleFileConverter();
         case 'Puli\\Manager\\Api\\Module\\RootModuleFile':
             return $this->container->getLegacyRootModuleFileConverter();
         default:
             throw new InvalidArgumentException(sprintf('Could not find converter for class "%s".', $className));
     }
 }