public function getConverter(string $modelClass, string $originalClass = '')
    {
        if ('' === $originalClass) {
            $originalClass = $modelClass;
        }

        $converterClass = 'NerdsAndCompany\\Schematic\\Converters\\'.ucfirst(str_replace('craft\\', '', $modelClass));
        $event = new ConverterEvent([
            'modelClass' => $modelClass,
            'converterClass' => $converterClass,
        ]);

        $this->trigger(self::EVENT_RESOLVE_CONVERTER, $event);
        $converterClass = $event->converterClass;

        if (class_exists($converterClass)) {
            $converter = new $converterClass();
            if ($converter instanceof ConverterInterface) {
                return $converter;
            }
        }

        $parentClass = get_parent_class($modelClass);
        if (!$parentClass) {
            Schematic::error('No converter found for '.$originalClass);

            return null;
        }

        return $this->getConverter($parentClass, $originalClass);
    }
public function getConverter(string $modelClass, string $originalClass = '')
    {
        if ('' === $originalClass) {
            $originalClass = $modelClass;
        }

        $converterClass = 'NerdsAndCompany\\Schematic\\Converters\\'.ucfirst(str_replace('craft\\', '', $modelClass));
        $event = new ConverterEvent([
            'modelClass' => $modelClass,
            'converterClass' => $converterClass,
        ]);

        $this->trigger(self::EVENT_RESOLVE_CONVERTER, $event);
        $converterClass = $event->converterClass;

        if (class_exists($converterClass)) {
            $converter = new $converterClass();
            if ($converter instanceof ConverterInterface) {
                return $converter;
            }
        }

        $parentClass = get_parent_class($modelClass);
        if (!$parentClass) {
            Schematic::error('No converter found for '.$originalClass);

            return null;
        }

        return $this->getConverter($parentClass, $originalClass);
    }
public function getConverter ( string $ modelClass , string $ originalClass = '' ) { if ( '' === $ originalClass ) { $ originalClass = $ modelClass ; } $ converterClass = 'NerdsAndCompany\\Schematic\\Converters\\' . ucfirst ( str_replace ( 'craft\\' , '' , $ modelClass ) ) ; $ event = new ConverterEvent ( [ 'modelClass' => $ modelClass , 'converterClass' => $ converterClass , ] ) ; $ this -> trigger ( self :: EVENT_RESOLVE_CONVERTER , $ event ) ; $ converterClass = $ event -> converterClass ; if ( class_exists ( $ converterClass ) ) { $ converter = new $ converterClass ( ) ; if ( $ converter instanceof ConverterInterface ) { return $ converter ; } } $ parentClass = get_parent_class ( $ modelClass ) ; if ( ! $ parentClass ) { Schematic :: error ( 'No converter found for ' . $ originalClass ) ; return null ; } return $ this -> getConverter ( $ parentClass , $ originalClass ) ; }
Find converter for model class.

@param string $modelClass

@return ConverterInterface|null
Find converter for model class .