Neos\Flow\Aop\Builder\ClassNameIndex::applyUnion PHP Method

applyUnion() public method

Sets this index to all class names which are either already present or are contained in the given index
public applyUnion ( ClassNameIndex $classNameIndex ) : void
$classNameIndex ClassNameIndex
return void
    public function applyUnion(ClassNameIndex $classNameIndex)
    {
        if (count($this->classNames) > count($classNameIndex->classNames)) {
            foreach ($classNameIndex->classNames as $className => $value) {
                $this->classNames[$className] = true;
            }
        } else {
            $unionClassNames = $classNameIndex->classNames;
            foreach ($this->classNames as $className => $value) {
                $unionClassNames[$className] = true;
            }
            $this->classNames = $unionClassNames;
        }
    }

Usage Example

 /**
  * @test
  */
 public function applyUnionWorks()
 {
     $index1 = new Aop\Builder\ClassNameIndex();
     $index1->setClassNames(['\\Foo\\Bar', '\\Foo\\Baz']);
     $index2 = new Aop\Builder\ClassNameIndex();
     $index2->setClassNames(['\\Foo\\Baz', '\\Foo\\Blubb']);
     $index1->applyUnion($index2);
     $index1->sort();
     $this->assertEquals(['\\Foo\\Bar', '\\Foo\\Baz', '\\Foo\\Blubb'], $index1->getClassNames());
 }
All Usage Examples Of Neos\Flow\Aop\Builder\ClassNameIndex::applyUnion