Prado\Data\SqlMap\DataMapper\TPropertyAccess::has PHP Метод

has() публичный статический Метод

public static has ( $object, $path ) : boolean
Результат boolean true if property path is valid
    public static function has($object, $path)
    {
        if (!is_array($object) && !is_object($object)) {
            return false;
        }
        $properties = explode('.', $path);
        foreach ($properties as $prop) {
            if (is_array($object) || $object instanceof \ArrayAccess) {
                if (array_key_exists($prop, $object)) {
                    $object = $object[$prop];
                } else {
                    return false;
                }
            } else {
                if (is_object($object)) {
                    $getter = 'get' . $prop;
                    if (method_exists($object, $getter) && is_callable(array($object, $getter))) {
                        $object = $object->{$getter}();
                    } else {
                        if (in_array($prop, array_keys(get_object_vars($object)))) {
                            $object = $object->{$prop};
                        } elseif (method_exists($object, '__get') && is_callable(array($object, '__get'))) {
                            $object = $object->{$prop};
                        } else {
                            return false;
                        }
                    }
                } else {
                    return false;
                }
            }
        }
        return true;
    }

Usage Example

 /**
  * Load cache models from xml mapping.
  * @param SimpleXmlElement cache node.
  */
 protected function loadCacheModel($node)
 {
     $cacheModel = new TSqlMapCacheModel();
     $properties = array('id', 'implementation');
     foreach ($node->attributes() as $name => $value) {
         if (in_array(strtolower($name), $properties)) {
             $cacheModel->{'set' . $name}((string) $value);
         }
     }
     $cache = Prado::createComponent($cacheModel->getImplementationClass(), $cacheModel);
     $this->setObjectPropFromNode($cache, $node, $properties);
     foreach ($node->xpath('property') as $propertyNode) {
         $name = $propertyNode->attributes()->name;
         if ($name === null || $name === '') {
             continue;
         }
         $value = $propertyNode->attributes()->value;
         if ($value === null || $value === '') {
             continue;
         }
         if (!TPropertyAccess::has($cache, $name)) {
             continue;
         }
         TPropertyAccess::set($cache, $name, $value);
     }
     $this->loadFlushInterval($cacheModel, $node);
     $cacheModel->initialize($cache);
     $this->_manager->addCacheModel($cacheModel);
     foreach ($node->xpath('flushOnExecute') as $flush) {
         $this->loadFlushOnCache($cacheModel, $node, $flush);
     }
 }
All Usage Examples Of Prado\Data\SqlMap\DataMapper\TPropertyAccess::has
TPropertyAccess