Jackalope\Query\Row::getValue PHP Method

getValue() public method

{@inheritDoc}
public getValue ( $columnName )
    public function getValue($columnName)
    {
        if (false === strpos($columnName, '.')) {
            $columnName = $this->defaultSelectorName . '.' . $columnName;
        }
        $values = $this->getValues();
        if (!array_key_exists($columnName, $values)) {
            throw new ItemNotFoundException("Column '{$columnName}' not found");
        }
        $value = $values[$columnName];
        // According to JSR-283 6.7.39 a query should only return
        // single-valued properties. We join the values when it's a string
        // for multi-values boolean/binary values we can't provide a
        // defined result so we return null
        if (is_array($value)) {
            if (is_scalar($value[0]) && !is_bool($value[0])) {
                $value = implode(' ', $value);
            } else {
                $value = null;
            }
        }
        return $value;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Resolves permissions for given user.
  *
  * @param Row $row
  * @param UserInterface $user
  *
  * @return array
  */
 private function resolvePermissions(Row $row, UserInterface $user = null)
 {
     $permissions = [];
     if (null !== $user) {
         foreach ($user->getRoleObjects() as $role) {
             foreach (array_filter(explode(' ', $row->getValue(sprintf('role%s', $role->getId())))) as $permission) {
                 $permissions[$role->getId()][$permission] = true;
             }
         }
     }
     return $permissions;
 }
All Usage Examples Of Jackalope\Query\Row::getValue