Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Static Private Member Functions | List of all members
Hoa\Xyl\Interpreter\Html\Concrete Class Reference
Inheritance diagram for Hoa\Xyl\Interpreter\Html\Concrete:

Public Member Functions

 construct ()
 
 readAttributes ()
 
 readAttribute ($name)
 
 attributeExists ($name)
 
 readAttributesAsList ()
 
 readAttributeAsList ($name)
 
 readCustomAttributes ($set)
 
 readCustomAttributesAsList ($set)
 
 readAttributesAsString ($compute=true)
 
 writeAttributes (Array $attributes)
 
 writeAttribute ($name, $value)
 
 writeCustomAttributes ($set, Array $pairs)
 
 removeAttribute ($name)
 
 getName ()
 
- Public Member Functions inherited from Hoa\Xyl\Element\Concrete
 computeDataBinding (Array &$data, Array &$parent=null)
 
 render (Stream\IStream\Out $out)
 
 computeValue (Stream\IStream\Out $out=null)
 
 computeTransientValue (Stream\IStream\Out $out=null)
 
 computeAttributeValue ($value, $type=self::ATTRIBUTE_TYPE_UNKNOWN, $name=null)
 
 isLastIteration ()
 
 setVisibility ($visibility)
 
 getVisibility ()
 
- Public Member Functions inherited from Hoa\Xml\Element\Concrete
 __construct (Element $abstract, Element $superRoot, Array $rank=[], $namespace=null)
 
 construct ()
 
 getAbstractElement ()
 
 getAbstractElementSuperRoot ()
 
 getName ()
 
 count ()
 
 getIterator ()
 
 __set ($name, Concrete $value)
 
 __get ($name)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $element)
 
 offsetUnset ($offset)
 
 __call ($name, Array $arguments=[])
 

Protected Member Functions

 mapAttributes ()
 
- Protected Member Functions inherited from Hoa\Xyl\Element\Concrete
 selectData ($expression, Array &$bucket)
 
 getCurrentData ()
 
 paint (Stream\IStream\Out $out)
 
 cleanTransientValue ()
 
 formatValue ($value, $name=null)
 
 _formatValue ($value)
 
 computeFromString ($xyl)
 
 getDeclaredAttributes ()
 

Protected Attributes

 $_htmlAttributes = []
 
 $_htmlAttributesType = []
 
 $_contentFlow = 2
 
- Protected Attributes inherited from Hoa\Xyl\Element\Concrete
 $_visibility = true
 
 $_transientValue = null
 
 $_lastIteration = false
 
- Protected Attributes inherited from Hoa\Xml\Element\Concrete
 $_name = null
 
 $_children = []
 
 $_iterator = []
 
 $abstract = null
 
 $_superRoot = null
 

Static Protected Attributes

static $_attributesMapping = …
 
- Static Protected Attributes inherited from Hoa\Xyl\Element\Concrete
static $_attributes
 
- Static Protected Attributes inherited from Hoa\Xml\Element\Concrete
static $_store = []
 
static $_superRoots = []
 
static $_multiton = []
 

Static Private Member Functions

static _mapAttributes ($self, $parent, Array &$mapped)
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\Xml\Element\Concrete
static getAbstractElementId (Element $element)
 
static getConcreteElement (Element $element)
 
static getAbstractElementSuperRootOf (Element $element)
 
- Public Attributes inherited from Hoa\Xyl\Element\Concrete
const ATTRIBUTE_TYPE_UNKNOWN = 0
 
const ATTRIBUTE_TYPE_NORMAL = 1
 
const ATTRIBUTE_TYPE_ID = 2
 
const ATTRIBUTE_TYPE_CUSTOM = 4
 
const ATTRIBUTE_TYPE_LIST = 8
 
const ATTRIBUTE_TYPE_LINK = 16
 
- Static Protected Member Functions inherited from Hoa\Xyl\Element\Concrete
static _getDeclaredAttributes ()
 

Detailed Description

Class .

Parent of all XYL components for this interpreter.

