@param StockItemInterface $item
@param Location           $location

@return array|StockUnit[]
339912
public function findByStockItem(
        StockItemInterface $item,
        ?BatchInterface $batch = null
    ): array {
        return array_filter(
            $this->findAll(),
            function ($su) use ($item) {
                return $su->getStockItem() == $item;
            }
        );
    }
1286313
public static function toResults(array $items) {

        $output = [];

        foreach ($items as $current) {

            if (false === ($current instanceof Select2ItemInterface)) {
                throw new InvalidArgumentException("The item must implements Select2ItemInterface");
            }

            $output[] = [
                "id"   => $current->getSelect2ItemId(),
                "text" => $current->getSelect2ItemText(),
            ];
        }

        return $output;
    }
662616
public static function convertLocationCoordinates(Location $location)
    {
        $coordinates = $location->getCoordinates()->getCoordinates();
        $coordinate = doubleval($coordinates[1]) . '%' . doubleval($coordinates[0]);
        $coordinate = strtr($coordinate, [
            '%'=>',',
            ','=>'.'
        ]);
        return $coordinate;
    }
953513
public function loadPathLocations(Location $location)
    {
        $locationQuery = new LocationQuery([
            'filter' => new Ancestor($location->pathString),
            'sortClauses' => [new Path()],
        ]);

        $searchResult = $this->searchService->findLocations($locationQuery);

        return array_map(function (SearchHit $searchHit) {
            return $searchHit->valueObject;
        }, $searchResult->searchHits);
    }
1221145
public function getReservedQty(StockItemInterface $item): UomQty
    {
        $units = $this->stockUnitRepository
            ->findReservedByStockItem($item);

        return $this->computeQtyForUnits($item->getUom(), $units);
    }
363543
protected function buildTrashItem(Location $location)
    {
        return new TrashItem(
            array(
                'contentInfo' => $location->contentInfo,
                'id' => $location->id,
                'priority' => $location->priority,
                'hidden' => $location->hidden,
                'invisible' => $location->invisible,
                'remoteId' => $location->remoteId,
                'parentLocationId' => $location->parentLocationId,
                'pathString' => $location->pathString,
                'depth' => (int)$location->depth,
                'sortField' => $location->sortField,
                'sortOrder' => $location->sortOrder,
            )
        );
    }
1225461
public function getAvailableQty(StockItemInterface $item): UomQty
    {
        $units = $this->stockUnitRepository
            ->findAvailableByStockItem($item);

        return $this->computeQtyForUnits($item->getUom(), $units);
    }
718351
private function order($position, $item)
    {
        $category = $this->categoryRepository->find($item['id']);
        $this->savePosition($category, $position);
        $this->makeItemChildOf($category, null);

        if ($this->hasChildren($item)) {
            $this->handleChildrenForParent($category, $item['children']);
        }
    }
538483
protected function formatItem(string $type, $item): array
    {
        $formattedItem = [];

        if ('route' === $type) {
            return [
            'item_name' => $item,
            ];
        }

        $model = $item['model'];
        $formattedItem['item_name'] = $model;
        if (is_object($model)) {
            $formattedItem['item'] = $model;
            $formattedItem['item_name'] = get_class($model);
        }
        if ('field' === $type) {
            $formattedItem['item_name'] .= ":{$item['field']}";
        }

        return $formattedItem;
    }
1351983
public function portfolioItemsAction($locationId)
    {
        $criteria = array(
            new Criterion\ParentLocationId($locationId),
            new Criterion\Visibility(Criterion\Visibility::VISIBLE),
            new Criterion\ContentTypeIdentifier(array('image')),
        );

        $query = new Query(
            array(
                'criterion' => new Criterion\LogicalAnd(
                    $criteria
                ),
            )
        );

        $searchHits = $this->getRepository()->getSearchService()->findContent($query)->searchHits;

        $itemsArray = array();
        foreach ($searchHits as $searchHit) {
            $content = $searchHit->valueObject;
            $itemsArray[] = $content;
        }

        return $this->render(
            'YuzuPipelineBundle:portfolio:sub_items.html.twig',
            array(
                'items' => $itemsArray,
            )
        );
    }
1142188
public function createLocationMenuItem(string $name, int $locationId, array $options = []): ?ItemInterface
    {
        try {
            $location = $this->locationService->loadLocation($locationId);
            $contentInfo = $location->getContentInfo();
            $canRead = $this->permissionResolver->canUser('content', 'read', $contentInfo);
        } catch (\Exception $e) {
            return null;
        }

        $defaults = [
            'route' => '_ezpublishLocation',
            'routeParameters' => [
                'locationId' => $locationId,
            ],
        ];

        return $this->createItem($name, array_merge_recursive($defaults, $options));
    }
1178092
protected static function parseLocation($location)
	{
		if (is_string($location))
		{
			$locationName  = self::getMountNameFromPath($location);
			$locationMount = self::findMountByName($locationName);
		}
		else
		{
			$locationName  = uniqid('', true);
			$locationMount = $location->getAdapter();
			$location      = $locationName . '://' . $location->getPath();
		}

		return [$location, $locationName, $locationMount];
	}
867214
public function addItemInstance(Nodes\NodeInterface $item, $location = null)
	{
		$location = (int) $location;

		$this->items[$location][] = $item;

		if ($id = $item->getId()) {
			$this->ids[$id] = $item;
		}

		return $item;
	}
1145174
private function normalizeLocationData(LocationData $locationData)
    {
        return [
            'id' => $locationData->getId(),
            'name' => $locationData->getName(),
            'code' => $locationData->getCode(),
            'type' => $locationData->getType(),
        ];
    }
870454
public function getMenuEntries($location = null)
    {
        $runtimeManager = $this->framework->getRuntimeManager();

        // Give the modules the opportunity to add additional menu entries
        $runtimeManager->executeEvent('\\Zepi\\Web\\General\\Event\\MenuManager\\RegisterAdditionalMenuEntries');
        
        if ($location === null) {
            return $this->menuEntries;
        }
        
        // If this location does not exists, return an empty array
        if (!isset($this->menuEntries[$location])) {
            return array();
        }
        
        // Execute the event
        $menuEntries = $runtimeManager->executeFilter('\\Zepi\\Web\\General\\Filter\\MenuManager\\FilterMenuEntries', $this->menuEntries[$location]);
        
        return $menuEntries;
    }
333028
public static function getStaticItem( int $item_id, string $locale = 'en_US', string $version = null ) : array
	{
		$data = self::getStaticItems($locale, $version);
		if (isset($data['data'][$item_id]) == false)
			throw new ArgumentException('Item with given ID was not found.', 404);

		return $data['data'][$item_id];
	}
1037264
public function findByOrderId($orderId, $locale)
    {
        $result = array();
        $items = $this->getShippingRepository()->findByOrderId($orderId, $locale);
        foreach ($items as $item) {
            $result[] = $this->shippingFactory->createApiEntity($item, $locale);
        }
        return $result;
    }