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

@return int

@throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
434569
protected function getAllChildrenCount(Location $location): int
    {
        $query = new LocationQuery([
            'filter' => new Criterion\Subtree($location->pathString),
        ]);

        $searchResults = $this->searchService->findLocations($query);

        return $searchResults->totalCount;
    }
1314623
public function setLocation( Location $location )
    {
        foreach ( $this->handlers as $handler )
        {
            if ( $handler instanceof LocationAwareHandlerInterface )
            {
                $handler->setLocation( $location );
            }
        }
    }
1350952
public function refreshLocation(Location $location)
    {

        $refreshedLocation = $this->findLocationBy(array('id' => $location->getId()));
        if (null === $refreshedLocation) {
            throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be reloaded.', $location->getId()));
        }
        return $refreshedLocation;
    }
1246786
public function id(): int
    {
        return app('cache.array')->rememberForever(__CLASS__ . __METHOD__ . $this->location_name, function () {
            // The "top-level" location won't exist in the database.
            if ($this->parts->isEmpty()) {
                return 0;
            }

            $parent_location_id = $this->parent()->id();

            $location_id = (int) DB::table('placelocation')
                ->where('pl_place', '=', $this->parts->first())
                ->where('pl_parent_id', '=', $parent_location_id)
                ->value('pl_id');

            if ($location_id === 0) {
                $location = $this->parts->first();

                $location_id = 1 + (int) DB::table('placelocation')->max('pl_id');

                DB::table('placelocation')->insert([
                    'pl_id'        => $location_id,
                    'pl_place'     => $location,
                    'pl_parent_id' => $parent_location_id,
                    'pl_level'     => $this->parts->count() - 1,
                    'pl_lati'      => '',
                    'pl_long'      => '',
                    'pl_icon'      => '',
                    'pl_zoom'      => 2,
                ]);
            }

            return $location_id;
        });
    }
820032
public function createLocation(Location $location): UIValue\Content\Location
    {
        return new UIValue\Content\Location($location, [
            'childCount' => $this->locationService->getLocationChildCount($location),
            'pathLocations' => $this->pathService->loadPathLocations($location),
            'userCanManage' => $this->permissionResolver->canUser(
                'content', 'manage_locations', $location->getContentInfo()
            ),
            'userCanRemove' => $this->permissionResolver->canUser(
                'content', 'remove', $location->getContentInfo(), [$location]
            ),
            'userCanEdit' => $this->permissionResolver->canUser(
                'content', 'edit', $location->getContentInfo(), [$location]
            ),
            'main' => $location->getContentInfo()->mainLocationId === $location->id,
        ]);
    }
1274770
public function getToken(Location $location = null)
    {
        if (!$location) {
            return $this->token;
        }

        $repository = $this->em->getRepository('CampaignChainSecurityAuthenticationClientOAuthBundle:Token');
        $token = $repository->findOneByLocation($location);

        if (!$token) {
            throw new \Exception(
                'No token found for location '.$location->getId()
            );
        }

        return $token;
    }
