public function aggregate($collection)
    {
        // Ensure the collection is materialized.
        $collection = $this->mirror->materializeCollection($collection);

        // Create aggregate collection to accumulate style sheets.
        $aggregate = new StyleAggregate();
        foreach ($collection as $resource) {
            if ($resource instanceof MaterializedResource) {
                $internalResource = $resource->getResource();
                $mediaType = 'all';
                if ($internalResource instanceof CssResource) {
                    $mediaType = $internalResource->getMediaType();
                }
                $aggregate->addStyle($resource, $mediaType);
            }
        }

        // Create resource with the aggregate style sheet.
        $data = $aggregate->getAggregateStyle();
        $hash = sha1($data);
        $file = $this->prefix.$hash.'.css';
        $resource = new LocalResource($file, $data);
        return $resource;
    }