src/Auth/AclRepository.php
protected function normalizeAclPresence($data)
    {
        if ( ! $data) {
            // @codeCoverageIgnoreStart
            return [];
            // @codeCoverageIgnoreEnd
        }

        if ($data instanceof AclPresenceInterface) {

            $data = [$data];

        } elseif (is_array($data) && ! Arr::isAssoc($data)) {

            $presences = [];

            foreach ($data as $nestedData) {

                if (is_array($nestedData)) {
                    $nestedData = new AclPresence($nestedData);
                }

                if ( ! ($nestedData instanceof AclPresenceInterface)) {
                    throw new UnexpectedValueException(
                        'ACL presence data from array provided by module is not an array or ACL presence instance'
                    );
                }

                $presences[] = $nestedData;
            }

            $data = $presences;

        } else {

            $data = [ new AclPresence($data) ];
        }

        /** @var AclPresenceInterface[] $data */

        // Now normalized to an array with one or more ACL presences.
        // Make sure the permission children are listed as simple strings.
        foreach ($data as $index => $presence) {

            $data[ $index ]->setPermissions($presence->permissions());
        }

        return $data;
    }
protected function normalizeAclPresence($data)
    {
        if ( ! $data) {
            // @codeCoverageIgnoreStart
            return [];
            // @codeCoverageIgnoreEnd
        }

        if ($data instanceof AclPresenceInterface) {

            $data = [$data];

        } elseif (is_array($data) && ! Arr::isAssoc($data)) {

            $presences = [];

            foreach ($data as $nestedData) {

                if (is_array($nestedData)) {
                    $nestedData = new AclPresence($nestedData);
                }

                if ( ! ($nestedData instanceof AclPresenceInterface)) {
                    throw new UnexpectedValueException(
                        'ACL presence data from array provided by module is not an array or ACL presence instance'
                    );
                }

                $presences[] = $nestedData;
            }

            $data = $presences;

        } else {

            $data = [ new AclPresence($data) ];
        }

        /** @var AclPresenceInterface[] $data */

        // Now normalized to an array with one or more ACL presences.
        // Make sure the permission children are listed as simple strings.
        foreach ($data as $index => $presence) {

            $data[ $index ]->setPermissions($presence->permissions());
        }

        return $data;
    }
protected function normalizeAclPresence ( $ data ) { if ( ! $ data ) { // @codeCoverageIgnoreStart return [ ] ; // @codeCoverageIgnoreEnd } if ( $ data instanceof AclPresenceInterface ) { $ data = [ $ data ] ; } elseif ( is_array ( $ data ) && ! Arr :: isAssoc ( $ data ) ) { $ presences = [ ] ; foreach ( $ data as $ nestedData ) { if ( is_array ( $ nestedData ) ) { $ nestedData = new AclPresence ( $ nestedData ) ; } if ( ! ( $ nestedData instanceof AclPresenceInterface ) ) { throw new UnexpectedValueException ( 'ACL presence data from array provided by module is not an array or ACL presence instance' ) ; } $ presences [ ] = $ nestedData ; } $ data = $ presences ; } else { $ data = [ new AclPresence ( $ data ) ] ; } /** @var AclPresenceInterface[] $data */ // Now normalized to an array with one or more ACL presences. // Make sure the permission children are listed as simple strings. foreach ( $ data as $ index => $ presence ) { $ data [ $ index ] -> setPermissions ( $ presence -> permissions ( ) ) ; } return $ data ; }
Normalizes ACL presence data to an array of ACLPresence instances.

@param $data
@return AclPresenceInterface[]
Normalizes ACL presence data to an array of ACLPresence instances .