Ejemplo n.º 1
0
 /**
  * getZoneWeight
  *
  * @param mixed $address Address
  *
  * @return integer
  */
 public function getZoneWeight($address)
 {
     $zoneWeight = 0;
     $elementTypesData = \XLite\Model\ZoneElement::getElementTypesData();
     if ($this->hasZoneElements()) {
         foreach ($elementTypesData as $type => $data) {
             $checkFuncName = 'checkZone' . $data['funcSuffix'];
             // Get zone elements
             $elements = $this->getElementsByType($type);
             if (!empty($elements)) {
                 // Check if address field belongs to the elements
                 $found = $this->{$checkFuncName}($address, $elements);
                 if ($found) {
                     // Increase the total zone weight
                     $zoneWeight += $data['weight'];
                 } elseif ($data['required']) {
                     // Break the comparing
                     $zoneWeight = 0;
                     break;
                 }
             }
         }
         if ($zoneWeight) {
             $zoneWeight++;
         }
     } else {
         $zoneWeight = 1;
     }
     return $zoneWeight;
 }
 /**
  * {@inheritDoc}
  */
 public function prepareEntityBeforeCommit($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type));
     return parent::prepareEntityBeforeCommit($type);
 }