@param ModelTransformerInterface $modelTransformer
@param int $priority

@return $this|ModelTransformerInterface

@throws \RuntimeException
7717
public function addModelTransformer($modelTransformer, $priority = 0)
    {
        if (!(($modelTransformer instanceof ModelTransformerInterface)
            || ($modelTransformer instanceof ContextualModelTransformerInterface)
            || ($modelTransformer instanceof ObjectTransformerInterface)
        )
        ) {
            throw new \RuntimeException(
                sprintf('Model transformer should be an instance of "%s", "%s" or "%s"', ModelTransformerInterface::class, ContextualModelTransformerInterface::class, ObjectTransformerInterface::class)
            );
        }

        if ($modelTransformer instanceof ObjectTransformerInterface) {
            if (!isset($this->objectTransformers[$modelTransformer->getSupportedClass()])) {
                $this->objectTransformers[$modelTransformer->getSupportedClass()] = [];
            }

            if (!isset($this->objectTransformers[$modelTransformer->getSupportedClass()][$modelTransformer->getTargetClass()])) {
                $this->objectTransformers[$modelTransformer->getSupportedClass()][$modelTransformer->getTargetClass()] = [];
            }

            $this->objectTransformers[$modelTransformer->getSupportedClass()][$modelTransformer->getTargetClass()][$priority] = $modelTransformer;
            unset($this->sortedObjectTransformers);

            return $this;
        }

        if (!isset($this->modelTransformers[$priority])) {
            $this->modelTransformers[$priority] = [];
        }

        $this->modelTransformers[$priority][] = $modelTransformer;
        unset($this->sortedModelTransformers);

        return $this;
    }
938451
public function usingPaginator($paginator = null): TransformationFactory
	{
		if (! ($this->resource instanceof Collection) || ! ($this->entity instanceof LengthAwarePaginator)) {
			throw new \InvalidArgumentException('Bad Request Issued');
		}

		$this->resource->setPaginator(new IlluminatePaginatorAdapter($this->entity));

		return $this;
	}
743557
protected function transformDataProvider(DataProviderInterface $dataProvider)
    {
        if (Craft::$app->getRequest()->getIsHead()) {
            return null;
        } else {
            if (!$transformer = $this->dataTransformer()) {
                return $dataProvider;
            }

            // The transformed data
            $models = Factory::collection(
                $this->resolveTransformer($transformer),
                $dataProvider->getModels(),
                $this->getTransformConfig()
            );

            if ($this->collectionEnvelope === null) {
                return $models;
            } else {
                return [
                    $this->collectionEnvelope => $models,
                ];
            }
        }
    }
1009451
public function setPriorityString($priority)
    {
        $priority = \array_search(\strtolower($priority), TicketMessageInterface::PRIORITIES);

        if ($priority > 0) {
            $this->setPriority($priority);
        }

        return $this;
    }
270510
public function collection($items, $transformer, $model_name = '', $meta = [])
    {
        $resource = new Collection($items, $transformer, $model_name);

        $resource->setMeta($meta);
        if ($items instanceof LengthAwarePaginator) {
            $resource->setPaginator(new IlluminatePaginatorAdapter($items));
        }

        return $this->manager->createData($resource)->toArray();
    }
105595
public function addFormFieldResolver(FormFieldResolverInterface $resolver, $priority = 0)
    {
        $this->formFieldResolvers[$priority][] = $resolver;
        $this->needsSorting = true;
    }
108117
public function transform(array &$samples) : void
    {
        if ($this->medians === null or $this->mads === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }

        foreach ($samples as &$sample) {
            foreach ($this->mads as $column => $mad) {
                $feature = $sample[$column];

                if ($this->center) {
                    $feature -= $this->medians[$column];
                }

                $sample[$column] = $feature / $mad;
            }
        }
    }
699319
protected function _addTransformers(Model $model, Transit $transit, array $attachment) {
        if (empty($attachment['transforms'])) {
            return;
        }

        foreach ($attachment['transforms'] as $options) {
            $transformer = $this->_getTransformer($attachment, $options);

            if ($options['self']) {
                $transit->addSelfTransformer($transformer);
            } else {
                $transit->addTransformer($transformer);
            }
        }
    }
1196975
public function buildForm(FormBuilderInterface $builder, array $options) {
        /** @var ClassAwareDataTransformerInterface $entityTransformer */
        $entityTransformer = new $options['transformer']($this->om, $options['class']);
        $builder->addModelTransformer($entityTransformer);
    }
890727
public function transform($workflowTransition, array $params = array())
    {
        if (!$workflowTransition instanceof WorkflowTransitionInterface) {
            throw new TransformerParameterTypeException();
        }

        $facade = $this->newFacade();
        $facade->statusFrom = $this->getContext()->transform('status', $workflowTransition->getStatusFrom());
        $facade->statusTo = $this->getContext()->transform('status', $workflowTransition->getStatusTo());

        return $facade;
    }
886442
protected function getTransformer()
    {
        $transformer = null;

        // Check if controller specifies a resource
        if (! is_null(static::$transformer)) {
            $transformer = static::$transformer;
        }

        // Otherwise, check if model is specified
        else {
            // If it is, check if the controller's model specifies the transformer
            if (! is_null(static::$model)) {
                // If it does, use it
                if (! is_null((static::$model)::$transformer)) {
                    $transformer = (static::$model)::$transformer;
                }
            }
        }

        // This is the default transformer, if one is not specified
        if (is_null($transformer)) {
            $transformer = BaseTransformer::class;
        }

        return new $transformer;
    }
1243030
public function getModelTransformerForTranslation(FieldDefinition $fieldDefinition): CallbackTransformer
    {
        return new CallbackTransformer(
            function (ApiUserValue $data) {
                return new UserAccountFieldData($data->login, null, $data->email, $data->enabled);
            },
            function (UserAccountFieldData $submittedData) use ($fieldDefinition) {
                $userValue = clone $fieldDefinition->defaultValue;
                $userValue->login = $submittedData->username;
                $userValue->email = $submittedData->email;
                $userValue->enabled = $submittedData->enabled;

                return $userValue;
            }
        );
    }
941770
public function addAdminPanelAdaptor(AdminPanelAdaptorInterface $adaptor, $priority = 0)
    {
        $this->adaptors[$priority][] = $adaptor;
        unset($this->sorted);
    }
238025
public function setCurrentRecord(Mage_Core_Model_Abstract $model = null)
    {
        if ($model) {
            $expectedClass = get_class($this->getModel());
            if (!is_a($model, $expectedClass)) {
                throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model)));
            }
        }

        Mage::unregister($this->getCurrentRecordKey());

        if ($model) {
            Mage::register($this->getCurrentRecordKey(), $model);
        }

        return $this;
    }
484647
public function listen($event, $callable, $priority = ListenerPriority::NORMAL)
    {
        $this->getDispatcher()->listen($event, $callable, $priority);

        return $this;
    }
1112049
protected function pickTransformer(Resource $resource, Resource $parentResource)
    {
        foreach ($this->transformers as $i => $transformer) {
            if ($transformer->supports($resource, $parentResource)) {
                if (0 != $i) {
                    // Move transformer to top to improve next pick
                    unset($this->transformers[$i]);
                    array_unshift($this->transformers, $transformer);
                }

                return $transformer;
            }
        }

        throw new \RuntimeException('No transformer is able to support the resource.');
    }
1339930
public function setTransformer(\chilimatic\lib\interfaces\IFlyWeightTransformer $transformer)
    {
        $this->transformer = $transformer;

        return $this;
    }