Example #1
0
File: Company.php Project: ud223/yj
 /**
  * 创建公司
  * @param \Documents\User $user 公司的创建者
  * @return \Documents\Company - 返回的是新创建的公司的对象
  * @throws \Angel_Exception_Company
  */
 public function createCompany(\Documents\User $user)
 {
     $result = null;
     if ($user->isStartup()) {
         $company = new $this->_document_class();
         $company->owner = $user;
         $this->_dm->persist($company);
         $this->_dm->flush();
         $result = $company;
     } else {
         // 只有创业者才能创建公司
         throw new \Angel_Exception_Company(Angel_Exception_Company::ONLY_STARTUP_CAN_CREATE_COMPANY);
     }
     return $result;
 }
Example #2
0
 public function isStartup()
 {
     $this->__load();
     return parent::isStartup();
 }