0

I have been learning the Zend Framework for the past couple of days. I am at the beginner level as of now.

I have been given a problem statement:

/* Create a new lead
 *
 * planId will be sent $_GET['planId'], the form should send the action to
 * the same page
 * a user should be logged in and he should be administrator of the plan
 *
 * @uses Plans_Model_Dao_Moderator::isAdmin
 * @throws unauthorized exception, catch the exception in error controller
 */

I have searched the whole Zend tutorial available on the website to understand how to start with it! It really is getting on my nerves..any help regarding this would be grateful.

Can the error handling be done with Zend_Controller_Plugin_ErrorHandler?

Aurelio De Rosa
  • 21,856
  • 8
  • 48
  • 71
Manas Shah
  • 19
  • 5

1 Answers1

1

First of all, you need to set up your application.

Following the Zend Framework Quick Start (http://framework.zend.com/manual/en/learning.quickstart.intro.html) you will end up with a single application accessible through /index/index

If you consider the quick start not sufficient, you can follow this link: http://alex-tech-adventures.com/development/zend-framework.html?start=20

There you will find how to setup the application with login, access control and also forms.

After that, you can finally try to understand the Plans_Model_Dao_Moderator::isAdmin

In this case, there is a different concept. The ZF Quick Start uses Data Mappers as DAL (Data Access Layer) which act with a DAO (Data Access Objects) for each model object.

See: What is the difference between DAO and DAL?

The tutorial provided on the link above (Alex Tech Adventures), do not make use of Data Mappers. The DAL in that case is the Zend_Db_Table and Zend_Db_Table_Row. But you can adapt it after you understand the whole concept.

So basically, the Plans_Model_Dao_Moderator::isAdmin will be something like:

/**
 * Check if the user has administrative rights
 * on a given plan
 * @param int $user_id
 * @param int $plan_id
 * @return bool
 */
public function isAdmin($user_id, $plan_id)
{
    // perform the the select on the data base
    // $this->dbAdapter->fetchRow($select->from('table'...
    // return $bool
}
Community
  • 1
  • 1
Keyne Viana
  • 6,194
  • 2
  • 24
  • 55