Question

<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">

and

<form action="<?php echo $this->getUrl('customer/account/createpost'); ?>" method="post" id="form-validate">

both code call AccountController and createPostAction action but the first one make this process very complicated.so my qustion is why magento use this complicated method .

here action call this Function

public function getPostActionUrl()
{
    return $this->helper('customer')->getRegisterPostUrl();
}

and then Block use helper

public function getRegisterPostUrl()
{
    return $this->_getUrl('customer/account/createpost');
}
Was it helpful?

Solution

The answer is simple. Extensibility & Enapsulation.
Having the URL returned by a method, you can call that method everywhere in the code without the need to remember what the actual URL is.
Also in case the core team decides to change the url, they will do it in a single place.

If YOU decide to change the url all you need to do is to rewrite one single method.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top