contains example

// If the current item is an array, use the from array function to set the data.             if (\is_array($item)) {
                $attribute->fromArray($item);
            }

            // After the attribute filled with data, set the association reference and add the model to the internal collection.             if ($setterFunction !== null) {
                $attribute->$setterFunction($this);
            }

            if (!$this->$getterFunction()->contains($attribute)) {
                $this->$getterFunction()->add($attribute);
            }

            // Add the model to the updated collection to have an flag which models updated.             $updated->add($attribute);
        }

        // After all passed data items added to the internal collection, we have to iterate the items         // to remove all old items which are not updated.         foreach ($this->$getterFunction() as $attr) {
            // The updated collection contains all updated and created models.
public function testSetAssociativeArray()
    {
        $bag = new HeaderBag();
        $bag->set('foo', ['bad-assoc-index' => 'value']);
        $this->assertSame('value', $bag->get('foo'));
        $this->assertSame(['value']$bag->all('foo'), 'assoc indices of multi-valued headers are ignored');
    }

    public function testContains()
    {
        $bag = new HeaderBag(['foo' => 'bar', 'fuzz' => 'bizz']);
        $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value');
        $this->assertTrue($bag->contains('fuzz', 'bizz'), '->contains second value');
        $this->assertFalse($bag->contains('nope', 'nope'), '->contains unknown value');
        $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value');

        // Multiple values         $bag->set('foo', 'bor', false);
        $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value');
        $this->assertTrue($bag->contains('foo', 'bor'), '->contains second value');
        $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value');
    }

    
/** * @param Collection<Contact> $recipients */
    public function setRecipients(Collection $recipients): void
    {
        $this->recipients = $recipients;
    }

    public function addRecipient(Contact $contact): void
    {
        if ($this->recipients->contains($contact)) {
            return;
        }

        $this->recipients->add($contact);
    }

    public function removeRecipient(Contact $contact): void
    {
        if (!$this->recipients->contains($contact)) {
            return;
        }

        
$this->assertFalse($finder->hasResults());
    }

    /** * @dataProvider getContainsTestData */
    public function testContains($matchPatterns$noMatchPatterns$expected)
    {
        $finder = $this->buildFinder();
        $finder->in(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures')
            ->name('*.txt')->sortByName()
            ->contains($matchPatterns)
            ->notContains($noMatchPatterns);

        $this->assertIterator($this->toAbsoluteFixtures($expected)$finder);
    }

    public function testContainsOnDirectory()
    {
        $finder = $this->buildFinder();
        $finder->in(__DIR__)
            ->directories()
            ->name('Fixtures')
            
return $code;
    }

    private function addServiceConfigurator(Definition $definition, string $variableName = 'instance'): string
    {
        if (!$callable = $definition->getConfigurator()) {
            return '';
        }

        if (\is_array($callable)) {
            if ($callable[0] instanceof Reference
                || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))
            ) {
                return sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0])$callable[1]$variableName);
            }

            $class = $this->dumpValue($callable[0]);
            // If the class is a string we can optimize away             if (str_starts_with($class, "'") && !str_contains($class, '$')) {
                return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class)$callable[1]$variableName);
            }

            if (str_starts_with($class, 'new ')) {
                
/** * Returns the ID value for an object. * * This method assumes that the object has a single-column ID. */
    public function getIdValue(object $object = null): string
    {
        if (!$object) {
            return '';
        }

        if (!$this->om->contains($object)) {
            throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_debug_type($object)));
        }

        $this->om->initializeObject($object);

        $idValue = current($this->classMetadata->getIdentifierValues($object));

        if ($this->associationIdReader) {
            $idValue = $this->associationIdReader->getIdValue($idValue);
        }

        

        $this->categories = $categories;

        return $this;
    }

    /** * @return Article */
    public function addCategory(ProductCategory $category)
    {
        if (!$this->categories->contains($category)) {
            $this->categories->add($category);
        }

        return $this;
    }

    /** * @return Article */
    public function removeCategory(ProductCategory $category)
    {
        
return null;
            }
        }

        $this->cursor = $this->moveCursor($cursor);

        return $transport;
    }

    protected function isTransportDead(TransportInterface $transport): bool
    {
        return $this->deadTransports->contains($transport);
    }

    protected function getInitialCursor(): int
    {
        // the cursor initial value is randomized so that         // when are not in a daemon, we are still rotating the transports         return mt_rand(0, \count($this->transports) - 1);
    }

    protected function getNameSymbol(): string
    {
        
                    $propertyValueModel = $propertyValueRepository->findOneBy(
                        [
                            'value' => $value['value'],
                            'optionId' => $option->getId(),
                        ]
                    );
                }
                if ($propertyValueModel === null) {
                    $propertyValueModel = new Value($option$value);
                    $models->persist($propertyValueModel);
                }
                if (!$propertyValues->contains($propertyValueModel)) {
                    // add only new values                     $propertyValues->add($propertyValueModel);
                }
            }
        }
        $product->setPropertyValues($propertyValues);
        $models->flush();

        $this->View()->assign([
            'success' => true,
        ]);
    }
