Grido\Grid::getProperty PHP Méthode

getProperty() public méthode

A simple wrapper around symfony/property-access with Nette Database dot notation support.
public getProperty ( array | object $object, string $name ) : mixed
$object array | object
$name string
Résultat mixed
    public function getProperty($object, $name)
    {
        if ($object instanceof \Nette\Database\Table\IRow && \Nette\Utils\Strings::contains($name, '.')) {
            $parts = explode('.', $name);
            foreach ($parts as $item) {
                if (is_object($object)) {
                    $object = $object->{$item};
                }
            }
            return $object;
        }
        if (is_array($object)) {
            $name = "[{$name}]";
        }
        return $this->getPropertyAccessor()->getValue($object, $name);
    }

Usage Example

 /**
  * @inheritdoc
  */
 public function getProperty($object, $name)
 {
     $propertyAccessor = $this->getPropertyAccessor();
     if ($propertyAccessor instanceof EntityArrayAccessor) {
         return $propertyAccessor->getValue($object, $name);
     }
     return parent::getProperty($object, $name);
 }