Definition at line 49 of file Concrete.php.

Member Function Documentation

static Hoa\Xyl\Interpreter\Html\Concrete::_mapAttributes (   $self,
  $parent,
Array &  $mapped 
)
staticprivate

Real attributes mapping.

Parameters
\Hoa\Xyl\Element\Concrete$selfElement that will receive attributes.
string$parentParent's name.
array&$mappedMapped attributes.
Returns
void

Definition at line 126 of file Concrete.php.

127  {
128  if (!isset($parent::$_attributesMapping) ||
129  !isset($parent::$_attributes)) {
130  return;
131  }
132 
133  $map = $parent::$_attributesMapping;
134 
135  if (… === $map) {
136  $map = array_keys($parent::$_attributes);
137  }
138 
139  $map = array_diff($map, $mapped);
140 
141  foreach ($map as $from => $to) {
142  if (is_int($from)) {
143  $from = $to;
144  }
145 
146  $type = $parent::$_attributes[$from];
147  $self->_htmlAttributesType[$to] = $type;
148  $mapped[] = $from;
149 
150  if (self::ATTRIBUTE_TYPE_CUSTOM == $type) {
151  $values = $self->abstract->readCustomAttributes($from);
152 
153  foreach ($values as $name => $value) {
154  $self->writeAttribute($to . '-' . $name, $value);
155  }
156 
157  continue;
158  } elseif (null === $value = $self->abstract->readAttribute($from)) {
159  continue;
160  }
161 
162  $self->writeAttribute($to, $value);
163  }
164 
165  return;
166  }
Hoa\Xyl\Interpreter\Html\Concrete::attributeExists (   $name)

Whether an attribute exists.

Parameters
string$nameAttribute's name.
Returns
bool

Definition at line 201 of file Concrete.php.

