Returns the first available component with the given class or interface.

@param string $type ClassName
@return GridFieldComponent
19062
public function getComponentByType($type)
    {
        foreach ($this->components as $component) {
            if ($component instanceof $type) {
                return $component;
            }
        }
        return null;
    }
536705
public function getRenderer($type = self::PHP, $config = [])
    {
        $type = strtolower($type);

        $class = sprintf('Windwalker\Core\Renderer\%sRenderer', ucfirst($type));

        if (!class_exists($class)) {
            $class = sprintf('Windwalker\Renderer\%sRenderer', ucfirst($type));
        }

        if (!class_exists($class)) {
            throw new \DomainException(sprintf('%s renderer not supported.', $type));
        }

        if ($type === 'blade') {
            if (empty($config['cache_path'])) {
                $config['cache_path'] = $this->config->get('path.cache') . '/renderer';
            }
        }

        if ($type === 'edge') {
            if (empty($config['cache_path']) && !isset($config['cache'])) {
                $config['cache_path'] = $this->config->get('path.cache') . '/renderer';
            }
        }

        if ($type === 'twig') {
            if (empty($config['path_separator'])) {
                $config['path_separator'] = '.';
            }
        }

        /** @var AbstractRenderer|CoreRendererInterface|GlobalVarsTrait $renderer */
        $renderer = new $class(static::getGlobalPaths(), $config);

        $renderer->setPackageFinder($this->finder);
        $renderer->setGlobals($this->getGlobals());

        return $renderer;
    }
132690
public static function getType($type)
    {
        if (!isset(self::$typesMap[$type])) {
            throw new \InvalidArgumentException(sprintf('Invalid type specified "%s".', $type));
        }
        if (!isset(self::$typeObjects[$type])) {
            $className                = self::$typesMap[$type];
            self::$typeObjects[$type] = new $className;
        }

        return self::$typeObjects[$type];
    }
99449
public function get($type)
    {
        if (!isset($this->instances[$type])) {

            if (!isset($this->services[$type])) {
                if ($this->debug) {
                    trigger_error(sprintf("Widget type '%s' does not exist, returning a null implementation", $type), E_USER_ERROR);
                }
                // This primarily meant to display stuff, we should never WSOD
                // in the user's face, return a null object instead that will
                // UI operations smooth and error tolerant.
                return new NullWidget();
            }

            $this->instances[$type] = $this->container->get($this->services[$type]);
        }

        return $this->instances[$type];
    }
1072141
public function getFirstByNameType( $name, $type, $config = [] ) {

		$modelClass = static::$modelClass;

		return $modelClass::findFirstByNameType( $name, $type, $config );
	}
467400
public function getAncestorByType($type)
    {
        $current = $this;
        do
        {
            $parent = $current->parent;
            $current = $parent;
        }
        while($parent && !$parent instanceof $type);

        return $parent;
    }
1218314
public static function getExporter($type) {
        // normalize type
        $className = 'Garp_Content_Export_' . ucfirst($type);
        $obj = new $className();
        if (!$obj instanceof Garp_Content_Export_Abstract) {
            throw new Garp_Content_Export_Exception(
                "Class $className does not implement Garp_Content_Export_Abstract."
            );
        }
        return $obj;
    }
1155755
public function getPaginator( $type )
    {
        $type = (string) $type;

        switch ( $type )
        {
            case 'content':
                $joins = array(
                    'paragraph_property_layout' => array(
                        'table'     => array( 'paragraph_property_layout' => 'paragraph_property' ),
                        'where'     => new Expression(
                            '?.? = ?.? AND ?.? = ?',
                            array(
                                'paragraph',                 'id',
                                'paragraph_property_layout', 'paragraphId',
                                'paragraph_property_layout', 'name',
                                'layoutId',
                            ),
                            array(
                                Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                                Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                                Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                                Expression::TYPE_VALUE,
                            )
                        ),
                        'columns'   => array(),
                        'type'      => Select::JOIN_LEFT,
                    ),
                    'paragraph_layout' => array(
                        'table'     => array( 'paragraph_layout' => 'paragraph' ),
                        'where'     => new Expression(
                            'CAST( CASE
                                     WHEN ?.? = \'\' THEN NULL
                                     ELSE ?.?
                                   END AS INT ) = ?.?',
                            array(
                                'paragraph_property_layout', 'value',
                                'paragraph_property_layout', 'value',
                                'paragraph_layout',          'id',
                            ),
                            array(
                                Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                                Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                                Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            )
                        ),
                        'columns'   => array( 'layoutName' => 'name' ),
                        'type'      => Select::JOIN_LEFT,
                    ),
                );
                $columns = array(
                    'title' => new Expression(
                        '( SELECT ?
                             FROM ? AS ?
                            WHERE ?.? = ?.?
                              AND ?.? = ?
                         ORDER BY CASE ?.?
                                      WHEN ? THEN 3
                                      WHEN ? THEN 2
                                      ELSE 1
                                  END DESC
                            LIMIT 1 )',
                        array(
                            'value',
                            'paragraph_property', 'paragraph_property_title',
                            'paragraph', 'id',
                            'paragraph_property_title', 'paragraphId',
                            'paragraph_property_title', 'name',
                            'title',
                            'paragraph_property_title', 'locale',
                            $this->getLocale(),
                            $this->getPrimaryLanguage(),
                        ),
                        array(
                            Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_VALUE,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_VALUE,
                            Expression::TYPE_VALUE,
                        )
                    ),
                    'defaultFor' => new Expression(
                        '( SELECT COUNT(*)
                             FROM ?
                            WHERE ?.? = ?.? )',
                        array(
                            'subdomain',
                            'subdomain', 'defaultContentId',
                            'paragraph', 'id',
                        ),
                        array(
                            Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                        )
                    ),
                );
                break;

            case 'layout':
                $joins   = null;
                $columns = array(
                    'defaultFor' => new Expression(
                        '( SELECT COUNT(*) FROM ? WHERE ?.? = ?.? )',
                        array(
                            'subdomain',
                            'subdomain', 'defaultLayoutId',
                            'paragraph', 'id',
                        ),
                        array(
                            Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                            Expression::TYPE_IDENTIFIER, Expression::TYPE_IDENTIFIER,
                        )
                    ),
                );
                break;

            case 'widget':
                $joins  = array(
                    'paragraph_content' => array(
                        'table'     => array( 'paragraph_content' => 'paragraph' ),
                        'where'     => 'paragraph.rootId = paragraph_content.id',
                        'columns'   => array(
                            'rootName'  => 'name',
                            'rootType'  => 'type',
                        ),
                        'type'      => Select::JOIN_LEFT,
                    ),
                );
                $columns = null;
                break;

            default:
                $joins   = null;
                $columns = null;
                break;
        }

        return $this->getMapper()
                    ->getPaginator(
                        array( 'paragraph.type' => $type ),
                        array( 'rootId'         => 'ASC',
                               'left'           => 'ASC' ),
                        $columns,
                        $joins
                    );
    }
