public function setCollector(ResourceCollectorInterface $collector)
    {
        $this->collector = $collector;

        if ($this->loader) {
            if ($this->loader instanceof ResourceAwareInterface) {
                $this->loader->setResourceCollector($collector);
            }

            if ($this->loader instanceof DelegatingLoader) {
                $resolver = $this->loader->getResolver();

                if ($resolver instanceof ResourceAwareInterface) {
                    $resolver->setResourceCollector($collector);
                }
            }
        }
    }