コード例 #1
0
  public static HashMap<String, String> getFormExtensionKeys(
      Project project, String... formTypeNames) {
    HashMap<String, String> extensionKeys = new HashMap<String, String>();
    ArrayList<String> typeClasses = FormOptionsUtil.getExtendedTypeClasses(project, formTypeNames);

    for (String typeClass : typeClasses) {
      attachOnDefaultOptions(project, extensionKeys, typeClass);
    }

    return extensionKeys;
  }
コード例 #2
0
  /** finishView, buildView: $this->vars */
  public static Set<String> getFormViewVars(Project project, String... formTypeNames) {

    Set<String> stringSet = new HashSet<String>();

    ArrayList<PhpClass> phpClasses = new ArrayList<PhpClass>();

    // attach core form phpclass
    // @TODO: add formtype itself
    PhpClass coreForm = FormUtil.getFormTypeToClass(project, "form");
    if (coreForm != null) {
      phpClasses.add(coreForm);
    }

    // for extension can also provide vars
    for (Map.Entry<String, String> entry :
        FormOptionsUtil.getFormExtensionKeys(project, formTypeNames).entrySet()) {
      PhpClass phpClass = PhpElementsUtil.getClassInterface(project, entry.getValue());
      if (phpClass != null) {
        phpClasses.add(phpClass);
      }
    }

    for (PhpClass phpClass : phpClasses) {
      for (String stringMethod : new String[] {"finishView", "buildView"}) {
        Method method = PhpElementsUtil.getClassMethod(phpClass, stringMethod);
        if (method != null) {

          // self method
          getMethodVars(stringSet, method);

          // allow parent::
          // @TODO: provide global util method
          for (ClassReference classReference :
              PsiTreeUtil.collectElementsOfType(method, ClassReference.class)) {
            if ("parent".equals(classReference.getName())) {
              PsiElement methodReference = classReference.getContext();
              if (methodReference instanceof MethodReference) {
                PsiElement parentMethod = ((MethodReference) methodReference).resolve();
                if (parentMethod instanceof Method) {
                  getMethodVars(stringSet, (Method) parentMethod);
                }
              }
            }
          }
        }
      }
    }

    return stringSet;
  }