blob: ae258194ad71dd8660190d0ae2b25096b63b4960 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.php.zend;
import org.netbeans.modules.php.api.framework.BadgeIcon;
import org.netbeans.modules.php.api.phpmodule.PhpModule;
import org.netbeans.modules.php.api.phpmodule.PhpModuleProperties;
import org.netbeans.modules.php.spi.editor.EditorExtender;
import org.netbeans.modules.php.spi.framework.PhpFrameworkProvider;
import org.netbeans.modules.php.spi.framework.PhpModuleActionsExtender;
import org.netbeans.modules.php.spi.framework.PhpModuleExtender;
import org.netbeans.modules.php.spi.framework.PhpModuleIgnoredFilesExtender;
import org.netbeans.modules.php.spi.phpmodule.ImportantFilesImplementation;
import org.netbeans.modules.php.zend.commands.ZendCommandSupport;
import org.netbeans.modules.php.zend.editor.ZendEditorExtender;
import org.openide.filesystems.FileObject;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
* @author Tomas Mysik
*/
public final class ZendPhpFrameworkProvider extends PhpFrameworkProvider {
private static final String ICON_PATH = "org/netbeans/modules/php/zend/ui/resources/zend_badge_8.png"; // NOI18N
private static final ZendPhpFrameworkProvider INSTANCE = new ZendPhpFrameworkProvider();
private final BadgeIcon badgeIcon;
@PhpFrameworkProvider.Registration(position=200)
public static ZendPhpFrameworkProvider getInstance() {
return INSTANCE;
}
private ZendPhpFrameworkProvider() {
super("Zend PHP Web Framework", // NOI18N
NbBundle.getMessage(ZendPhpFrameworkProvider.class, "LBL_FrameworkName"),
NbBundle.getMessage(ZendPhpFrameworkProvider.class, "LBL_FrameworkDescription"));
badgeIcon = new BadgeIcon(
ImageUtilities.loadImage(ICON_PATH),
ZendPhpFrameworkProvider.class.getResource("/" + ICON_PATH)); // NOI18N
}
@Override
public BadgeIcon getBadgeIcon() {
return badgeIcon;
}
@Override
public boolean isInPhpModule(PhpModule phpModule) {
FileObject sourceDirectory = phpModule.getSourceDirectory();
if (sourceDirectory == null) {
// broken project
return false;
}
FileObject zfProject = sourceDirectory.getFileObject(".zfproject.xml"); // NOI18N
return zfProject != null && zfProject.isData() && zfProject.isValid();
}
@Override
public ImportantFilesImplementation getConfigurationFiles2(PhpModule phpModule) {
return new ConfigurationFiles(phpModule);
}
@Override
public PhpModuleExtender createPhpModuleExtender(PhpModule phpModule) {
// return new ZendPhpModuleExtender();
// legacy version, disable it
return null;
}
@Override
public PhpModuleProperties getPhpModuleProperties(PhpModule phpModule) {
PhpModuleProperties properties = new PhpModuleProperties();
FileObject sourceDirectory = phpModule.getSourceDirectory();
if (sourceDirectory == null) {
// broken project
return properties;
}
FileObject web = sourceDirectory.getFileObject("public"); // NOI18N
if (web != null) {
properties = properties.setWebRoot(web);
}
FileObject tests = sourceDirectory.getFileObject("tests"); // NOI18N
if (tests != null) {
properties = properties.setTests(tests);
}
return properties;
}
@Override
public PhpModuleActionsExtender getActionsExtender(PhpModule phpModule) {
return new ZendPhpModuleActionsExtender();
}
@Override
public PhpModuleIgnoredFilesExtender getIgnoredFilesExtender(PhpModule phpModule) {
return null;
}
@Override
public ZendCommandSupport getFrameworkCommandSupport(PhpModule phpModule) {
return new ZendCommandSupport(phpModule);
}
@Override
public EditorExtender getEditorExtender(PhpModule phpModule) {
return new ZendEditorExtender();
}
}