Decorates result as resource item.

@param array $data
@param string $locale

@return ArrayAccessItem[]
185636
protected function decorateResourceItems(array $data, $locale)
    {
        return array_map(
            function($item) {
                $itemData = $this->serializer->serialize($item, 'array', $this->getSerializationContext());
                $id = $this->getIdForItem($item);

                if ($this->referenceStore) {
                    $this->referenceStore->add($id);
                }

                return new ArrayAccessItem($id, $itemData, $item);
            },
            $data
        );
    }
1077951
public function getByIds($ids, $locale)
    {
        if (!is_array($ids) || 0 === count($ids)) {
            return [];
        }

        $contacts = $this->contactRepository->findByIds($ids);

        return array_map(
            function($contact) use ($locale) {
                return $this->getApiObject($contact, $locale);
            },
            $contacts
        );
    }
1312260
public function getIsoFormats($locale = null)
    {
        return [
            'LT' => $this->getTranslationMessage('formats.LT', $locale, 'h:mm A'),
            'LTS' => $this->getTranslationMessage('formats.LTS', $locale, 'h:mm:ss A'),
            'L' => $this->getTranslationMessage('formats.L', $locale, 'MM/DD/YYYY'),
            'LL' => $this->getTranslationMessage('formats.LL', $locale, 'MMMM D, YYYY'),
            'LLL' => $this->getTranslationMessage('formats.LLL', $locale, 'MMMM D, YYYY h:mm A'),
            'LLLL' => $this->getTranslationMessage('formats.LLLL', $locale, 'dddd, MMMM D, YYYY h:mm A'),
        ];
    }
283264
public function getDefaultResourceForLocale( $locale )
    {
        $resource = null;

        if( $this->getValue() && !$this->getValue()->isEmpty() )
        {
            foreach( $this->getValue() as $index => $item )
            {
                if( $item->{$this->getModel()->getLocaleKey()} === $locale )
                {
                    $resource = $item;
                }
            }
        }

        return $resource;
    }
828680
private function decorateDataItems(array $data, $locale)
    {
        return array_map(
            function($item) use ($locale) {
                return new ContentDataItem($item, $this->getResource($item['uuid'], $locale));
            },
            $data
        );
    }
1069418
public function findByLocale(string $locale): ICollection
	{
		$builder = $this->builder()
			->innerJoin('_pages', '[_locales]', 'l', '_pages.localeId = l.id')
			->andWhere('[url] IS NOT NULL')
			->andWhere('[visible] = %i', 1)
			->andWhere('[l.name] = %s', $locale);
		return $this->toCollection($builder);
	}
858589
protected function processAttributes(array $data, ProductInterface $product, $locale)
    {
        if (isset($data['attributes'])) {
            // Create local array of all currently assigned attributes of product.
            $productAttributes = [];
            foreach ($product->getProductAttributes() as $productAttribute) {
                $productAttributes[$productAttribute->getAttribute()->getId()] = $productAttribute;
            }

            // Save all attribute ids which are given in the request.
            $attributeIdsInRequest = [];

            // Add and change attributes.
            foreach ($data['attributes'] as $attributeData) {
                if (!isset($attributeData['attributeId'])) {
                    continue;
                }

                $attributeId = $attributeData['attributeId'];
                $attributeIdsInRequest[$attributeId] = $attributeId;

                // Check if a attributeValueName is provided, otherwise do nothing.
                if (!array_key_exists('attributeValueName', $attributeData)) {
                    continue;
                }
                $attributeDataValueName = trim($attributeData['attributeValueName']);

                // Get attributeValueLocale from request.
                $attributeValueLocale = $locale;
                if (isset($attributeData['attributeValueLocale'])) {
                    $attributeValueLocale = $attributeData['attributeValueLocale'];
                }

                // If attribute value is empty do not add.
                if ('' === $attributeDataValueName || null === $attributeDataValueName) {
                    // If already set on product, remove attribute value translation.
                    if (array_key_exists($attributeId, $productAttributes)) {
                        /** @var ProductAttribute $productAttribute */
                        $productAttribute = $productAttributes[$attributeId];

                        // Remove attribute value translation from attribute value.
                        $this->productAttributeManager->removeAttributeValueTranslation(
                            $productAttribute->getAttributeValue(),
                            $attributeValueLocale
                        );

                        // If no more attribute value translation exists,
                        // remove the whole product attribute from the product.
                        if ($productAttribute->getAttributeValue()->getTranslations()->isEmpty()) {
                            $product->removeProductAttribute($productAttribute);
                            $this->em->remove($productAttribute);
                        }
                    }
                    continue;
                }

                // Product attribute does not exists.
                if (!array_key_exists($attributeId, $productAttributes)) {
                    $attribute = $this->retrieveAttributeById($attributeId);
                    // Create new attribute value with translation.
                    $attributeValue = $this->productAttributeManager->createAttributeValue(
                        $attribute,
                        $attributeDataValueName,
                        $attributeValueLocale
                    );
                    // Create new product attribute.
                    $this->productAttributeManager->createProductAttribute($attribute, $product, $attributeValue);
                } else {
                    // Product attribute exists.
                    /** @var ProductAttribute $productAttribute */
                    $productAttribute = $productAttributes[$attributeId];
                    $attributeValue = $productAttribute->getAttributeValue();
                    // Create translation in current locale.
                    $this->productAttributeManager->setOrCreateAttributeValueTranslation(
                        $attributeValue,
                        $attributeDataValueName,
                        $attributeValueLocale
                    );
                }
            }

            // Delete attributes.
            foreach ($productAttributes as $productAttribute) {
                if (!array_key_exists($productAttribute->getAttribute()->getId(), $attributeIdsInRequest)) {
                    // Remove all attribute value translations from attribute value.
                    $this->productAttributeManager->removeAllAttributeValueTranslations(
                        $productAttribute->getAttributeValue()
                    );

                    // Remove attribute from product.
                    $product->removeProductAttribute($productAttribute);
                    $this->em->remove($productAttribute);
                }
            }
        }
    }
