[SalesForce] Apex Class Non static AuraEnabled methods may not have parameters

I have an apex class which is the controller for a lightning component. In the class I want to pull through several different parts of different objects and return it in to the JS controller as one object. Now I am getting the errors: Non static AuraEnabled methods may not have parameters and AuraEnabled methods must be named with a prefix 'get'.

public with sharing class EBC_RelatedListsApx {

public class TableRow{
    @AuraEnabled public String type      {get;set;}
    @AuraEnabled public String body      {get;set;}
    @AuraEnabled public String dateString     {get;set;}
    @AuraEnabled public String user   {get;set;}
}

@AuraEnabled public List<TableRow> RowList {get; set;}

@AuraEnabled
public list<TableRow> WrapperDemoController(string processId){

    RowList = new List<TableRow>();
    TableRow tr;

    //ACTION
    for(arcusregserv__RS_Action__c action : [select arcusregserv__Action_Type__c, arcusregserv__Actual_Date__c, CreatedBy.Name, id from arcusregserv__RS_Action__c where arcusregserv__Activity__c =: processId order by CreatedDate desc]){

        tr = new TableRow();
        tr.type = 'Action';
        tr.body = action.arcusregserv__Action_Type__c;
        tr.dateString = string.valueOfGmt(action.arcusregserv__Actual_Date__c);
        tr.user = action.CreatedBy.Name;

        /*Add the TableRow to the List then and there*/
        RowList.add(tr);
    }

    //Chatter

    for(feedItem chatter : [select body, CreatedDate, CreatedBy.name from feedItem where parentId =: processId order by CreatedDate desc]){

        tr = new TableRow();
        tr.type = 'Chatter';
        tr.body = chatter.body;
        tr.dateString = string.valueOfGmt(date.newInstance(chatter.createdDate.year(), chatter.createdDate.month(), chatter.createdDate.day()));
        tr.user = chatter.CreatedBy.Name;

        /*Add the TableRow to the List then and there*/
        RowList.add(tr);
    }

    //ContentDocumentVersion
    List<id> contentDocumentIdList = new List<id>(new Map<id, contentDocumentLink>([select contentDocumentId from contentdocumentlink where linkedentityid =: processId]).keySet());

    String SOQL_IDs = '';
    for (Id id : contentDocumentIdList) {
        String id_in_quotes = '\''+id+'\'';
        if (SOQL_IDs!='') { SOQL_IDs+=','; }  //  add a comma if this isn't the first one
        SOQL_IDs += id_in_quotes;
    }
    String SOQL = 'select title, CreatedDate, Createdby.Name from contentVersion where contentDocumentId in ('+SOQL_IDs+')';

    for(contentVersion CV : database.query(SOQL)){

        tr = new TableRow();
        tr.type = 'CV';
        tr.body = CV.title;
        tr.dateString = string.valueOfGmt(date.newInstance(CV.createdDate.year(), CV.createdDate.month(), CV.createdDate.day()));
        tr.user = CV.CreatedBy.Name;

        /*Add the TableRow to the List then and there*/
        RowList.add(tr);
    }

    //Requisite

    for(arcusregserv__RS_Requisite__c requisite : [select arcusregserv__Status__c, CreatedDate, CreatedBy.name, id  from arcusregserv__RS_Requisite__c where arcusregserv__Process__c =: processId order by CreatedDate desc]){

        tr = new TableRow();
        tr.type = 'Requisite';
        tr.body = requisite.arcusregserv__Status__c;
        tr.dateString = string.valueOfGmt(date.newInstance(requisite.createdDate.year(), requisite.createdDate.month(), requisite.createdDate.day()));
        tr.user = requisite.CreatedBy.Name;

        /*Add the TableRow to the List then and there*/
        RowList.add(tr);
    }

    //Financial transaction

    for(arcshared__Financial_Transaction__c FT : [select arcshared__Status__c, CreatedDate, CreatedBy.name, id  from arcshared__Financial_Transaction__c where arcusregserv__Related_Process__c =: processId order by CreatedDate desc]){

        tr = new TableRow();
        tr.type = 'FinancialTransaction';
        tr.body = FT.arcshared__Status__c;
        tr.dateString = string.valueOfGmt(date.newInstance(FT.createdDate.year(), FT.createdDate.month(), FT.createdDate.day()));
        tr.user = FT.CreatedBy.Name;

        /*Add the TableRow to the List then and there*/
        RowList.add(tr);
    }

    return RowList;
}

}

Best Answer

Fix by:

// Delete this line
@AuraEnabled public List<TableRow> RowList {get; set;}

// Strange name for a method: change it?
@AuraEnabled
public static list<TableRow> WrapperDemoController(string processId){

    List<TableRow> RowList = new List<TableRow>();
    TableRow tr;

    ...

The methods have to be static to make it clear that there is no mechanism for preserving the state of class properties between requests. Each method must take parameters from the page, do work (e.g. queries) and then return the result back to the page.