Package fr.adrienbrault.idea.symfony2plugin.util.dict

Examples of fr.adrienbrault.idea.symfony2plugin.util.dict.SymfonyBundle


            if (matcher.find()) {
                return getAnnotationRepositoryClass(phpClass, matcher.group(1));
            }
        }

        SymfonyBundle symfonyBundle = new SymfonyBundleUtil(PhpIndex.getInstance(project)).getContainingBundle(phpClass);
        if(symfonyBundle != null) {
            String classFqnName = phpClass.getPresentableFQN();

            if(classFqnName != null) {
                PhpClass repositoryClass = getEntityRepositoryClass(project, symfonyBundle, classFqnName);
View Full Code Here


    }

    @Nullable
    public static PsiFile getModelConfigFile(PhpClass phpClass) {

        SymfonyBundle symfonyBundle = new SymfonyBundleUtil(phpClass.getProject()).getContainingBundle(phpClass);
        if(symfonyBundle != null) {
            for(String modelShortcut: new String[] {"orm", "mongodb"}) {
                String fqn = phpClass.getPresentableFQN();

                String className = phpClass.getName();

                if(fqn != null) {
                    int n = fqn.indexOf("\\Entity\\");
                    if(n > 0) {
                        className = fqn.substring(n + 8).replace("\\", ".");
                    }
                }

                String entityFile = "Resources/config/doctrine/" + className + String.format(".%s.yml", modelShortcut);
                VirtualFile virtualFile = symfonyBundle.getRelative(entityFile);
                if(virtualFile != null) {
                    PsiFile psiFile = PsiManager.getInstance(phpClass.getProject()).findFile(virtualFile);
                    if(psiFile != null) {
                        return psiFile;
                    }
View Full Code Here

    }

    private List<TranslationFileModel> getFormattedFileModelList(Collection<PsiFile> psiFiles) {

        SymfonyBundleUtil symfonyBundleUtil = new SymfonyBundleUtil(this.project);
        final SymfonyBundle symfonyBundle = symfonyBundleUtil.getContainingBundle(fileContext);

        List<TranslationFileModel> psiFilesSorted = new ArrayList<TranslationFileModel>();
        for(PsiFile psiFile: psiFiles) {
            TranslationFileModel psiWeightList = new TranslationFileModel(psiFile);

            if(symfonyBundle != null && symfonyBundle.isInBundle(psiFile)) {
                psiWeightList.setSymfonyBundle(symfonyBundle);
                psiWeightList.setBoldness(true);
                psiWeightList.addWeight(2);
            } else {
                psiWeightList.setSymfonyBundle(symfonyBundleUtil.getContainingBundle(psiFile));
View Full Code Here

            return;
        }

        String bundleName = text.substring(1, text.indexOf("/"));

        SymfonyBundle symfonyBundle = new SymfonyBundleUtil(PhpIndex.getInstance(psiElement.getProject())).getBundle(bundleName);

        if(symfonyBundle == null) {
            return;
        }

        String path = text.substring(text.indexOf("/") + 1);
        PsiFile psiFile = PsiElementUtils.virtualFileToPsiFile(psiElement.getProject(), symfonyBundle.getRelative(path));
        if(psiFile == null) {
            return;
        }

        results.add(psiFile);
View Full Code Here

        this.symfonyBundles = new HashMap<String, SymfonyBundle>();
        Collection<PhpClass> phpClasses = this.phpIndex.getAllSubclasses("\\Symfony\\Component\\HttpKernel\\Bundle\\Bundle");

        for (PhpClass phpClass : phpClasses) {
            this.symfonyBundles.put(phpClass.getName(), new SymfonyBundle(phpClass));
        }

    }
View Full Code Here

    private ArrayList<ControllerAction> getActionMethods(SymfonyBundleUtil symfonyBundleUtil, PhpClass controllerClass) {

        ArrayList<ControllerAction> actions = new ArrayList<ControllerAction>();

        Collection<Method> methods = controllerClass.getMethods();
        SymfonyBundle symfonyBundle = symfonyBundleUtil.getContainingBundle(controllerClass);

        if(symfonyBundle == null) {
            return actions;
        }

        String path = symfonyBundle.getRelative(controllerClass.getContainingFile().getVirtualFile(), true);
        if(path == null || !path.startsWith("Controller/") || !path.endsWith("Controller")) {
            return actions;
        }

        for(Method method : methods) {
            String methodName = method.getName();
            if(methodName.endsWith("Action") && method.getAccess().isPublic()) {
                String shortcutName = symfonyBundle.getName() + ":" + path.substring("Controller/".length(), path.length() - 10) + ':' + methodName.substring(0, methodName.length() - 6);
                actions.add(new ControllerAction(shortcutName, method));
            }

        }
View Full Code Here

                    String bundleName = matcher.group(1);
                    final String fileName = "Resources/views/" + matcher.group(2) + "/" + matcher.group(3);


                    SymfonyBundle symfonyBundle = new SymfonyBundleUtil(project).getBundle(bundleName);
                    if(symfonyBundle == null) {
                        return;
                    }

                    final VirtualFile virtualFile = symfonyBundle.getVirtualDirectory();
                    if(virtualFile == null) {
                        return;
                    }

                    String content = TwigUtil.buildStringFromTwigCreateContainer(project, VfsUtil.findRelativeFile(virtualFile, ("Resources/views/" + matcher.group(2)).split("/")));
View Full Code Here

        if(!className.endsWith("Controller")) {
            return null;
        }

        SymfonyBundleUtil symfonyBundleUtil = new SymfonyBundleUtil(PhpIndex.getInstance(method.getProject()));
        SymfonyBundle symfonyBundle = symfonyBundleUtil.getContainingBundle(phpClass);
        if(symfonyBundle == null) {
            return null;
        }

        // find the bundle name of file
        PhpClass BundleClass = symfonyBundle.getPhpClass();
        if(null == BundleClass) {
            return null;
        }

        // check if files is in <Bundle>/Controller/*
        if(!phpClass.getNamespaceName().startsWith(BundleClass.getNamespaceName() + "Controller\\")) {
            return null;
        }

        // strip the controller folder name
        String templateFolderName = phpClass.getNamespaceName().substring(BundleClass.getNamespaceName().length() + 11);

        // HomeBundle:default:indexes
        // HomeBundle:default/Test:indexes
        templateFolderName = templateFolderName.replace("\\", "/");
        String shortcutName = symfonyBundle.getName() + ":" + templateFolderName + className.substring(0, className.lastIndexOf("Controller")) + ":" + methodName.substring(0, methodName.lastIndexOf("Action"));

        // we should support types later on
        // HomeBundle:default:indexes.html.twig
        return shortcutName + ".html.twig";
    }
View Full Code Here

    }

    @Nullable
    public static Method findTwigFileController(TwigFile twigFile) {

        SymfonyBundle symfonyBundle = new SymfonyBundleUtil(twigFile.getProject()).getContainingBundle(twigFile);
        if(symfonyBundle == null) {
            return null;
        }

        String relativePath = symfonyBundle.getRelativePath(twigFile.getVirtualFile());
        if(relativePath == null || !relativePath.startsWith("Resources/views/")) {
            return null;
        }

        String viewPath = relativePath.substring("Resources/views/".length());

        Matcher simpleFilter = Pattern.compile(".*/(\\w+)\\.\\w+\\.twig").matcher(viewPath);
        if(!simpleFilter.find()) {
            return null;
        }

        String methodName = simpleFilter.group(1) + "Action";
        String className = symfonyBundle.getNamespaceName() + "Controller\\" + viewPath.substring(0, viewPath.lastIndexOf("/")).replace("/", "\\") + "Controller";

        return PhpElementsUtil.getClassMethod(twigFile.getProject(), className, methodName);

    }
View Full Code Here

        final PsiFileFactory factory = PsiFileFactory.getInstance(project);

        String bundleName = "Acme\\DemoBundle";

        SymfonyBundleUtil symfonyBundleUtil = new SymfonyBundleUtil(project);
        SymfonyBundle symfonyBundle = symfonyBundleUtil.getContainingBundle(initialBaseDir);

        if(symfonyBundle != null) {
            bundleName = StringUtils.strip(symfonyBundle.getNamespaceName(), "\\");
            String path = symfonyBundle.getRelative(initialBaseDir.getVirtualFile());
            if(path != null) {
                bundleName = bundleName.concat("\\" + path);
            }
        }
View Full Code Here

TOP

Related Classes of fr.adrienbrault.idea.symfony2plugin.util.dict.SymfonyBundle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.