示例#1
0
 /**
  * get or create attribute data for given object
  *
  * @param Billing $object
  * @return \Shopware\Models\Attribute\CustomerBilling
  * @throws Exception 
  */
 public function getOrCreateBillingAttribute($object)
 {
     if ($attribute = $object->getAttribute()) {
         return $attribute;
     }
     if ($object instanceof Shopware\Models\Customer\Billing) {
         if (!($attribute = Shopware()->Models()->getRepository('Shopware\\Models\\Attribute\\CustomerBilling')->findOneBy(array('customerBillingId' => $object->getId())))) {
             $attribute = new Shopware\Models\Attribute\CustomerBilling();
         }
     } else {
         throw new Exception('Unknown attribute base class');
     }
     $object->setAttribute($attribute);
     return $attribute;
 }