202  {
203  return true === array_key_exists($name, $this->readAttributes());
204  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::construct ( )

Construct element.

Returns
void

Definition at line 90 of file Concrete.php.

91  {
92  parent::construct();
93  $this->mapAttributes();
94 
95  return;
96  }

Here is the call graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::getName ( )

Get component name.

string

Definition at line 379 of file Concrete.php.

380  {
381  return $this->abstract->getName();
382  }

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::mapAttributes ( )
protected

Map attributes (from XYL to HTML).

Returns
void

Definition at line 103 of file Concrete.php.

104  {
105  $parent = get_called_class();
106  $mapped = [];
107 
108  do {
109  static::_mapAttributes($this, $parent, $mapped);
110  } while (__CLASS__ !== $parent = get_parent_class($parent));
111 
112  static::_mapAttributes($this, $parent, $mapped);
113 
114  return;
115  }

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::readAttribute (   $name)

Read a specific attribute.

Parameters
string$nameAttribute's name.
Returns
string

Definition at line 184 of file Concrete.php.

185  {
186  $attributes = $this->readAttributes();
187 
188  if (false === array_key_exists($name, $attributes)) {
189  return null;
190  }
191 
192  return $attributes[$name];
193  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::readAttributeAsList (   $name)

Read a attribute value as a list.

Parameters
string$nameAttribute's name.
Returns
array

Definition at line 228 of file Concrete.php.

229  {
230  return explode(' ', $this->readAttribute($name));
231  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::readAttributes ( )

Read all attributes.

Returns
array

Definition at line 173 of file Concrete.php.

174  {
175  return $this->_htmlAttributes;
176  }

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::readAttributesAsList ( )

Read attributes value as a list.

Returns
array

Definition at line 211 of file Concrete.php.

212  {
213  $attributes = $this->readAttributes();
214 
215  foreach ($attributes as $name => &$value) {
216  $value = explode(' ', $value);
217  }
218 
219  return $attributes;
220  }

Here is the call graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::readAttributesAsString (   $compute = true)

Read attributes as a string.

Parameters
bool$computeWhether we automatically call the Hoa::computeAttributeValue() method.
Returns
string

Definition at line 282 of file Concrete.php.

283  {
284  $out = null;
285 
286  foreach ($this->readAttributes() as $name => $value) {
287  if (null !== $value) {
288  $out .=
289  ' ' . $name . '="' .
290  str_replace(
291  '"',
292  '\"',
293  true === $compute
294  ? $this->computeAttributeValue(
295  $value,
296  isset($this->_htmlAttributesType[$name])
297  ? $this->_htmlAttributesType[$name]
298  : parent::ATTRIBUTE_TYPE_NORMAL,
299  $name
300  )
301  : $value
302  ) .
303  '"';
304  }
305  }
306 
307  return $out;
308  }
computeAttributeValue($value, $type=self::ATTRIBUTE_TYPE_UNKNOWN, $name=null)
Definition: Concrete.php:488

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::readCustomAttributes (   $set)

Read custom attributes (as a set). For example: <component data-abc="def" data-uvw="xyz"> “data” is a custom attribute, so the $set.

Parameters
string$setSet name.
Returns
array

Definition at line 242 of file Concrete.php.

243  {
244  $out = [];
245  $set .= '-';
246  $strlen = strlen($set);
247 
248  foreach ($this->readAttributes() as $name => $value) {
249  if ($set === substr($name, 0, $strlen)) {
250  $out[substr($name, $strlen)] = $value;
251  }
252  }
253 
254  return $out;
255  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::readCustomAttributesAsList (   $set)

Read custom attributes values as a list.

Parameters
string$setSet name.
Returns
array

Definition at line 263 of file Concrete.php.

264  {
265  $out = [];
266 
267  foreach ($this->readCustomAttributes($set) as $name => $value) {
268  $out[$name] = explode(' ', $value);
269  }
270 
271  return $out;
272  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::removeAttribute (   $name)

Remove an attribute.

Parameters
string$nameName.
Returns
void

Definition at line 367 of file Concrete.php.

368  {
369  unset($this->_htmlAttributes[$name]);
370 
371  return;
372  }
Hoa\Xyl\Interpreter\Html\Concrete::writeAttribute (   $name,
  $value 
)

Write an attribute. If the attribute does not exist, it will be created.

Parameters
string$nameName.
string$valueValue.
Returns
void

Definition at line 334 of file Concrete.php.

335  {
336  $this->_htmlAttributes[$name] = $value;
337 
338  return;
339  }

Here is the caller graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::writeAttributes ( Array  $attributes)

Write attributes. If an attribute does not exist, it will be created.

Parameters
array$attributesAttributes.
Returns
void

Definition at line 317 of file Concrete.php.

318  {
319  foreach ($attributes as $name => $value) {
320  $this->writeAttribute($name, $value);
321  }
322 
323  return;
324  }

Here is the call graph for this function:

Hoa\Xyl\Interpreter\Html\Concrete::writeCustomAttributes (   $set,
Array  $pairs 
)

Write custom attributes (as a set). For example: <component data-abc="def" data-uvw="xyz"> “data” is a custom attribute, so the $set.

Parameters
string$setSet name.
array$pairsPairs of attribute/value (e.g. abc => def, uvw => xyz).
Returns
void

Definition at line 352 of file Concrete.php.

353  {
354  foreach ($pairs as $attribute => $value) {
355  $this->writeAttribute($set . '-' . $attribute, $value);
356  }
357 
358  return;
359  }

Here is the call graph for this function:

Member Data Documentation

Hoa\Xyl\Interpreter\Html\Concrete::$_attributesMapping = …
staticprotected

Definition at line 59 of file Concrete.php.

Hoa\Xyl\Interpreter\Html\Concrete::$_contentFlow = 2
protected

Definition at line 81 of file Concrete.php.

Hoa\Xyl\Interpreter\Html\Concrete::$_htmlAttributes = []
protected

Definition at line 66 of file Concrete.php.

Hoa\Xyl\Interpreter\Html\Concrete::$_htmlAttributesType = []
protected

Definition at line 73 of file Concrete.php.


The documentation for this class was generated from the following file: