@param TypeInterface $type
@param array         $options

@return self
961647
public static function fromType(TypeInterface $type, array $options = []): self
    {
        $optionsResolver = new OptionsResolver();

        $type->configureOptions($optionsResolver);

        $options = $optionsResolver->resolve($options);

        $builder = new self();

        $type->buildMessage($builder, $options);

        return $builder;
    }
1303156
public function instance($type = null, $options = array())
	{
		$type = $type ?: $this->getType();

		$signature = serialize(array($type, $options));

		// If the given type has not been created before, we will create the instances
		// here and cache it so we can return it next time very quickly. If there is
		// already a type created by this name, we'll just return that instance.
		if (!isset($this->types[$signature]))
		{
			try
			{
				$document = $this->createType($type, $options);
			}
			catch (Exception $e)
			{
				$document = $this->createType('html', $options);
			}

			$this->types[$signature] = $document;
		}

		return $this->types[$signature];
	}
638969
protected function createType($type, $options = array())
	{
		$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);

		$class = __NAMESPACE__ . '\\Type\\' . ucfirst($type);

		if (!class_exists($class))
		{
			throw new InvalidArgumentException("Type [$type] not supported.");
		}

		return new $class($options);
	}
432291
public function template($type, $options) {
		if (isset($options[$type])) {
			return $options[$type];
		}
		return isset($options['template']) ? $options['template'] : '';
	}
1232621
private function resolve(OptionInterface $type, array $options)
    {
        $oid = spl_object_hash($type);
        if (!isset($this->resolver[$oid])) {
            $this->resolver[$oid] = new OptionsResolver();
            $type->configureOptions($this->resolver[$oid]);
        }

        return $this->resolver[$oid]->resolve($options);
    }
527254
public function setType($type)
	{
		if ($type === self::TYPE_CSS || $type === self::TYPE_JS)
			$this->_options['type'] = $type;
		else
			throw new Exception('Invalid type: '.$type);
	}
702589
public static function get($type, array $options)
    {
        if (self::TYPE_STASH == $type) {
            $cache = new StashCache();
        } elseif (self::TYPE_DOCTRINE == $type) {
            $cache = new DoctrineCache();
        } elseif (self::TYPE_NONE == $type) {
            $cache = new NoCache();
        } else {
            throw new InvalidArgumentException(sprintf('Unknown cache type "%s".', $type));
        }
        $cache->setOptions($options);

        return $cache;
    }
297663
public function setType($type)
    {
        if ($type === null) {
            $type = self::TYPE_UNDEFINED;
        }

        $this->type = $type;

        return $this;
    }
1025383
public function setType($type): self
    {
        if ($type instanceof Type) {
            $this->setIndex($type->getIndex()->getName());
            $type = $type->getName();
        }

        $this->_type = (string) $type;

        return $this;
    }
1323283
private function validateOptions(array $options, $type)
    {
        if (!isset(self::$requiredOptions[$type])) {
            return;
        }
        foreach (self::$requiredOptions[$type] as $requiredOption) {
            if (!array_key_exists($requiredOption, $options)) {
                throw new ConfigurationException(
                    sprintf('Option "%s" must be provided for "%s" type parameters.', $requiredOption, $type)
                );
            }
        }
    }
710384
public function addType($name, $type, $data = null, $options = array())
    {
        $this->types[$name] = $type;
        $this->data[$name] = $data;
        $this->options[$name] = $options;

        return $this;
    }
430649
public function setCache($type, array $options = array())
    {
        $this->cacheType = $type;
        $this->cacheOptions = $options;

        return $this;
    }
1243323
public static function prepare( $type, $options ) {

		self::field_loader( $type );

		$prepare = '%s';

		if ( method_exists( self::$loaded[ $type ], 'prepare' ) ) {
			$prepare = self::$loaded[ $type ]->prepare( $options );
		}

		$prepare = apply_filters( "pods_field_{$type}_prepare", $prepare, $options, $type );

		return $prepare;
	}
127490
protected function initService(string $type, string $alias, array $options)
    {
        $id      = $this->resolverFactory->resolve($type, $alias);
        $service = $this->get($id);
        
        $service->setOptions($options);
        
        return $service;
    }
898683
public function onAddedToType(TypeInterface &$type)
    {
        parent::onAddedToType($type);

        $type->addTrait(IsArchivedInterface::class, IsArchivedInterfaceImplementation::class)->serialize($this->getName());
    }
410907
public function convert($field, $type, array $options = []) {
        if (!isset($this->_defaults[$type])) {
            throw new InvalidArgumentException(sprintf('Converter %s does not exist', $type));
        }

        $this->_converters[$field] = Hash::merge([
            'encode' => true,
            'decode' => true,
            'type' => $type,
        ], $this->_defaults[$type], $options);

        return $this;
    }
914597
public function addOption(OptionInterface $option)
    {
        if (!$this->hasOption($option)) {
            $this->options->add($option);
        }

        return $this;
    }