public function mapPolicies(array $data)
    {
        /**
         * @var \eZ\Publish\SPI\Persistence\User\Policy[]
         */
        $policies = array();
        foreach ($data as $row) {
            $policyId = $row['ezpolicy_id'];
            if (!isset($policies[$policyId]) && ($policyId !== null)) {
                $originalId = null;
                if ($row['ezpolicy_original_id']) {
                    $originalId = (int)$row['ezpolicy_original_id'];
                } elseif ($row['ezrole_version']) {
                    $originalId = (int)$policyId;
                }

                $policies[$policyId] = new Policy(
                    array(
                        'id' => (int)$policyId,
                        'roleId' => (int)$row['ezrole_id'],
                        'originalId' => $originalId,
                        'module' => $row['ezpolicy_module_name'],
                        'function' => $row['ezpolicy_function_name'],
                        'limitations' => '*', // limitations must be '*' if not a non empty array of limitations
                    )
                );
            }

            if (!$row['ezpolicy_limitation_identifier']) {
                continue;
            } elseif ($policies[$policyId]->limitations === '*') {
                $policies[$policyId]->limitations = array();
            }

            if (!isset($policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']])) {
                $policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']] = array($row['ezpolicy_limitation_value_value']);
            } elseif (!in_array($row['ezpolicy_limitation_value_value'], $policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']])) {
                $policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']][] = $row['ezpolicy_limitation_value_value'];
            }
        }

        return array_values($policies);
    }
public function mapPolicies(array $data)
    {
        /**
         * @var \eZ\Publish\SPI\Persistence\User\Policy[]
         */
        $policies = array();
        foreach ($data as $row) {
            $policyId = $row['ezpolicy_id'];
            if (!isset($policies[$policyId]) && ($policyId !== null)) {
                $originalId = null;
                if ($row['ezpolicy_original_id']) {
                    $originalId = (int)$row['ezpolicy_original_id'];
                } elseif ($row['ezrole_version']) {
                    $originalId = (int)$policyId;
                }

                $policies[$policyId] = new Policy(
                    array(
                        'id' => (int)$policyId,
                        'roleId' => (int)$row['ezrole_id'],
                        'originalId' => $originalId,
                        'module' => $row['ezpolicy_module_name'],
                        'function' => $row['ezpolicy_function_name'],
                        'limitations' => '*', // limitations must be '*' if not a non empty array of limitations
                    )
                );
            }

            if (!$row['ezpolicy_limitation_identifier']) {
                continue;
            } elseif ($policies[$policyId]->limitations === '*') {
                $policies[$policyId]->limitations = array();
            }

            if (!isset($policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']])) {
                $policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']] = array($row['ezpolicy_limitation_value_value']);
            } elseif (!in_array($row['ezpolicy_limitation_value_value'], $policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']])) {
                $policies[$policyId]->limitations[$row['ezpolicy_limitation_identifier']][] = $row['ezpolicy_limitation_value_value'];
            }
        }

        return array_values($policies);
    }
public function mapPolicies ( array $ data ) { /**
         * @var \eZ\Publish\SPI\Persistence\User\Policy[]
         */ $ policies = array ( ) ; foreach ( $ data as $ row ) { $ policyId = $ row [ 'ezpolicy_id' ] ; if ( ! isset ( $ policies [ $ policyId ] ) && ( $ policyId !== null ) ) { $ originalId = null ; if ( $ row [ 'ezpolicy_original_id' ] ) { $ originalId = ( int ) $ row [ 'ezpolicy_original_id' ] ; } elseif ( $ row [ 'ezrole_version' ] ) { $ originalId = ( int ) $ policyId ; } $ policies [ $ policyId ] = new Policy ( array ( 'id' => ( int ) $ policyId , 'roleId' => ( int ) $ row [ 'ezrole_id' ] , 'originalId' => $ originalId , 'module' => $ row [ 'ezpolicy_module_name' ] , 'function' => $ row [ 'ezpolicy_function_name' ] , 'limitations' => '*' , // limitations must be '*' if not a non empty array of limitations ) ) ; } if ( ! $ row [ 'ezpolicy_limitation_identifier' ] ) { continue ; } elseif ( $ policies [ $ policyId ] -> limitations === '*' ) { $ policies [ $ policyId ] -> limitations = array ( ) ; } if ( ! isset ( $ policies [ $ policyId ] -> limitations [ $ row [ 'ezpolicy_limitation_identifier' ] ] ) ) { $ policies [ $ policyId ] -> limitations [ $ row [ 'ezpolicy_limitation_identifier' ] ] = array ( $ row [ 'ezpolicy_limitation_value_value' ] ) ; } elseif ( ! in_array ( $ row [ 'ezpolicy_limitation_value_value' ] , $ policies [ $ policyId ] -> limitations [ $ row [ 'ezpolicy_limitation_identifier' ] ] ) ) { $ policies [ $ policyId ] -> limitations [ $ row [ 'ezpolicy_limitation_identifier' ] ] [ ] = $ row [ 'ezpolicy_limitation_value_value' ] ; } } return array_values ( $ policies ) ; }
Map policy data to an array of policies.

@param array $data

@return \eZ\Publish\SPI\Persistence\User\Policy
Map policy data to an array of policies .