Exemplo n.º 1
0
 /**
  * This method returns an object matching the description specified by the element.
  *
  * @access public
  * @param Spring\Object\Parser $parser                      a reference to the parser
  * @param \SimpleXMLElement $element                        the element to be parsed
  * @return mixed                                            an object matching the description
  *                                                          specified by the element
  * @throws Throwable\Parse\Exception                        indicates that a problem occurred
  *                                                          when parsing
  */
 public function getObject(Spring\Object\Parser $parser, \SimpleXMLElement $element)
 {
     $attributes = $element->attributes();
     if (isset($attributes['local'])) {
         $object = $parser->valueOf($attributes['local']);
         if (!$parser->isIdref($object, $parser->getResource())) {
             throw new Throwable\Parse\Exception('Unable to process Spring XML. Expected a valid "idref" token, but got ":token".', array(':token' => $object));
         }
         return $object;
     } else {
         if (isset($attributes['object'])) {
             $object = $parser->valueOf($attributes['object']);
             return $object;
         } else {
             throw new Throwable\Parse\Exception('Unable to process Spring XML. Tag ":tag" is missing ":attribute" attribute.', array(':tag' => 'idref', ':attribute' => 'object'));
         }
     }
 }