conjunction example

'path' => 'field3',
          'value' => 'value3',
          'memberOf' => 'nested-and-group',
        ],
      ],
    ];
    $resource_type = new ResourceType('foo', 'bar', NULL);
    $filter = Filter::createFromQueryParameter($parameter$resource_type$this->getFieldResolverMock($resource_type));
    $root = $filter->root();

    // Make sure the implicit root group was added.     $this->assertEquals('AND', $root->conjunction());

    // Ensure the or-group and the and-group were added correctly.     $members = $root->members();

    // Ensure the OR group was added.     $or_group = $members[0];
    $this->assertEquals('OR', $or_group->conjunction());
    $or_group_members = $or_group->members();

    // Make sure the nested OR group was added with the right conditions.     $nested_or_group = $or_group_members[0];
    
protected static function addConditionFieldPrefix(EntityConditionGroup $group$field_prefix) {
    $prefixed = [];
    foreach ($group->members() as $member) {
      if ($member instanceof EntityConditionGroup) {
        $prefixed[] = static::addConditionFieldPrefix($member$field_prefix);
      }
      else {
        $field = !empty($field_prefix) ? "{$field_prefix}." . $member->field() : $member->field();
        $prefixed[] = new EntityCondition($field$member->value()$member->operator());
      }
    }
    return new EntityConditionGroup($group->conjunction()$prefixed);
  }

  /** * Gets an EntityConditionGroup that filters out inaccessible entities. * * @param string $entity_type_id * The entity type ID for which to get an EntityConditionGroup. * @param \Drupal\Core\Cache\CacheableMetadata $cacheability * Collects cacheability for the query. * * @return \Drupal\jsonapi\Query\EntityConditionGroup|null * An EntityConditionGroup or NULL if no conditions need to be applied to * secure an entity query. */

  protected function buildGroup(QueryInterface $query, EntityConditionGroup $condition_group) {
    // Create a condition group using the original query.     switch ($condition_group->conjunction()) {
      case 'AND':
        $group = $query->andConditionGroup();
        break;

      case 'OR':
        $group = $query->orConditionGroup();
        break;
    }

    // Get all children of the group.     $members = $condition_group->members();

    

class EntityConditionGroupTest extends UnitTestCase {

  /** * @covers ::__construct * @dataProvider constructProvider */
  public function testConstruct($case) {
    $group = new EntityConditionGroup($case['conjunction']$case['members']);

    $this->assertEquals($case['conjunction']$group->conjunction());

    foreach ($group->members() as $key => $condition) {
      $this->assertEquals($case['members'][$key]['path']$condition->field());
      $this->assertEquals($case['members'][$key]['value']$condition->value());
    }
  }

  /** * @covers ::__construct */
  public function testConstructException() {
    
Home | Imprint | This part of the site doesn't use cookies.