AccountPage methods naming convention

Version 0

How to name method in AccountPage class

Extending AccountPage

Use assignement operator to set values

Page and Field objects have a secifig setValue() function, but it is recommended to use an assignement operator when setting value to field. This will make code more readable (setting value stands out from isChanged() etc. comparison functions)

function onSave()
{
    $this->total_price = 100;
}

Update field data

Set values but do NOT save them inside method, so that it can be calles outside the clacc. Return $this to enable chaining.

function updatePrice()
{
    $this->total_price = $this->order_rows->calculate('amount*price');
    $return $this;
}

Get list of pages

User plural form to name function that return a collection of pages. Return the Kansio object so the client code can use calculete() etc. methods.

function getNewOrders()
{
    return $this->get('pages','order')->hae('client='.$this->getId().'&status=New');
}

Get Link to a page

Use Link -suffix in methods that return eLink -object:

function getAddOrderLink()
{
    return $this->get('page','order')->getLink()
        ->addParam('param[oletusarvo][client]', $this->client->getValue());
}

Get Link to a page

Use Button -suffix in methods that return UiButton -object:

function getAddOrderButton()
{
    return $this->get('ui','button',Array(
        'icon'  => 'app-addnew',
        'title' => 'Add new order',
        'link'  => $this->getAddOrderLink()
    ));
}

Create new page

Use create -prefix on functions that creates a new Page:

function createOrder()
{
    $Order = $this->get('page','order')->setValues(Array(
        'order_date' => 'Tänään'
    ))
    ->setValuesFrom($this,'
        client=nr,
        email
    ')
    ->save();

    return $Order;
}