AssetManager\Resolver\PathStackResolver::setPaths PHP Method

setPaths() public method

Rest the path stack to the paths provided
public setPaths ( Traversabl\Traversable | array $paths )
$paths Traversabl\Traversable | array
    public function setPaths($paths)
    {
        if (!is_array($paths) && !$paths instanceof Traversable) {
            throw new Exception\InvalidArgumentException(sprintf('Invalid argument provided for $paths, expecting either an array or Traversable object, "%s" given', is_object($paths) ? get_class($paths) : gettype($paths)));
        }
        $this->clearPaths();
        $this->addPaths($paths);
    }

Usage Example

 public function testSetPaths()
 {
     $resolver = new PathStackResolver();
     $resolver->setPaths(array('dir2', 'dir1'));
     // order inverted because of how a stack is traversed
     $this->assertSame(array('dir1' . DIRECTORY_SEPARATOR, 'dir2' . DIRECTORY_SEPARATOR), $resolver->getPaths()->toArray());
     $paths = new ArrayObject(array('dir4', 'dir3'));
     $resolver->setPaths($paths);
     $this->assertSame(array('dir3' . DIRECTORY_SEPARATOR, 'dir4' . DIRECTORY_SEPARATOR), $resolver->getPaths()->toArray());
     $this->setExpectedException('AssetManager\\Exception\\InvalidArgumentException');
     $resolver->setPaths('invalid');
 }