Normalize a file entry.

@param   string  $item
@param   string  $base
@return  array   Normalized file array
183469
protected function normalizeObject($item, $base)
	{
		$item = preg_replace('#\s+#', ' ', trim($item), 7);
		list($permissions, /* $number */, /* $owner */, /* $group */, $size, /* $month */, /* $day */, /* $time*/, $name) = explode(' ', $item, 9);

		$type = $this->detectType($permissions);
		$path = empty($base) ? $name : $base . $this->separator . $name;

		if ($type === 'dir')
		{
			return compact('type', 'path');
		}

		$permissions = $this->normalizePermissions($permissions);
		$size = (int) $size;

		return compact('type', 'path', 'permissions', 'size');
	}
82392
public function transformWithRelated($item)
    {
        $transformedItem = $this->getTransformation($item);

        return $this->transformRelated($transformedItem, $item);
    }
588683
protected function doClean(Item $item)
    {
        $item->setIntro(
            $this->purifier->purify($item->getIntro())
        );
        $item->setContent(
            $this->purifier->purify($item->getContent())
        );

        return $item;
    }
664985
public function normalize($object, $format = null, array $context = []): array
    {
        $links = [];

        if (count($object->getRelations())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getRelations(), $format, $context));
        }

        if (count($object->getActions())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getActions(), $format, $context));
        }

        $data = [
            'message' => $object->getMessage(),
        ];

        if ($object->getPath()) {
            $data['path'] = $object->getPath();
        }

        if ($object->getIdentifier()) {
            $data['logref'] = $object->getIdentifier();
        }

        if (count($links)) {
            $data['_links'] = $links;
        }

        return $data;
    }
759019
private function getContainerParameters($item)
    {
        $matches = array();
        if (preg_match('/^%([^%]+)%$/', $item, $matches)) {
            if ($this->hasParameter($matches[1])) {
                return $this->getParameter($matches[1]);
            }
        }

        if (preg_match_all('/%([^%]+)%/', $item, $matches, PREG_PATTERN_ORDER)) {
            foreach ($matches[1] as $expr) {
                if ($this->hasParameter($expr)) {
                    $item = str_replace('%'.$expr.'%', $this->getParameter($expr), $item);
                }
            }
        }

        return $item;
    }
884629
protected function normalizeObject($item, $base)
    {
        $systemType = $this->systemType ?: $this->detectSystemType($item);

        if ($systemType === 'unix') {
            return $this->normalizeUnixObject($item, $base);
        }

        if ($systemType === 'windows') {
            return $this->normalizeWindowsObject($item, $base);
        }

        throw NotSupportedException::forFtpSystemType($systemType);
    }
692644
protected function getBaseDocument(Item $item, array $itemRecord)
    {
        $type = $item->getType();
        $rootPageUid = $item->getRootPageUid();
        $accessRootLine = $this->getAccessRootline($item);
        return $this->documentBuilder->fromRecord($itemRecord, $type, $rootPageUid, $accessRootLine);
    }
812651
protected function absolutePath(string $file, string $base): string
    {
        return $file[0] !== DIRECTORY_SEPARATOR && !str_contains($file, ':')
            ? $base . DIRECTORY_SEPARATOR . $file
            : $file;
    }
969098
protected function convertItem($item)
    {
        foreach ($item as $key => $value) {
            if (!isset($this->converters[$key])) {
                continue;
            }

            foreach ($this->converters[$key] as $converter) {
                $item[$key] = call_user_func($converter, $item[$key]);
            }
        }

        return $item;
    }
136182
public function importItem(Item $item)
    {
        foreach ($this->data as $templateData) {
            foreach ($item->getData() as $itemData) {
                if ($itemData->getName() === $templateData->getName()) {
                    $templateData->setName($itemData->getName());
                    $templateData->setValue($itemData->getValue());
                    $templateData->setPrompt($itemData->getPrompt());
                }
            }
        }

        return $this;
    }
43783
protected function normalize($data)
    {
        if (is_array($data) || $data instanceof \Traversable) {
            $normalized = array();

            $count = 1;
            foreach ($data as $key => $value) {
                if ($count++ >= 1000) {
                    $normalized['...'] = 'Over 1000 items, aborting normalization';
                    break;
                }
                $normalized[$key] = $this->normalize($value);
            }

            return $normalized;
        }

        if ($data instanceof Exception) {
            return $this->normalizeException($data);
        }

        return $data;
    }
1132129
function normalizePEMContent(root, file) {
  if (Array.isArray(file)) return file.map(function map(item) {
    return normalizePEMContent(root, item)
  });

  //
  // Assumption that this is a Buffer, a PEM file, or something broken
  //
  if (typeof(file) !== 'string' || pemFormat.test(file)) {
    return file;
  }

  return fs.readFileSync(path.resolve(root, file));
}
966024
public function itemCreate(Item $item)
    {
        $response = $this->getGuzzleClient()
            ->post(
                '/items',
                array_merge($this->setQuery(), $this->setBody($item))
            );

        return $this->serializer->deserialize(
            $response->getBody()->getContents(),
            Item::class,
            'json'
        );
    }
181189
public static function normalizeFilesArray(array $files): array
    {
        $return = [];
        foreach ($files as $i => $file) {
            foreach ($file as $key => $value) {
                $return[$key][$i] = $value;
            }
        }

        return $return;
    }
939530
protected function getAccessRootline(Item $item)
    {
        $accessRestriction = '0';
        $itemRecord = $item->getRecord();

        // TODO support access restrictions set on storage page

        if (isset($GLOBALS['TCA'][$item->getType()]['ctrl']['enablecolumns']['fe_group'])) {
            $accessRestriction = $itemRecord[$GLOBALS['TCA'][$item->getType()]['ctrl']['enablecolumns']['fe_group']];

            if (empty($accessRestriction)) {
                // public
                $accessRestriction = '0';
            }
        }

        return 'r:' . $accessRestriction;
    }
988800
protected function normalizeFiles($files)
    {
        foreach ($files as $name => $info) {
            $this->loadFilesRecursive($name, $info['name'], $info['tmp_name'], $info['type'], $info['size'], $info['error']);
        }

        return $this->_files;
    }
1021530
public function normalize($object, $format = null, array $context = []): array
    {
        $nested = $object->getMessage() || $object->getReason();

        $errors = [];

        foreach ($object as $item) {
            $errors[] = $this->normalizer->normalize($item, $format, $context);
        }

        $links = [];

        if (count($object->getRelations())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getRelations(), $format, $context));
        }

        if (count($object->getActions())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getActions(), $format, $context));
        }

        if ($nested) {
            $innerError = new ErrorResource(
                $object->getMessage(),
                $object->getReason(),
                $object->getPath(),
                $object->getAttributes(),
                $object->getIdentifier()
            );

            $data = $this->normalizer->normalize($innerError, $format, $context);

            if (count($links)) {
                $data['_links'] = $links;
            }

            $data['_embedded'] = [
                'errors' => $errors,
            ];

            return $data;
        }

        $data = [
            'total' => count($errors),
            '_embedded' => [
                'errors' => $errors,
            ],
        ];

        if (count($links)) {
            $data['_links'] = $links;
        }

        return $data;
    }