protected function copyAssets(Filesystem $fs, $from_directory, $to_directory)
    {
        Tlog::getInstance()->addDebug("Copying assets from $from_directory to $to_directory");

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($from_directory, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $fs->mkdir($to_directory, 0777);

        /** @var \RecursiveDirectoryIterator $iterator */
        foreach ($iterator as $item) {
            if ($item->isDir()) {
                $dest_dir = $to_directory . DS . $iterator->getSubPathName();

                if (! is_dir($dest_dir)) {
                    if ($fs->exists($dest_dir)) {
                        $fs->remove($dest_dir);
                    }

                    $fs->mkdir($dest_dir, 0777);
                }
            } elseif (! $this->isSourceFile($item)) {
                // We don't copy source files

                $dest_file = $to_directory . DS . $iterator->getSubPathName();

                if ($fs->exists($dest_file)) {
                    $fs->remove($dest_file);
                }

                $fs->copy($item, $dest_file);
            }
        }
    }