Jackalope\Query\Row::__construct PHP Method

__construct() public method

Create new Row instance.
public __construct ( Jackalope\FactoryInterface $factory, ObjectManager $objectManager, array $columns )
$factory Jackalope\FactoryInterface the object factory
$objectManager Jackalope\ObjectManager
$columns array array of array with fields dcr:name and dcr:value
    public function __construct(FactoryInterface $factory, ObjectManager $objectManager, $columns)
    {
        $this->factory = $factory;
        $this->objectManager = $objectManager;
        // TODO all of the normalization logic should better be moved to the Jackrabbit transport layer
        foreach ($columns as $column) {
            $pos = strpos($column['dcr:name'], '.');
            if (false !== $pos) {
                // jackalope-doctrine-dbal has the selector name both in the dcr:name and as separate column dcr:selectorName
                $selectorName = substr($column['dcr:name'], 0, $pos);
                $column['dcr:name'] = substr($column['dcr:name'], $pos + 1);
            } elseif (isset($column['dcr:selectorName'])) {
                $selectorName = $column['dcr:selectorName'];
            } else {
                $selectorName = '';
            }
            if ('jcr:score' === $column['dcr:name']) {
                $this->score[$selectorName] = (double) $column['dcr:value'];
            } elseif ('jcr:path' === $column['dcr:name']) {
                $this->path[$selectorName] = $column['dcr:value'];
            } else {
                if ('jcr:primaryType' === substr($column['dcr:name'], -15)) {
                    $this->defaultSelectorName = $selectorName;
                }
                $this->columns[] = $column;
                $this->values[$selectorName][$column['dcr:name']] = $column['dcr:value'];
            }
        }
        if (null === $this->defaultSelectorName && 1 === count($this->path)) {
            $this->defaultSelectorName = key($this->path);
        }
        if (isset($this->values[''])) {
            foreach ($this->values[''] as $key => $value) {
                $this->values[$this->defaultSelectorName][$key] = $value;
            }
            unset($this->values['']);
        }
    }