1212837
public function doGenerate($location, array $parameters)
    {
        $urlAliasService = $this->repository->getURLAliasService();

        $siteaccess = null;
        if (isset($parameters['siteaccess'])) {
            $siteaccess = $parameters['siteaccess'];
            unset($parameters['siteaccess']);
        }

        if ($siteaccess) {
            // We generate for a different SiteAccess, so potentially in a different language.
            $languages = $this->configResolver->getParameter('languages', null, $siteaccess);
            $urlAliases = $urlAliasService->listLocationAliases($location, false, null, null, $languages);
            // Use the target SiteAccess root location
            $rootLocationId = $this->configResolver->getParameter('content.tree_root.location_id', null, $siteaccess);
        } else {
            $languages = null;
            $urlAliases = $urlAliasService->listLocationAliases($location, false);
            $rootLocationId = $this->rootLocationId;
        }

        $queryString = '';
        unset($parameters['language'], $parameters['contentId']);
        if (!empty($parameters)) {
            $queryString = '?' . http_build_query($parameters, '', '&');
        }

        if (!empty($urlAliases)) {
            $path = $urlAliases[0]->path;
            // Remove rootLocation's prefix if needed.
            if ($rootLocationId !== null) {
                $pathPrefix = $this->getPathPrefixByRootLocationId($rootLocationId, $languages, $siteaccess);
                // "/" cannot be considered as a path prefix since it's root, so we ignore it.
                if ($pathPrefix !== '/' && ($path === $pathPrefix || mb_stripos($path, $pathPrefix . '/') === 0)) {
                    $path = mb_substr($path, mb_strlen($pathPrefix));
                } elseif ($pathPrefix !== '/' && !$this->isUriPrefixExcluded($path) && $this->logger !== null) {
                    // Location path is outside configured content tree and doesn't have an excluded prefix.
                    // This is most likely an error (from content edition or link generation logic).
                    $this->logger->warning("Generating a link to a location outside root content tree: '$path' is outside tree starting to location #$rootLocationId");
                }
            }
        } else {
            $path = $this->defaultRouter->generate(
                self::INTERNAL_CONTENT_VIEW_ROUTE,
                array('contentId' => $location->contentId, 'locationId' => $location->id)
            );
        }

        $path = $path ?: '/';

        // replace potentially unsafe characters with url-encoded counterpart
        return strtr($path . $queryString, $this->unsafeCharMap);
    }
506084
public function getHandler( Location $location )
    {
        if ( isset( $this->map[$location->contentInfo->remoteId] ) )
        {
            return $this->map[$location->contentInfo->remoteId];
        }

        return new NullHandler();
    }
661580
public function addChild(Location $location): void
    {
        if ($this->hasChild($location)) {
            throw new InvalidArgumentException(
                'The same Location cannot be added twice');
        }

        $location->setWarehouse(null);
        $location->setParent($this);

        $this->addTreeChild($location);
    }
856231
public function getHandler( Location $location )
    {
        $locationContentTypeId = $location->contentInfo->contentTypeId;

        /** @var ContentType $locationContentType */
        $locationContentType = $this->contentTypeService->loadContentType( $locationContentTypeId );

        return array_key_exists( $locationContentType->identifier, $this->map ) ?
            $this->map[$locationContentType->identifier] :
            new NullHandler();
    }
1305706
public function sendRedirect($location, $status = 302)
    {
        if (!is_int($status) || $status < 300 || $status > 399) {
            return;
        }
        
        if ($location[0] != '/' && !preg_match("/^[0-9a-z]+:\\/\\//i", $location)) {
            $location = $this->baseUrl . $location;
        }
        
        $this->clearHeaders();
        $this->addHeader('Location', $location, true);
        $this->setStatus($status);
        $this->isRedirect = true;
        $this->sendHeaders();
        
        exit();
    }
1351184
public function addLocation(Location $location): void
    {
        if ($this->locations->contains($location)) {
            throw new \InvalidArgumentException(
                    'The same Location cannot be added twice');
        }
        $location->setWarehouse($this);
        $this->locations->add($location);
    }
1144294
protected function storeContext($context, $location)
    {
        $cacheFile = $location . '/cache/apidoc.data';
        if (!is_dir($dir = dirname($cacheFile))) {
            mkdir($dir, 0777, true);
        }
        file_put_contents($cacheFile, serialize($context));
    }
510402
public function get($location)
    {
        curl_setopt($this->curl, CURLOPT_HTTPGET, true);

        return $this->execute('GET', $location);
    }
105766
public function setStorageLocation(\Concrete\Core\Entity\File\StorageLocation\StorageLocation $location)
    {
        $this->storageLocation = $location;
    }
622507
public function delete($location, $body = null)
    {
        curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, "DELETE");

        if ($body) {
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, $body);
        }

        return $this->execute('DELETE', $location);
    }
1272607
private function getLocationCounter($location)
    {
        $locationHash = md5(implode(',', $location));
        if (!isset($this->seenCounter[$locationHash])) {
            $this->seenCounter[$locationHash] = 0;
        } else {
            $this->seenCounter[$locationHash]++;
        }
        return $this->seenCounter[$locationHash];
    }