private $founderInstance = null;
/**
- * Employed people by this company
+ * Headquarter harbor instance
*/
- private $employeeList = null;
+ private $hqInstance = null;
/**
- * Headquarter harbor instance
+ * Employed people by this company
*/
- private $hqInstance = null;
+ private $employeeList = null;
/**
* List of all assigned shipyards
*/
private $contractList = null;
- /**
- * Database result instance
- */
- private $resultInstance = null;
-
// Exception constants
const EXCEPTION_USER_OWNS_NO_COMPANY = 0x200;
*
* @param $userInstance A user class
* @return $companyInstance Prepared company instance
- * @throws NoShippingCompanyOwnedException If the user owns no shipping companies
*/
public final static function createShippingCompany (BaseUser $userInstance) {
// Get new instance
$companyInstance = new ShippingCompany();
// Does the given user owns a company?
- if (!$companyInstance->ifUserOwnsShippingCompany($userInstance)) {
- // Throw an exception here
- throw new NoShippingCompanyOwnedException(array($companyInstance, $userInstance), self::EXCEPTION_USER_OWNS_NO_COMPANY);
+ if ($companyInstance->ifUserParticipatesInCompany($userInstance)) {
+ // Then do some nastly caching here but don't throw an exception
+ // because then you will hurt our web helpers... :/
+ $companyInstance->partialStub("Don't throw exceptions here.");
} // END - if
- // Set the user instance. We don't care here if he is founder or employee.
- $companyInstance->setUserInstance($userInstance);
-
// Init all lists
$companyInstance->initCompanyLists();
}
/**
- * Checks wether the given user owns a company or not
+ * Checks wether the given user participates in a company
*
* @param $userInstance An instance of a user class
- * @return $ownsCompany Wether the user owns at least one company
+ * @return $participates Wether the user participates at lease in one company
*/
- protected function ifUserOwnsShippingCompany (BaseUser $userInstance) {
+ protected function ifUserParticipatesInCompany (BaseUser $userInstance) {
// By default no user owns any company... ;)
- $ownsCompany = false;
+ $participates = false;
// Get a company database wrapper class
$wrapperInstance = ObjectFactory::createObjectByConfiguredName('company_db_wrapper_class');
- // Get a search criteria class
- $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+ // Ask the wrapper if this user participates
+ $participates = $wrapperInstance->ifUserParticipatesInCompany($userInstance);
- // Add the user primary key as a search criteria
- $criteriaInstance->addCriteria('company_owner', $userInstance->getPrimaryKey());
- $criteriaInstance->setLimit(1);
+ // Get the result instance
+ $resultInstance = $wrapperInstance->getResultInstance();
- // Get the result back
- $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
- $resultInstance->debugInstance();
+ // Caches the result instance here, if set (we don't the wrapper anymore!)
+ if ($resultInstance instanceof SearchableResult) {
+ // Set the result instance
+ $this->setResultInstance($resultInstance);
+ } // END - if
+
+ // Return result
+ return $participates;
}
+ //----------------------------------------------------------------------------
+ // From here is very old code which needs to be translated and changed heavily
+ //----------------------------------------------------------------------------
+
/**
* Intialize all lists
*
* @return void
+ * @todo Maybe we don't need these big lists anymore?! So we can deprecate/remove it
*/
protected function initCompanyLists () {
// Employees
$this->contractList = new FrameworkArrayObject("FakedContractList");
}
- //----------------------------------------------------------------------------
- // From here is very old code which needs to be translated and changed heavily
- //----------------------------------------------------------------------------
-
// Setter-Methode fuer Firmennamen
public final function setCompanyName ($companyName) {
$this->companyName = (string) $companyName;