X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Fwrapper%2Fclass_CompanyDatabaseWrapper.php;h=752e40999e19dc27d7fccb157e8ac8e8c4cb44c4;hb=a771e8625d659bffda3dc7dd929b5fcc877e9328;hp=80bb0371954c3adb59b07db9ad763cd4feda9fd5;hpb=8ba5a30e52e7cd8adb76f675ab3f7129a60819e3;p=shipsimu.git diff --git a/application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php b/application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php index 80bb037..752e409 100644 --- a/application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php +++ b/application/ship-simu/main/wrapper/class_CompanyDatabaseWrapper.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class CompanyDatabaseWrapper extends BaseDatabaseWrapper { + /** + * Company instance + */ + private $companyInstance = null; + // Constants for database tables const DB_TABLE_COMPANY_DATA = "company"; const DB_TABLE_COMPANY_USER = "company_user"; @@ -34,26 +39,27 @@ class CompanyDatabaseWrapper extends BaseDatabaseWrapper { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription("A wrapper for database access to company data"); - - // Create unique ID number - $this->generateUniqueId(); } /** * Creates an instance of this wrapper class * + * @param $companyInstance An instance of a generic company class or null if no specific * @return $wrapperInstance An instance of this wrapper class + * @todo Find an interface which is suitable for all companies */ - public final static function createCompanyDatabaseWrapper () { + public final static function createCompanyDatabaseWrapper (ShippingCompany $companyInstance = null) { // Create a new instance $wrapperInstance = new CompanyDatabaseWrapper(); // Set (primary!) table name $wrapperInstance->setTableName(self::DB_TABLE_COMPANY_DATA); + // Set the company instance if not null + if (!is_null($companyInstance)) { + $wrapperInstance->setCompanyInstance($companyInstance); + } // END - if + // Return the instance return $wrapperInstance; } @@ -93,6 +99,27 @@ class CompanyDatabaseWrapper extends BaseDatabaseWrapper { // Return the result return $participates; } + + /** + * Setter for company instance + * + * @param $companyInstance An instance of a generic company + * @return void + * @todo Find an interface suitable for all types of companies + */ + protected final function setCompanyInstance (ShippingCompany $companyInstance) { + $this->companyInstance = $companyInstance; + } + + /** + * Getter for company instance + * + * @return $companyInstance An instance of a generic company + * @todo Find an interface suitable for all types of companies + */ + public final function getCompanyInstance () { + return $this->companyInstance; + } } // [EOF]