@param $contentInfo
@param \eZ\Publish\API\Repository\Values\Content\Location $location

@return \Symfony\Component\Form\FormInterface
501252
protected function createLocationUpdateMainForm($contentInfo, Location $location): FormInterface
    {
        return $this->formFactory->updateContentMainLocation(
            new ContentMainLocationUpdateData($contentInfo, $location)
        );
    }
808969
private function addTrashAssetField(FormInterface $form, Location $location = null): void
    {
        if ($location === null) {
            return;
        }

        $contentType = $this->contentTypeService->loadContentType(
            $location->getContentInfo()->contentTypeId
        );

        $translatorParameters = [
            '%content_name%' => $location->getContent()->getName(),
            '%content_type%' => $contentType->getName(
                $location->getContentInfo()->mainLanguageCode
            ),
        ];

        $form->add('trashAssets', ChoiceType::class, [
            'expanded' => true,
            'multiple' => false,
            'choices' => [
                /** @Desc("Delete only %content_name% (%content_type%)") */
                $this->translator->trans('location_trash_form.default_trash', $translatorParameters, 'forms') => LocationTrashWithAssetType::RADIO_SELECT_DEFAULT_TRASH,
                /** @Desc("Delete %content_name% (%content_type%) and its related image assets") */
                $this->translator->trans('location_trash_form.trash_with_asset', $translatorParameters, 'forms') => LocationTrashWithAssetType::RADIO_SELECT_TRASH_WITH_ASSETS,
            ],
        ]);
    }
1333145
public function addSiteMap($location, $lastModification = null)
    {
        $sitemapElement = $this->createElement('sitemap');

        if (0 === strpos($location, '/')) {
            $location = $this->baseUri.$location;
        }
        $locElement = $this->createElement('loc');
        $locElement->appendChild($this->createTextNode($location));
        $sitemapElement->appendChild($locElement);

        if (null !== $lastModification) {
            if ($lastModification instanceof \DateTime) {
                $lastModification = $lastModification->format('c');
            } else {
                if (is_string($lastModification)) {
                    $lastModification = strtotime($lastModification);
                }
                $lastModification = date('c', $lastModification);
            }

            $lastmodElement = $this->createElement('lastmod');
            $lastmodElement->appendChild($this->createTextNode($lastModification));
            $sitemapElement->appendChild($lastmodElement);
        }

        $this->root->appendChild($sitemapElement);

        return $this;
    }
1255641
public function loadLocationDataByContent($contentId, $rootLocationId = null)
    {
        $query = $this->handler->createSelectQuery();
        $query
            ->select('*')
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
            ->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('contentobject_id'),
                    $query->bindValue($contentId)
                )
            );

        if ($rootLocationId !== null) {
            $this->applySubtreeLimitation($query, $rootLocationId);
        }

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
1231755
public static function to($location, $data = null)
    {
        $location = ($location === '/') ? URL : URL . $location;

        $c = ($data) ? '?twigformfields='.base64_encode(json_encode($data)) : null;
        header('Location: ' . $location . $c);
        exit;
    }
506084
public function getHandler( Location $location )
    {
        if ( isset( $this->map[$location->contentInfo->remoteId] ) )
        {
            return $this->map[$location->contentInfo->remoteId];
        }

        return new NullHandler();
    }
1088575
public function matchContentInfo(ContentInfo $contentInfo)
    {
        $contentType = $this->repository
            ->getContentTypeService()
            ->loadContentType($contentInfo->contentTypeId);

        return isset($this->values[$contentType->identifier]);
    }
1189150
private function createRestLocation(Location $location): RestLocation
    {
        return new RestLocation(
            $location,
            $this->locationService->getLocationChildCount($location)
        );
    }
412362
private function loadParentLocations(ContentInfo $contentInfo)
    {
        $locations = $this->persistence->locationHandler()->loadLocationsByContent($contentInfo->id);
        $parentLocations = [];
        foreach ($locations as $location) {
            if ($location->depth > 0) {
                $parentLocations[] = $this->persistence->locationHandler()->load($location->parentId);
            }
        }

        return $parentLocations;
    }
1064210
public function getFacts(Location $location, $percent = false)
    {
        $qb = $this->em->createQueryBuilder();
        $qb->select('r.time, r.value, IDENTITY(r.metric) as metric')
            ->from('CampaignChain\CoreBundle\Entity\ReportAnalyticsLocationFact', 'r')
            ->where('r.location = :locationId')
            ->orderBy('r.time', 'ASC')
            ->setParameter('locationId', $location->getId());

        $query = $qb->getQuery();
        $facts = $query->getArrayResult();

        $factsData = [];
        $tmp = [];
        foreach ($facts as $fact) {
            $tmp[$fact['metric']][] = [
                $fact['time']->getTimestamp() * 1000,
                $fact['value'],
            ];
        }

        foreach (array_keys($tmp) as $k) {
            $factsData[$k]['data'] = $this->serializer->serialize($tmp[$k], 'json');
            $factsData[$k]['id'] = $k;
//            if ($percent) {
//                $factsData[$k]['percent'] = $this->getDimensionPercent($campaign, $activity, $k);
//            }
        }

        return $factsData;
    }
