Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bundle/Controller/LocationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function swapAction(Request $request): Response
$currentLocation = $data->getCurrentLocation();
$newLocation = $data->getNewLocation();

$childCount = $this->locationService->getLocationChildCount($currentLocation);
$childCount = $this->locationService->getLocationChildCount($currentLocation, 1);
$contentType = $newLocation->getContent()->getContentType();

if (!$contentType->isContainer && $childCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,23 @@ class SubtreeOperations extends AbstractParser
/**
* @inheritdoc
*/
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void
public function mapConfig(array & $scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void
{
if (!isset($scopeSettings['subtree_operations']['copy_subtree']['limit'])) {
return;
if (isset($scopeSettings['subtree_operations']['copy_subtree']['limit'])) {
$contextualizer->setContextualParameter(
'subtree_operations.copy_subtree.limit',
$currentScope,
$scopeSettings['subtree_operations']['copy_subtree']['limit']
);
}

$contextualizer->setContextualParameter(
'subtree_operations.copy_subtree.limit',
$currentScope,
$scopeSettings['subtree_operations']['copy_subtree']['limit']
);
if (isset($scopeSettings['subtree_operations']['query_subtree']['limit'])) {
$contextualizer->setContextualParameter(
'subtree_operations.query_subtree.limit',
$currentScope,
$scopeSettings['subtree_operations']['query_subtree']['limit']
);
}
}

public function addSemanticConfig(NodeBuilder $nodeBuilder): void
Expand All @@ -57,6 +63,14 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void
->end()
->end()
->end()
->arrayNode('query_subtree')
->children()
->integerNode('limit')
->info('Limit the total count of items queried for when calculating the the number of direct children a node has. -1 for no limit. Default is 500 for performance reasons.')
->defaultValue(500)
->isRequired()
->end()
->end()
->end()
->end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ parameters:

# Subtree Operations
ezsettings.admin_group.subtree_operations.copy_subtree.limit: 100
ezsettings.admin_group.subtree_operations.query_subtree.limit: 500

# Notifications
ezsettings.admin_group.notifications.error.timeout: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<td class="ez-table__cell">
{% include '@ezdesign/ui/location_path.html.twig' with {'locations': location.pathLocations, 'link_last_element': true} %}
</td>
<td class="ez-table__cell">{{ location.childCount }}</td>
<td class="ez-table__cell">{% if sub_item_query_limit is not null and location.childCount > sub_item_query_limit %}{{ location.childCount -1 }}+{% else %}{{location.childCount}}{% endif %}</td>
<td class="ez-table__cell">
<label class="ez-checkbox-icon {{ not location.explicitlyHidden ? 'is-checked' }}{% if not can_hide[location.id] %} disabled{% endif %}"
title="{{ 'tab.locations.visibility'|trans|desc('Visibility') }}">
Expand Down
16 changes: 13 additions & 3 deletions src/lib/Form/TrashLocationOptionProvider/HasChildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use eZ\Publish\API\Repository\LocationService;
use eZ\Publish\API\Repository\Values\Content\Location;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use EzSystems\EzPlatformAdminUi\Specification\Location\HasChildren as HasChildrenSpec;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
Expand All @@ -23,10 +24,14 @@ final class HasChildren implements TrashLocationOptionProvider
/** @var \Symfony\Contracts\Translation\TranslatorInterface */
private $translator;

public function __construct(LocationService $locationService, TranslatorInterface $translator)
/** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */
private $configResolver;

public function __construct(LocationService $locationService, TranslatorInterface $translator, ConfigResolverInterface $configResolver)
{
$this->locationService = $locationService;
$this->translator = $translator;
$this->configResolver = $configResolver;
}

public function supports(Location $location): bool
Expand All @@ -36,10 +41,15 @@ public function supports(Location $location): bool

public function addOptions(FormInterface $form, Location $location): void
{
$childCount = $this->locationService->getLocationChildCount($location);
$limit = $this->configResolver->getParameter('subtree_operations.query_subtree.limit');

$useLimit = $limit > 0;
$childCount = $this->locationService->getLocationChildCount($location, $useLimit ? $limit + 1 : null);

$translatorParameters = [
'%children_count%' => $childCount,
'%children_count%' => ($useLimit && $childCount >= $limit) ?
sprintf('%d+', $limit) :
$childCount,
'%content_name%' => $location->getContent()->getName(),
];

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Specification/Location/HasChildren.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(LocationService $locationService)
*/
public function isSatisfiedBy($item): bool
{
$childCount = $this->locationService->getLocationChildCount($item);
$childCount = $this->locationService->getLocationChildCount($item, 1);

return 0 < $childCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function isSatisfiedBy($item): bool
return false;
}

return $this->copyLimit >= $this->locationService->getSubtreeSize($item);
return $this->copyLimit >= $this->locationService->getSubtreeSize($item, $this->copyLimit + 1);
}

private function isContainer(Location $location): bool
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Tab/LocationView/LocationsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,18 @@ public function getTemplateParameters(array $contextParameters = []): array
);
}

$subItemQueryLimit = $this->configResolver->getParameter('subtree_operations.query_subtree.limit');
if ($subItemQueryLimit <= 0) {
$subItemQueryLimit = null;
}

$viewParameters = [
'pager' => $pagination,
'pager_options' => [
'pageParameter' => sprintf('[%s]', self::PAGINATION_PARAM_NAME),
],
'locations' => $locations,
'sub_item_query_limit' => $subItemQueryLimit,
'form_content_location_add' => $formLocationAdd->createView(),
'form_content_location_remove' => $formLocationRemove->createView(),
'form_content_location_swap' => $formLocationSwap->createView(),
Expand Down
15 changes: 13 additions & 2 deletions src/lib/UI/Module/Subitems/ContentViewParameterSupplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\Location;
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use eZ\Publish\Core\MVC\Symfony\View\ContentView;
use eZ\Publish\Core\Query\QueryFactoryInterface;
use EzSystems\EzPlatformAdminUi\UI\Config\Provider\ContentTypeMappings;
Expand Down Expand Up @@ -71,6 +72,9 @@ class ContentViewParameterSupplier
/** @var \eZ\Publish\API\Repository\SearchService */
private $searchService;

/** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */
private $configResolver;

public function __construct(
Visitor $outputVisitor,
JsonOutputGenerator $outputGenerator,
Expand All @@ -83,7 +87,8 @@ public function __construct(
ContentTypeMappings $contentTypeMappings,
UserSettingService $userSettingService,
QueryFactoryInterface $queryFactory,
SearchService $searchService
SearchService $searchService,
ConfigResolverInterface $configResolver
) {
$this->outputVisitor = $outputVisitor;
$this->outputGenerator = $outputGenerator;
Expand All @@ -97,6 +102,7 @@ public function __construct(
$this->userSettingService = $userSettingService;
$this->queryFactory = $queryFactory;
$this->searchService = $searchService;
$this->configResolver = $configResolver;
}

/**
Expand Down Expand Up @@ -187,7 +193,12 @@ private function createRestLocation(Location $location): RestLocation
{
return new RestLocation(
$location,
$this->locationService->getLocationChildCount($location)
$this->locationService->getLocationChildCount(
$location,
// For the sub items module we only ever use the count to determine if there are children (0 or 1+),
// hence setting a limit of 1 is sufficient here.
1
)
);
}

Expand Down
13 changes: 11 additions & 2 deletions src/lib/UI/Value/ValueFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup;
use eZ\Publish\API\Repository\Values\User\Policy;
use eZ\Publish\API\Repository\Values\User\RoleAssignment;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use eZ\Publish\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface;
use eZ\Publish\Core\Repository\LocationResolver\LocationResolver;
use eZ\Publish\SPI\Limitation\Target;
Expand Down Expand Up @@ -74,6 +75,9 @@ class ValueFactory
/** @var \eZ\Publish\Core\Repository\LocationResolver\LocationResolver */
protected $locationResolver;

/** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */
protected $configResolver;

/**
* @param \eZ\Publish\API\Repository\UserService $userService
* @param \eZ\Publish\API\Repository\LanguageService $languageService
Expand All @@ -86,6 +90,7 @@ class ValueFactory
* @param \EzSystems\EzPlatformAdminUi\UI\Dataset\DatasetFactory $datasetFactory
* @param \eZ\Publish\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider
* @param \eZ\Publish\Core\Repository\LocationResolver\LocationResolver $locationResolver
* @param \eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver
*/
public function __construct(
UserService $userService,
Expand All @@ -98,7 +103,8 @@ public function __construct(
PathService $pathService,
DatasetFactory $datasetFactory,
UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider,
LocationResolver $locationResolver
LocationResolver $locationResolver,
ConfigResolverInterface $configResolver
) {
$this->userService = $userService;
$this->languageService = $languageService;
Expand All @@ -111,6 +117,7 @@ public function __construct(
$this->datasetFactory = $datasetFactory;
$this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider;
$this->locationResolver = $locationResolver;
$this->configResolver = $configResolver;
}

/**
Expand Down Expand Up @@ -235,9 +242,11 @@ public function createLocation(Location $location): UIValue\Content\Location
{
$translations = $location->getContent()->getVersionInfo()->languageCodes;
$target = (new Target\Version())->deleteTranslations($translations);
$limit = $this->configResolver->getParameter('subtree_operations.query_subtree.limit');
$useLimit = $limit > 0;

return new UIValue\Content\Location($location, [
'childCount' => $this->locationService->getLocationChildCount($location),
'childCount' => $this->locationService->getLocationChildCount($location, $useLimit ? $limit + 1 : null),
'pathLocations' => $this->pathService->loadPathLocations($location),
'userCanManage' => $this->permissionResolver->canUser(
'content', 'manage_locations', $location->getContentInfo()
Expand Down
Loading