Transform an array of roles to choices

@param array $value

@return array
168080
public function transform($value)
    {
        $result = array();
        $configuration = $this->generatePerimeterManager->generatePerimeters($value->getOwner()->getSite()->getSiteId());
        $value = $value->toArray();

        foreach ($configuration as $type => &$paths) {
            $items = array_key_exists($type, $value) ? $value[$type]->getItems() : array();
            array_walk($paths, function($path) use (&$result, $items, $type) {
                $key = GeneratePerimeterManager::changePathToName($path);
                $result[$type][$key] = in_array($path, $items);
                $result[$type][$key] = false;
                foreach($items as $item) {
                    $result[$type][$key] = $result[$type][$key] || preg_match('/^' . preg_quote($item, '/') . '.*$/', $path);
                }
            });
        }

        return $result;
    }
161589
protected function transformRecursive($value)
    {
        if (is_array($value)) {
            if (array_key_exists('#comment', $value)) {
                unset($value['#comment']);
            }

            foreach ($value as &$subvalue) {
                $subvalue = $this->transformRecursive($subvalue);
            }
        }

        return $value;
    }
166608
public function transform($value)
    {
        if (!$value instanceof Value) {
            return null;
        }

        return array(
            'title' => $value->title,
            'description' => $value->description,
            'keywords' => implode(',', $value->keywords),
            'priority' => $value->priority,
            'change' => $value->change,
            'sitemap_use' => !empty($value->sitemap_use),
        );
    }
963653
public static function getServiceConditionals($value)
    {
        $services = array();

        if (is_array($value)) {
            foreach ($value as $v) {
                $services = array_unique(array_merge($services, self::getServiceConditionals($v)));
            }
        } elseif ($value instanceof Reference && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $value->getInvalidBehavior()) {
            $services[] = (string) $value;
        }

        return $services;
    }
157380
protected function mapValuesToOptions(array $value, array $options)
    {
        $result = [];
        foreach ($value as $key) {
            $result[] = $this->mapValueToOption($key, $options);
        }
        return $result;
    }
1101277
public function reverseTransform($value): ?array
    {
        if (null === $value) {
            return null;
        }

        if (!is_string($value)) {
            throw new TransformationFailedException('Expected a string.');
        }

        $parts = explode(':', $value);

        if (count($parts) < 3) {
            throw new TransformationFailedException('Policy string must contain at least 3 parts.');
        }

        return [
            'id' => $parts[0],
            'module' => $parts[1],
            'function' => $parts[2],
        ];
    }
992287
public function createWeightedList($value): array
    {
        return array_map(function ($data) {
            if ($data instanceof AcquirerWeight) {
                return $data;
            }

            return AcquirerWeight::createFromData((array) $data);
        }, $value);
    }
999633
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof APIRole) {
            throw new TransformationFailedException('Expected a ' . APIRole::class . ' object.');
        }

        return $value->id;
    }
126477
static public function inArray($value, array $choices, $message = null, $propertyPath = null)
        {
            static::choice($value, $choices, $message, $propertyPath);
        }
1241833
protected function handleArrayParameter( $value )
    {
        $values = array();
        foreach ( $value->data->value as $subValue )
        {
            if ( $subValue->count() > 0 )
            {
                $subValue = (array)$subValue;
            }
            else
            {
                $subValue = array( (string)$subValue );
            }
            $values[] = $this->processParameter( $subValue );
        }

        return $values;
    }
1199323
protected function hydrateFiles(array $value)
    {
        if (empty($value)) {
            return [[$this->column => $this->getRules()], []];
        }

        $rules = $input = [];

        foreach ($value as $key => $file) {
            $rules[$this->column.$key] = $this->getRules();
            $input[$this->column.$key] = $file;
        }

        return [$rules, $input];
    }
576898
private function convertArrayToEntityValue(array $value)
    {
        $excludes = $this->pluck(Entity::EXCLUDE_FROM_INDEXES, $value, false) ?: [];

        $properties = [];
        foreach ($value as $key => $val) {
            $properties[$key] = $this->valueObject(
                $val,
                in_array($key, $excludes)
            );
        }

        if (!$properties) {
            $properties = (object) $properties;
        }

        return [
            'entityValue' => [
                'properties' => $properties
            ]
        ];
    }
732661
public static function toArray($value)
    {
        if (is_array($value)) {
            return $value;
        }

        if ($value instanceof Collection) {
            return $value->all();
        }

        return [$value];
    }
928179
public function transform($value)
    {
        if (null === $value) {
            $value = $this->fieldType->getEmptyValue();
        }

        return array_merge(
            $this->getDefaultProperties(),
            ['alternativeText' => $value->alternativeText]
        );
    }
532203
public function createAttachments(array $value): array
    {
        return array_map(function ($data) {
            if ($data instanceof ResourceAttachment) {
                return $data;
            }

            return new ResourceAttachment((array) $data);
        }, $value);
    }
1100025
private function getValues($value)
    {
        if (is_array($value)) {
            $newValue = [];

            foreach ($value as $itemValue) {
                $newValue = array_merge($newValue, $this->getValues($itemValue));
            }

            return [$newValue];
        }

        $metadataFactory = $this->em->getMetadataFactory();
        $unitOfWork      = $this->em->getUnitOfWork();

        if (is_object($value) && $metadataFactory->hasMetadataFor(StaticClassNameConverter::getClass($value))) {
            $class     = $metadataFactory->getMetadataFor(get_class($value));
            $persister = $unitOfWork->getEntityPersister($class->getClassName());

            if ($class->isIdentifierComposite()) {
                $newValue = [];

                foreach ($persister->getIdentifier($value) as $innerValue) {
                    $newValue = array_merge($newValue, $this->getValues($innerValue));
                }

                return $newValue;
            }
        }

        return [$this->getIndividualValue($value)];
    }
500235
public function tags($value)
    {
        foreach ($this->candidates as $categorizer) {
            $result = $categorizer->tags($value);
            if ($result !== null) {
                return $result;
            }
        }

        return [];
    }