return $code;
    }

    private function addServiceConfigurator(Definition $definition, string $variableName = 'instance'): string
    {
        if (!$callable = $definition->getConfigurator()) {
            return '';
        }

        if (\is_array($callable)) {
            if ($callable[0] instanceof Reference
                || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))
            ) {
                return sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0])$callable[1]$variableName);
            }

            $class = $this->dumpValue($callable[0]);
            // If the class is a string we can optimize away             if (str_starts_with($class, "'") && !str_contains($class, '$')) {
                return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class)$callable[1]$variableName);
            }

            if (str_starts_with($class, 'new ')) {
                
->addEventSubscriber(new MergeDoctrineCollectionListener())
            ->getForm();
    }

    public function testOnSubmitDoNothing()
    {
        $submittedData = ['test'];
        $event = new FormEvent($this->getForm()$submittedData);

        $this->dispatcher->dispatch($event, FormEvents::SUBMIT);

        $this->assertTrue($this->collection->contains('test'));
        $this->assertSame(1, $this->collection->count());
    }

    public function testOnSubmitNullClearCollection()
    {
        $submittedData = [];
        $event = new FormEvent($this->getForm()$submittedData);

        $this->dispatcher->dispatch($event, FormEvents::SUBMIT);

        $this->assertTrue($this->collection->isEmpty());
    }


        if (\count($privilege->getRequirements()) > 0) {
            $requirements = [];
            foreach ($privilege->getRequirements() as $requirement) {
                $requirements[] = $requirement->getId();
            }
            $privilegeNode['requirements'] = $requirements;
        }

        if ($role) {
            if ($role->getPrivileges()->contains($privilege) || $role->getAdmin() === 1) {
                $privilegeNode['checked'] = true;
                $resourceNode['expanded'] = true;
            }
        }

        return $privilegeNode;
    }
}


    /** * @final */
    public function collect(Request $request, Response $response, \Throwable $exception = null): void
    {
        if ($response instanceof RedirectResponse) {
            $this->data['redirect'] = true;
            $this->data['url'] = $response->getTargetUrl();

            if ($this->controllers->contains($request)) {
                $this->data['route'] = $this->guessRoute($request$this->controllers[$request]);
            }
        }

        unset($this->controllers[$request]);
    }

    /** * @return void */
    public function reset()
    {
return $code;
    }

    private function addServiceConfigurator(Definition $definition, string $variableName = 'instance'): string
    {
        if (!$callable = $definition->getConfigurator()) {
            return '';
        }

        if (\is_array($callable)) {
            if ($callable[0] instanceof Reference
                || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))
            ) {
                return sprintf(" %s->%s(\$%s);\n", $this->dumpValue($callable[0])$callable[1]$variableName);
            }

            $class = $this->dumpValue($callable[0]);
            // If the class is a string we can optimize away             if (str_starts_with($class, "'") && !str_contains($class, '$')) {
                return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class)$callable[1]$variableName);
            }

            if (str_starts_with($class, 'new ')) {
                
return null;
            }
        }

        $this->cursor = $this->moveCursor($cursor);

        return $transport;
    }

    protected function isTransportDead(TransportInterface $transport): bool
    {
        return $this->deadTransports->contains($transport);
    }

    protected function getInitialCursor(): int
    {
        // the cursor initial value is randomized so that         // when are not in a daemon, we are still rotating the transports         return mt_rand(0, \count($this->transports) - 1);
    }

    protected function getNameSymbol(): string
    {
        
Home | Imprint | This part of the site doesn't use cookies.