Пример #1
0
 public static function makeRequiredEntities()
 {
     $useExistingOrMakeNew = function ($entityClass, $model) {
         $name = $model->name;
         try {
             if ($entityClass === Bf_ProductRatePlan::getClassName()) {
                 $existing = Bf_ProductRatePlan::getByProductAndRatePlanID($model->productID, $name);
             } else {
                 $existing = $entityClass::getByID($name);
             }
             if ($existing) {
                 return $existing;
             }
         } catch (Bf_NoMatchingEntityException $e) {
             return $entityClass::create($model);
         }
     };
     $models = array('uom' => array(Models::UnitOfMeasure(), Models::UnitOfMeasure2(), Models::UnitOfMeasure2()), 'product' => Models::MonthlyRecurringProduct(), 'pricingComponentTierLists' => array(Models::PricingComponentTiers(), Models::PricingComponentTiers2(), Models::PricingComponentTiers2()));
     $created = array('uom' => array($useExistingOrMakeNew(Bf_UnitOfMeasure::getClassName(), $models['uom'][0]), $useExistingOrMakeNew(Bf_UnitOfMeasure::getClassName(), $models['uom'][1])), 'product' => $useExistingOrMakeNew(Bf_Product::getClassName(), $models['product']));
     // having created product, make rate plan for it
     $models['pricingComponents'] = array(Models::PricingComponent($created['uom'][0], $models['pricingComponentTierLists'][0]), Models::PricingComponent2($created['uom'][1], $models['pricingComponentTierLists'][1]), Models::PricingComponent3($created['uom'][1], $models['pricingComponentTierLists'][1]));
     $models['ratePlan'] = Models::ProductRatePlan($created['product'], $models['pricingComponents']);
     $created['ratePlan'] = $useExistingOrMakeNew(Bf_ProductRatePlan::getClassName(), $models['ratePlan']);
     self::$models = $models;
     self::$created = $created;
 }
Пример #2
0
 protected function doUnserialize(array $json)
 {
     // consult parent for further unserialization
     parent::doUnserialize($json);
     $this->unserializeArrayEntities('taxation', Bf_TaxationLink::getClassName(), $json);
     $this->unserializeArrayEntities('pricingComponents', Bf_PricingComponent::getClassName(), $json);
     $this->unserializeEntity('product', Bf_Product::getClassName(), $json);
     $this->unserializeEntity('metadata', Bf_MetadataJson::getClassName(), $json);
 }