Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-30689

QueryType throws "No QueryType found with that name" exception

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: High High
    • 3.0.0, 3.0.0-beta4
    • 3.0.x-dev
    • None

    Description

      Trying to use a QueryType to render children of a Content items results in a "Argument 'QueryType name' is invalid: No QueryType found with that name" exception.

      (Note: steps based on https://doc.ezplatform.com/en/latest/cookbook/displaying_children_of_a_content_item/#using-the-query-controller but updated to 3.0)

      1. Create src/QueryType/LocationChildrenQueryType.php:

      namespace App\QueryType;
      
      use eZ\Publish\API\Repository\Values\Content\LocationQuery;
      use eZ\Publish\API\Repository\Values\Content\Query\Criterion\ParentLocationId;
      use eZ\Publish\Core\QueryType\QueryType;
      
      class LocationChildrenQueryType implements QueryType
      {
          public function getQuery(array $parameters = [])
          {
              return new LocationQuery([
                  'filter' => new ParentLocationId($parameters['parentLocationId']),
              ]);
          }
      
          public function getSupportedParameters()
          {
              return ['parentLocationId'];
          }
      
          public static function getName()
          {
              return 'LocationChildren';
          }
      }
      

      2. Add view config in ezplatform.yaml:

      folder:
          controller: ez_query:locationQueryAction
          template: full/folder.html.twig
          match:
              Identifier\ContentType: folder
          params:
              query:
                  query_type: LocationChildren
                  parameters:
                      parentLocationId: '@=location.id'
                  assign_results_to: items
      

      3. Add template in templates/full/folder.html.twig:

      <h1>{{ ez_content_name(content) }}</h1>
      
      {% for item in items.searchHits %}
        <h2><a href={{ path('ez_urlalias', {'contentId': item.valueObject.contentInfo.id}) }}>{{ ez_content_name(item.valueObject.contentInfo) }}</a></h2>
      {% endfor %}
      

      4. Preview any folder on the front office.

      Result: "Argument 'QueryType name' is invalid: No QueryType found with that name" exception is thrown

      Attachments

        Activity

          People

            Unassigned Unassigned
            dominika.kurek-obsolete@ibexa.co Dominika Kurek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: