protected function generateResources(
        JsonDefinition $jsonDef,
        $bundleName,
        $bundleDir,
        $bundleNamespace
    ) {

        /** @var ResourceGenerator $generator */
        $generator = $this->resourceGenerator;
        $generator->setGenerateController(false);

        foreach ($this->getSubResources($jsonDef) as $subRecource) {
            $generator->setJson(new JsonDefinition($subRecource->getDef()->setIsSubDocument(true)));
            $generator->generate(
                $bundleDir,
                $bundleNamespace,
                $bundleName,
                $subRecource->getId()
            );
        }

        // main resources
        if (!empty($jsonDef->getFields())) {
            $generator->setGenerateController(true);

            $routerBase = $jsonDef->getRouterBase();
            if ($routerBase === false || $this->isNotWhitelistedController($routerBase)) {
                $generator->setGenerateController(false);
            }

            $generator->setJson(new JsonDefinition($jsonDef->getDef()));
            $generator->generate(
                $bundleDir,
                $bundleNamespace,
                $bundleName,
                $jsonDef->getId()
            );
        }
    }