/**
  * Populate __sleep values, restore serialize values specified on __sleep() method
  *
  * @return self
  */
 public function populateWithItself(self $formulary)
 {
     $this->_name = $formulary->getName();
     $this->_isActive = $formulary->isActive();
     $this->_isDefault = $formulary->isDefault();
     return $this;
 }
 public function processDefaultAction()
 {
     $tableName = preg_replace('/[^a-zA-Z]+/', '', $this->_getParam("id", ""));
     if (strlen($tableName) == 0) {
         $msg = __("Invalid formulary name");
         $code = 400;
         // invalid entry
     } else {
         $formulary = new FormularyItem($tableName);
         if ($formulary->populate(false)) {
             if (!$formulary->isActive()) {
                 $msg = __("Formulary " . $formulary->getPrettyName() . " is not active and cannot be set to default");
                 $code = 402;
             } else {
                 $formulary->setDefault();
                 $formulary->persist(false);
                 $msg = __("Formulary " . $formulary->getPrettyName() . " set to default successfully");
                 $code = 200;
             }
         } else {
             $msg = __("Formulary " . $formulary->getPrettyName() . " does not exists");
             $code = 401;
         }
     }
     $data['msg'] = $msg;
     $data['code'] = $code;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }