Example #1
0
    /**
     * Path routing
     *
     * @param AbstractResourceBundle $bundle
     *
     * @return null
     */
    private function patchRouting(AbstractResourceBundle $bundle)
    {
        $routingPath = $bundle->getPath() . '/Resources/config/routing/';
        $prefix = $this->getBundlePrefix();
        $namePrefix = strtolower($this->getBundlePrefix($bundle) . '_' . $this->model);
        $bundleName = $bundle->getName();
        $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($this->bundle->getName()) . '\\' . $this->model;
        $identifier = $this->getContainer()->get('doctrine')->getManager()->getClassMetadata($entityClass)->getIdentifier();
        $this->renderFile('controller/routing/routing.yml.twig', $routingPath . strtolower($this->model) . '.yml', array('route_name_prefix' => $namePrefix, 'bundle' => $prefix, 'entity' => $this->model, 'identifier' => $identifier[0], 'resource' => $bundle->getName(), 'actions' => $this->configuration['actions']));
        $path = $routingPath . 'main.yml';
        if (!file_exists($path)) {
            $path = $this->getContainer()->get('kernel')->getRootDir() . '/config/routing.yml';
        }
        $prefixName = strtolower($this->model);
        $nodeDeclaration = <<<EOF
{$namePrefix}:
    resource: @{$bundleName}/Resources/config/routing/{$prefixName}.yml
    prefix: /{$prefixName}
EOF;
        if (!$this->refExist($path, $namePrefix)) {
            $this->dumpFile($path, "\n" . $nodeDeclaration, false, false);
        }
        return null;
    }