Ejemplo n.º 1
0
 /**
  * Distribute data into the XYL tree. Data are linked to element through a
  * reference to the data bucket in this object.
  *
  * @param   Element\Concrete  $element    Compute data on this element.
  * @return  void
  */
 protected function computeDataBinding(Element\Concrete $element)
 {
     if (true === $this->isInnerOpened()) {
         return;
     }
     $this->_isDataComputed = true;
     $data = $this->getData()->toArray();
     return $element->computeDataBinding($data);
 }
Ejemplo n.º 2
0
 /**
  * Real attributes mapping.
  *
  * @param   \Hoa\Xyl\Element\Concrete  $self       Element that will receive
  *                                                 attributes.
  * @param   string                     $parent     Parent's name.
  * @param   array                      &$mapped    Mapped attributes.
  * @return  void
  */
 private static function _mapAttributes($self, $parent, array &$mapped)
 {
     if (!isset($parent::$_attributesMapping) || !isset($parent::$_attributes)) {
         return;
     }
     $map = $parent::$_attributesMapping;
     if (… === $map) {
         $map = array_keys($parent::$_attributes);
     }
     $map = array_diff($map, $mapped);
     foreach ($map as $from => $to) {
         if (is_int($from)) {
             $from = $to;
         }
         $type = $parent::$_attributes[$from];
         $self->_htmlAttributesType[$to] = $type;
         $mapped[] = $from;
         if (self::ATTRIBUTE_TYPE_CUSTOM == $type) {
             $values = $self->abstract->readCustomAttributes($from);
             foreach ($values as $name => $value) {
                 $self->writeAttribute($to . '-' . $name, $value);
             }
             continue;
         } elseif (null === ($value = $self->abstract->readAttribute($from))) {
             continue;
         }
         $self->writeAttribute($to, $value);
     }
     return;
 }