diff --git a/cms/contents/page/translations/sfs_cms_contents.en.yaml b/cms/contents/page/translations/sfs_cms_contents.en.yaml index 2e02beb0..65cc8884 100644 --- a/cms/contents/page/translations/sfs_cms_contents.en.yaml +++ b/cms/contents/page/translations/sfs_cms_contents.en.yaml @@ -263,6 +263,7 @@ admin_page: publishedAt.header: "Published at" filter_form: name.label: "Name" + path.label: "Path" sites.label: "Sites" status.label: "Status" publishedVersionContent.label: "Published version content (case sensitive)" diff --git a/cms/contents/page/translations/sfs_cms_contents.es.yaml b/cms/contents/page/translations/sfs_cms_contents.es.yaml index b5945f39..8c9b7165 100644 --- a/cms/contents/page/translations/sfs_cms_contents.es.yaml +++ b/cms/contents/page/translations/sfs_cms_contents.es.yaml @@ -263,6 +263,7 @@ admin_page: publishedAt.header: "Publicada" filter_form: name.label: "Nombre" + path.label: "Ruta" sites.label: "Sitios" status.label: "Estado" publishedVersionContent.label: "Contenido publicado (distingue mayúsculas y minúsculas)" diff --git a/src/Form/Admin/Content/ContentListFilterForm.php b/src/Form/Admin/Content/ContentListFilterForm.php index cb4cb1c9..7d3d7bb8 100644 --- a/src/Form/Admin/Content/ContentListFilterForm.php +++ b/src/Form/Admin/Content/ContentListFilterForm.php @@ -6,14 +6,16 @@ use Doctrine\ORM\QueryBuilder; use Softspring\CmsBundle\Config\CmsConfig; use Softspring\CmsBundle\Form\Admin\SiteChoiceType; +use Softspring\CmsBundle\Model\RoutePathInterface; use Softspring\Component\DoctrinePaginator\Form\PaginatorForm; +use Softspring\Component\DoctrinePaginator\Form\QueryBuilderProcessorInterface; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -class ContentListFilterForm extends PaginatorForm +class ContentListFilterForm extends PaginatorForm implements QueryBuilderProcessorInterface { protected CmsConfig $cmsConfig; @@ -58,6 +60,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'property_path' => '[name__like]', ]); + $builder->add('path', TextType::class, [ + 'required' => false, + 'property_path' => '[path__like]', + ]); + if (sizeof($this->cmsConfig->getSitesForContent($options['content_config']['_id'])) > 1) { $builder->add('sites', SiteChoiceType::class, [ 'required' => false, @@ -83,4 +90,28 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'property_path' => '[publishedVersion.data__like]', ]); } + + public function preProcessQueryBuilder(QueryBuilder $qb, array &$filters, array &$orderSort, int &$filtersMode): QueryBuilder + { + $pathFilter = trim((string) ($filters['path__like'] ?? '')); + unset($filters['path__like']); + + if ('' === $pathFilter) { + return $qb; + } + + $alias = $qb->getDQLPart('from')[0]->getAlias(); + $subQb = $this->em->createQueryBuilder(); + $subQb + ->select('1') + ->from(RoutePathInterface::class, 'routePath') + ->innerJoin('routePath.route', 'route') + ->where("route.content = $alias") + ->andWhere('(routePath.path LIKE :content_list_path OR routePath.compiledPath LIKE :content_list_path)'); + + $qb->andWhere($qb->expr()->exists($subQb->getDQL())); + $qb->setParameter('content_list_path', "%$pathFilter%"); + + return $qb; + } } diff --git a/templates/admin/content/list.html.twig b/templates/admin/content/list.html.twig index 69feaab0..d633a7f0 100644 --- a/templates/admin/content/list.html.twig +++ b/templates/admin/content/list.html.twig @@ -31,6 +31,7 @@