You are here

public function RulesFormsStructureWrapper::get in Rules Forms Support 7.2

Overrides EntityStructureWrapper::get() to ensure data is properly wrapped.

Overrides EntityStructureWrapper::get

File

includes/rules_forms.wrapper.inc, line 16
Manages and Process Form structure.

Class

RulesFormsStructureWrapper
Base metadata wrapper for Rules Forms data structures.

Code

public function get($name) {

  // Look it up in the cache if possible.
  if (!array_key_exists($name, $this->cache)) {

    // Try to get the property info without the hash. If this fails,
    // add the hash mark to the $name. This allows us to support chaining
    // with element attribute #names which are otherwise invalid PHP code.
    try {
      $info = $this
        ->getPropertyInfo($name);
    } catch (EntityMetadataWrapperException $e) {
      $name = '#' . $name;
    }
    if (!empty($info) || ($info = $this
      ->getPropertyInfo($name))) {
      $info += array(
        'parent' => $this,
        'name' => $name,
        'langcode' => $this->langcode,
        'property defaults' => array(),
      );
      $info['property defaults'] += $this->info['property defaults'];

      // Check if this is a form element attribute and wrap it if necessary.
      if (!empty($info['attribute info'])) {
        $this->cache[$name] = new RulesFormsAttributeWrapper($info['type'], NULL, $info);
      }
      else {
        $this->cache[$name] = rules_wrap_data(NULL, $info, TRUE);
      }
    }
    else {
      throw new EntityMetadataWrapperException('There is no property ' . check_plain($name) . " for this entity.");
    }
  }
  return $this->cache[$name];
}