Helper method for listing registered type handlers. Returns all handlers, or the
handler for a specific media type, if requested.

@param string $type The type of handler to return.
@return mixed Array of all handlers, or the handler for a specific type.
494107
public static function handlers($type = null) {
		$handlers = static::$_handlers + [
			'default' => [
				'view'     => 'lithium\template\View',
				'encode'   => false,
				'decode'   => false,
				'cast'     => false,
				'paths'    => [
					'template' => '{:library}/views/{:controller}/{:template}.{:type}.php',
					'layout'   => '{:library}/views/layouts/{:layout}.{:type}.php',
					'element'  => '{:library}/views/elements/{:template}.{:type}.php'
				]
			],
			'html' => [],
			'json' => [
				'cast' => true,
				'encode' => 'json_encode',
				'decode' => function($data) {
					return json_decode($data, true);
				}
			],
			'text' => ['cast' => false, 'encode' => function($s) { return $s; }],
			'form' => [
				'cast' => true,
				'encode' => 'http_build_query',
				'decode' => function($data) {
					$decoded = [];
					parse_str($data, $decoded);
					return $decoded;
				}
			]
		];

		if ($type) {
			return isset($handlers[$type]) ? $handlers[$type] : null;
		}
		return $handlers;
	}
1049792
protected static function _getList($type) {
        $types = array();

        foreach (self::$_types as $ext => $mimeType) {
            if (is_array($mimeType)) {
                $mimeType = $mimeType[0];
            }

            if (strpos($mimeType, $type) === 0) {
                $types[$ext] = $mimeType;
            }
        }

        return $types;
    }
1131141
public function getMethods($type)
    {
        $result = [];
        if ($type !== false) {
            $typeNorm = $this->toolsType->normalizeType($type);
            /** @var \Zend\Code\Reflection\ClassReflection $reflection */
            $reflection = new \Zend\Code\Reflection\ClassReflection($typeNorm);
            /** @var \Zend\Code\Reflection\DocBlockReflection $docBlock */
            $docBlock = $reflection->getDocBlock();
            $annotatedMethods = $this->_processClassDocBlock($docBlock);
            /* process normal methods (not annotated) */
            $publicMethods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
            $generalMethods = $this->_processClassMethods($publicMethods);
            $merged = array_merge($generalMethods, $annotatedMethods);
            /* convert results to array form according Magento requirements to be saved in the cache */
            /** @var \Praxigento\Core\App\Reflection\Data\Method $item */
            foreach ($merged as $item) {
                $methodName = $item->getName();
                $entry = [
                    'type' => $item->getType(),
                    'isRequired' => $item->getIsRequired(),
                    'description' => $item->getDescription(),
                    'parameterCount' => $item->getParameterCount()
                ];
                $result[$methodName] = $entry;
            }
        }
        return $result;
    }
1230764
public static function getOperators($type)
    {
        if (!in_array($type, self::getTypes())) {
            return [];
        }

        $source = snake_case($type).'_operators';

        return self::$$source;
    }
927921
public function fetchAll($type = self::FETCH_TYPE_NUM)
    {
        if ($this->_allFetched) {
            return $this->buffer;
        }
        $results = $this->statement->fetchAll($type);
        if ($results !== false) {
            $this->buffer = array_merge($this->buffer, $results);
        }
        $this->_allFetched = true;
        $this->statement->closeCursor();

        return $this->buffer;
    }
1192430
public function getHandlerForType(string $type) : HandlerInterface
    {
        if ($this->hasHandlerForType($type)) {
            return $this->handlers[$type];
        }

        throw DataTypeException::handlerNotFound($type);
    }
344656
protected function getAllSubtypes($type)
    {
        $subTypes = [];

        foreach ($this->superTypeConfiguration as $nodeType => $superTypes) {
            if (in_array($type, $superTypes)) {
                if (isset($this->types[$nodeType])) {
                    $subTypes[] = $nodeType;

                    $nodeTypeSubTypes = $this->getAllSubtypes($nodeType);
                    foreach ($nodeTypeSubTypes as $nodeTypeSubType) {
                        if (!in_array($nodeTypeSubType, $subTypes)) {
                            $subTypes[] = $nodeTypeSubType;
                        }
                    }
                }
            }
        }

        return $subTypes;
    }
91490
public function getHandler($media)
    {
        foreach ($this->handlers as $handler) {
            if ($handler->canHandle($media)) {
                return $handler;
            }
        }

        return new FileHandler();
    }
69820
public function get($type = null)
    {
        if (!$type) {
            return $this->messages;
        }

        if (isset($this->messages[$type])) {
            return $this->messages[$type];
        }

        return [];
    }
53176
public function getErrors($type = self::ERROR_ALL) {
        if ($type === self::ERROR_ALL) {
            return $this->_errors;
        }

        $clean = array();

        if ($this->_errors) {
            foreach ($this->_errors as $error) {
                if ($error['type'] === self::ERROR_NESTING) {
                    $clean[] = $error;

                } else if ($error['type'] === self::ERROR_CLOSING) {
                    $clean[] = $error;

                } else if ($error['type'] === self::ERROR_SCOPE) {
                    $clean[] = $error;
                }
            }
        }

        return $clean;
    }
1300596
public function get(string $type): array
    {
        try {
            return $this->converters[$this->resolveType($type)];
        } catch (\Throwable $t) {
            throw new InvalidTypeConverterException(
                sprintf('Invalid converter type `%s`.', $type)
            );
        }
    }
495850
public function getStatistics(string $type): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/enterprise/stats/:type', $type));
    }
953630
public function forType(string $type): HandlerInterface
    {
        $class = $type !== 'object' ? $type : null;

        if ($class === $this->class) {
            return $this;
        }

        $handler = clone $this;
        $handler->class = $class;

        return $handler;
    }
179654
public function getServiceNamesByType($type)
    {
        if (!$this->hasServices()) {
            return [];
        }
        $types = [];
        $services = $this->getServices();

        foreach ($services as $name => $service) {
            if ($service['type'] !== $type) {
                continue;
            }
            $types[] = $name;
        }

         return $types;
    }
1306494
public function lists($type = null)
    {
        $params = [
            'type' => $type,
        ];

        return $this->parseJSON('get', [self::API_LISTS, $params]);
    }
867339
protected function getAllowedFields(string $type): array
    {
        \assert($this->hasFilter($type) === true);

        return $this->fieldSets[$type];
    }
56445
public function to(string $type): HandlerInterface
    {
        $type = $this->normalizeType($type);

        if (isset($this->handlers[$type])) {
            $key = $type;
        } elseif ($type === 'integer|float' || $type === 'float|integer') {
            $key = 'number';
        } elseif (strpos($type, '|') !== false) {
            $key = 'multiple';
        } elseif (substr($type, -2) === '[]' || is_a($type, Traversable::class, true)) {
            $key = 'array';
        } else {
            $key = 'object';
        }

        if (!isset($this->handlers[$key])) {
            throw new OutOfBoundsException("Unable to find handler to cast to '$type'");
        }

        return $this->handlers[$key]->forType($type);
    }