Puli\Repository\Resource\Iterator\ResourceCollectionIterator::__construct PHP Метод

__construct() публичный Метод

The following constants can be used to configure the values returned by the iterator: * {@link CURRENT_AS_RESOURCE}: The {@link PuliResource} objects are returned as values; * {@link CURRENT_AS_PATH}: The resource paths are returned as values; * {@link CURRENT_AS_NAME}: The resource names are returned as values. The following constants can be used to configure the keys returned by the iterator: * {@link KEY_AS_CURSOR}: The collection keys are returned as keys; * {@link KEY_AS_PATH}: The resource paths are returned as keys. By default, the mode KEY_AS_PATH | CURRENT_AS_RESOURCE is used.
public __construct ( Puli\Repository\Api\ResourceCollection $resources, integer | null $mode = null )
$resources Puli\Repository\Api\ResourceCollection The resources to iterate.
$mode integer | null A bitwise combination of the mode constants.
    public function __construct(ResourceCollection $resources, $mode = null)
    {
        if (!($mode & (self::CURRENT_AS_PATH | self::CURRENT_AS_RESOURCE | self::CURRENT_AS_NAME))) {
            $mode |= self::CURRENT_AS_RESOURCE;
        }
        if (!($mode & (self::KEY_AS_PATH | self::KEY_AS_CURSOR))) {
            $mode |= self::KEY_AS_PATH;
        }
        $this->resources = $resources->toArray();
        $this->mode = $mode;
    }