Example #1
0
 /**
  * Set behaviors for the scheme when present
  *
  * @param One_Scheme $scheme
  * @param DOMXPath $xpath
  * @param DOMElement $meta
  */
 protected static function setBehaviors(One_Scheme $scheme, DOMXPath $xpath, DOMElement $meta)
 {
     $behaviorsSpec = $xpath->query($meta->getNodePath() . '/behaviors/behavior');
     $behaviors = array();
     $behaviorOptions = array();
     for ($i = 0; $i < $behaviorsSpec->length; $i++) {
         $behaviorSpec = $behaviorsSpec->item($i);
         $behavior = One_Repository::getBehavior($behaviorSpec->getAttribute('name'), $scheme->getName());
         $spec = array();
         for ($j = 0; $j < $behaviorSpec->attributes->length; $j++) {
             $attr = $behaviorSpec->attributes->item($j);
             $spec[$attr->name] = $attr->value;
         }
         $behaviors[] = $behavior;
         $behaviorOptions[strtolower($behavior->getName())] = $spec;
     }
     $scheme->set('behaviors', $behaviors);
     $scheme->set('behaviorOptions', $behaviorOptions);
 }