Neos\Flow\Persistence\Doctrine\Migrations\Version20141113173712::migrateAccountRolesDown PHP Метод

migrateAccountRolesDown() защищенный Метод

Generate SQL statements to migrate accounts down to embedded roles.
protected migrateAccountRolesDown ( ) : void
Результат void
    protected function migrateAccountRolesDown()
    {
        $allRolesAndAccounts = array();
        $accountRolesResult = $this->connection->executeQuery('SELECT persistence_object_identifier, roleidentifiers FROM typo3_flow_security_account');
        while ($accountIdentifierAndRoles = $accountRolesResult->fetch(\PDO::FETCH_ASSOC)) {
            $accountIdentifier = $accountIdentifierAndRoles['persistence_object_identifier'];
            $roleIdentifiers = explode(',', $accountIdentifierAndRoles['roleidentifiers']);
            foreach ($roleIdentifiers as $roleIdentifier) {
                if (!isset($allRolesAndAccounts[$roleIdentifier])) {
                    $allRolesAndAccounts[$roleIdentifier] = array();
                }
                $allRolesAndAccounts[$roleIdentifier][] = $accountIdentifier;
            }
        }
        $this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('Everybody', 'system')");
        $this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('Anonymous', 'system')");
        $this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES ('AuthenticatedUser', 'system')");
        foreach ($allRolesAndAccounts as $roleIdentifier => $accountIdentifiers) {
            $this->addSql("INSERT INTO typo3_flow_security_policy_role (identifier, sourcehint) VALUES (" . $this->connection->quote($roleIdentifier) . ", 'policy')");
            foreach ($accountIdentifiers as $accountIdentifier) {
                $this->addSql("INSERT INTO typo3_flow_security_account_roles_join (flow_security_account, flow_policy_role) VALUES (" . $this->connection->quote($accountIdentifier) . ", " . $this->connection->quote($roleIdentifier) . ")");
            }
        }
    }