FluentDOM\Element::getAttribute PHP Method

getAttribute() public method

Get an attribute value
public getAttribute ( string $name ) : string
$name string
return string
    public function getAttribute($name)
    {
        list($namespace, $localName) = $this->resolveTagName($name);
        if ($namespace != '') {
            return parent::getAttributeNS($namespace, $localName);
        } else {
            return parent::getAttribute($name);
        }
    }

Usage Example

Beispiel #1
0
 public function callAction(Element $element)
 {
     $url = Uri::createFromString($element->getAttribute('href'));
     $action = new Action($this, $url, $element);
     $params = explode(':', urldecode($url->getFragment()));
     array_shift($params);
     // slice away the needle
     $actionName = array_shift($params);
     $action->setParameters($params);
     $actions = $this->getLinkActions();
     if (array_key_exists($actionName, $actions)) {
         $config = $actions[$actionName];
         if (is_string($config)) {
             $config = ['call' => $config];
         }
         $action->setConfig($config);
         $action->call();
     }
 }