951060
public function getAdapter($type)
	{
		$type = strtolower($type);

		if (!isset($this->adapters[$type]))
		{
			// Try to load the adapter object
			/* @var  ExtractableInterface  $class */
			$class = 'Joomla\\Archive\\' . ucfirst($type);

			if (!class_exists($class) || !$class::isSupported())
			{
				throw new \InvalidArgumentException(
					sprintf(
						'Archive adapter "%s" (class "%s") not found or supported.',
						$type,
						$class
					)
				);
			}

			$this->adapters[$type] = new $class($this->options);
		}

		return $this->adapters[$type];
	}
1254610
public function getTransformer($type)
    {
        return isset($this->methods[$type]) ? $this->methods[$type] : null;
    }
673730
protected function resolveWidget($type)
    {
        if ($this->formGroupFactory()->isResolvable($type)) {
            return $this->formGroupFactory()->create($type);
        } elseif ($this->widgetFactory()->isResolvable($type)) {
            return $this->widgetFactory()->create($type);
        } else {
            throw new InvalidArgumentException(sprintf(
                'Invalid widget UI. Must be an instance of %s',
                WidgetInterface::class
            ));
        }
    }
862801
private function resolveClassName(string $type = null): string
    {
        if ($type === null) {
            throw new \InvalidArgumentException('Component type is not provided.');
        }
        $class = self::$dict[$type] ?? camelize($type);
        return $this->namespace . '\\' . $class . $this->suffix;
    }
1094365
public function get($type)
    {
        if ($type === self::TYPE_MAILER) {
            $name = $this->configService->getValue('system_mailer');
        } elseif ($type === self::TYPE_DISPATCHER) {
            $name = $this->configService->getValue('system_dispatcher');
        } else {
            throw new \InvalidArgumentException('Provided type does not exist');
        }

        if (empty($name)) {
            return null;
        }

        return $this->connector->getConnection($name);
    }
1159408
public function getCustomField($type, $field)
    {
        if (!isset($this->customFields[$type]) ||
             !isset($this->customFields[$type][$field])) {
            return null;
        }

        return $this->customFields[$type][$field];
    }
927342
public function getClassName(string $type): string
    {
        assert(isset($this->classes[$type]));
        return $this->classes[$type];
    }
607879
public function column( $type )
    {
        $classPrefix = __CLASS__ . '\\Type\\';

        if ( is_string( $type ) &&
             class_exists( $classPrefix . ucfirst( $type ) ) )
        {
            $type = ucfirst( $type );
            $args = func_get_args();
            array_shift( $args );
        }
        else if ( is_callable( $type ) )
        {
            $args = func_get_args();
            $type = static::CALLBACK;
        }
        else
        {
            $type = ucfirst( (string) $type );
            $args = func_get_args();
            array_shift( $args );
        }

        $class = $classPrefix . $type;

        if ( ! class_exists( $class ) )
        {
            throw new \LogicException( 'RowSet-type does not exists: ' . $class );
        }

        $reflection = new \ReflectionClass( $class );
        $result     = $reflection->newInstanceArgs( $args );

        if ( $result instanceof HelperInterface )
        {
            $result->setView( $this->getView() );
        }

        return $result;
    }
1004438
public function getItemClass($type = null)
    {
        $type = $type ? $type : $this->getDefaultValue();

        return $this->getPropertyItemsRootNamespace() . inflector()->classify($type);
    }