823674
public function createLocation(string $location, string $match = null) : Location
    {
        return new Location(new Param($location), is_null($match) ? null : new Param($match));
    }
998547
public function load(ContentInfo $contentInfo): self
    {
        $this->data = array_map(
            [$this->valueFactory, 'createLocation'],
            $this->locationService->loadLocations($contentInfo)
        );
        $this->data = $this->prioritizeMainLocation($this->data);

        return $this;
    }
862117
public function addLocation(\CampaignChain\CoreBundle\Entity\Location $location)
    {
        $this->locations[] = $location;

        return $this;
    }
460051
function createContentDraft($parentLocationId, $contentTypeIdentifier, $fields, $languageCode = null )
    {
        $languageCode = $languageCode ?: self::DEFAULT_LANGUAGE;

        $repository = $this->getRepository();
        $content = $repository->sudo(
            function() use( $repository, $languageCode, $contentTypeIdentifier, $fields, $parentLocationId )
            {
                $contentService = $repository->getcontentService();
                $contentTypeService = $repository->getContentTypeService();
                $locationCreateStruct = $repository->getLocationService()->newLocationCreateStruct( $parentLocationId );

                $contentTypeIdentifier = $contentTypeService->loadContentTypeByIdentifier( $contentTypeIdentifier );
                $contentCreateStruct = $contentService->newContentCreateStruct( $contentTypeIdentifier, $languageCode );
                foreach ( array_keys( $fields ) as $key ) {
                    $contentCreateStruct->setField( $key, $fields[$key] );
                }
                return $contentService->createContent( $contentCreateStruct, array( $locationCreateStruct ) );
            }
        );

        $this->addObjectToList( $content );

        return $content;
    }
246022
private function addTrashContainerField(FormInterface $form, Location $location = null): void
    {
        if (null === $location) {
            return;
        }

        $isContainer = new IsContainer();
        $hasChildren = new HasChildren($this->locationService);

        if (!$isContainer->and($hasChildren)->isSatisfiedBy($location)) {
            return;
        }

        $locationChildren = $this->locationService->loadLocationChildren($location);

        $translatorParameters = [
            '%children_count%' => $locationChildren->totalCount,
            '%content_name%' => $location->getContent()->getName(),
        ];

        $form->add('trashContainer', ChoiceType::class, [
            'expanded' => true,
            'multiple' => true,
            'choices' => [
                /** @Desc("%children_count% content items under location %content_name%") */
                $this->translator->trans('location_trash_form.trash_container', $translatorParameters, 'forms') => self::TRASH_WITH_CHILDREN,
            ],
        ]);
    }
1281641
private function processLocations(array $locations, ProgressBar $progressBar)
    {
        $contentList = $this->repository->sudo(
            function (Repository $repository) use ($locations) {
                $contentInfoList = array_map(
                    function (Location $location) {
                        return $location->contentInfo;
                    },
                    $locations
                );

                // load Content list in all languages
                return $repository->getContentService()->loadContentListByContentInfo(
                    $contentInfoList,
                    Language::ALL,
                    false
                );
            }
        );
        foreach ($locations as $location) {
            try {
                // ignore missing Content items
                if (!isset($contentList[$location->contentId])) {
                    continue;
                }

                $content = $contentList[$location->contentId];
                $this->repository->sudo(
                    function (Repository $repository) use ($location, $content) {
                        $repository->getURLAliasService()->refreshSystemUrlAliasesForLocation(
                            $location
                        );
                    }
                );
            } catch (Exception $e) {
                $contentInfo = $location->getContentInfo();
                $msg = sprintf(
                    'Failed processing location %d - [%d] %s (%s: %s)',
                    $location->id,
                    $contentInfo->id,
                    $contentInfo->name,
                    get_class($e),
                    $e->getMessage()
                );
                $this->logger->warning($msg);
                // in debug mode log full exception with a trace
                $this->logger->debug($e);
            } finally {
                $progressBar->advance(1);
            }
        }
    }
961762
public static function build($location, $required, $description)
    {
        $param = new static();
        $param->location = $location;
        $param->required = $required;
        $param->description = $description;

        return $param;
    }