Java Code Examples for fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent#getContainerFiles()

The following examples show how to use fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent#getContainerFiles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalProfilerFactory.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Nullable
protected File getCsvIndex(@NotNull Project project) {
    Symfony2ProjectComponent symfony2ProjectComponent = project.getComponent(Symfony2ProjectComponent.class);
    for(File file: symfony2ProjectComponent.getContainerFiles()) {
        if(file.exists()) {
            File csvFile = new File(file.getParentFile().getPath() + "/profiler/index.csv");
            if (csvFile.exists()) {
                return csvFile;
            }
        }
    }

    return null;
}
 
Example 2
Source File: ServiceXmlParserFactory.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@Nullable
synchronized public <T extends ServiceParserInterface> T parser(Class<T> serviceParser) {

    Symfony2ProjectComponent symfony2ProjectComponent = this.project.getComponent(Symfony2ProjectComponent.class);

    Collection<File> settingsServiceFiles = symfony2ProjectComponent.getContainerFiles();

    if (this.serviceParserInstance != null && !this.isModified(settingsServiceFiles)) {
        return (T) this.serviceParserInstance;
    }

    try {
        this.serviceParserInstance = serviceParser.newInstance();
        Symfony2ProjectComponent.getLogger().info("new instance: " + serviceParser.getName());
    } catch (InstantiationException | IllegalAccessException ignored) {
    }

    if (this.serviceParserInstance != null) {

        // extensions
        if(this.extensions.size() > 0) {
            CompiledServiceBuilderArguments args = new CompiledServiceBuilderArguments(project);
            for (CompiledServiceBuilderFactory.Builder builder : this.extensions) {
                builder.build(args);
            }

            for (InputStream inputStream : args.getStreams()) {
                this.serviceParserInstance.parser(inputStream);
            }
        }

        this.serviceFiles = new HashMap<>();
        for(File settingsServiceFile: settingsServiceFiles) {
            if(!settingsServiceFile.exists()) {
                continue;
            }

            try {
                this.serviceParserInstance.parser(new FileInputStream(settingsServiceFile));
            } catch (FileNotFoundException e) {
                continue;
            }

            serviceFiles.put(settingsServiceFile.getAbsolutePath(), settingsServiceFile.lastModified());
        }
    }

    Symfony2ProjectComponent.getLogger().info("update: " + serviceParser.getName());

    return (T) this.serviceParserInstance;
}