868140
protected function _loadI18nStrings($locale) {
        $file = APPLICATION_PATH . '/data/i18n/' . $locale . '.php';
        if (!file_exists($file)) {
            throw new Exception('File not found: ' . $file);
        }
        ob_start();
        $data = include $file;
        ob_end_clean();
        return $data;
    }
1065387
protected static function getLocaleResourceFilepaths($locale)
    {
        $localePartDelimiters = ['-', '_'];
        $multipart = false;
        foreach ($localePartDelimiters as $delimiter) {
            $locale = explode($delimiter, $locale);
            if (1 !== count($locale)) {
                $multipart = true;
                break;
            }
            $locale = $locale[0];
        }
        if (!$multipart) {
            return [sprintf('%s/Lang/%s.php', __DIR__, $locale)];
        }
        $paths = [];
        foreach ($localePartDelimiters as $delimiter) {
            $paths[] = sprintf('%s/Lang/%s%s%s.php', __DIR__, $locale[0], $delimiter, $locale[1]);
        }

        return $paths;
    }
691361
public function getBrandingsWithLocale($locale)
    {
        $result = array();
        foreach ($this->brandings as $branding) {
            if ($branding->hasLocale($locale)) {
                $result[] = $branding;
            }
        }

        return $result;
    }
378862
private function withBuiltInTemplates(string $locale): ValidatorFactory
    {
        $templates = include(__DIR__ . '/../lang/' . $locale . '.php');

        return $this->withDefaultTemplates($templates);
    }
521437
public function getTerLocaleDependencies($locale) {
		$terLocale = isset($this->isoMapping[$locale])
				? $this->isoMapping[$locale]
				: $locale;
		return $this->convertToTerLocales($this->getLocaleDependencies($terLocale));
	}
1291193
protected function parseLocale($locale) {
        if (null == $locale) {
            return [$this->locale, $this->fallback];
        }

        return [$locale, $this->fallback];
    }
533857
public function findAll($locale)
    {
        $currencies = $this->currencyRepository->findAll();

        array_walk(
            $currencies,
            function (&$currency) use ($locale) {
                $currency = new Currency($currency, $locale);
            }
        );

        return $currencies;
    }
1078033
public function findAll($locale)
    {
        $statuses = $this->statusRepository->findAllByLocale($locale);

        array_walk(
            $statuses,
            function (&$status) use ($locale) {
                $status = new Status($status, $locale);
            }
        );

        return $statuses;
    }
291409
public function getStaticItems( string $locale = 'en_US', string $version = null ): StaticData\StaticItemListDto
	{
		$result = false;
		try
		{
			// Fetch StaticData from JSON files
			$result = DataDragonAPI::getStaticItems($locale, $version);
			if (!$result) throw new ServerException("StaticData failed to be loaded.");

			// Create missing data
			array_walk($result['data'], function (&$d, $k) {
				$d['id'] = $k;
			});

			$this->result_data = $result;
		}
		catch (DataDragonExceptions\SettingsException $ex)
		{
			throw new SettingsException("DataDragon API was not initialized properly! StaticData endpoints cannot be used.");
		}
		catch (DataDragonExceptions\ArgumentException $ex)
		{
			throw new RequestException($ex->getMessage(), $ex->getCode());
		}
		finally
		{
			// Parse array and create instances
			return new StaticData\StaticItemListDto($result, $this);
		}
	}
207662
protected function getUnits($locale)
    {
        /** @var Status[] $units */
        $units = $this->get('sulu_product.unit_manager')->findAll($locale);

        $unitTitles = [];
        foreach ($units as $unit) {
            $unitTitles[] = [
                'id' => $unit->getId(),
                'name' => $unit->getName(),
            ];
        }

        return $unitTitles;
    }