Prose\UsingUsers::loadUsersFromFile PHP Метод

loadUsersFromFile() публичный Метод

NOTES: - Storyplayer calls this for you when you use the --users switch - it is safe to call this yourself from a story if you want to load additional users for any reason. however, Storyplayer will not manage saving these users for you - you WILL have to do that yourself
public loadUsersFromFile ( string $filename ) : DataSift\Stone\ObjectLib\BaseObject
$filename string the JSON file to load users from
Результат DataSift\Stone\ObjectLib\BaseObject
    public function loadUsersFromFile($filename)
    {
        // what are we doing?
        $log = usingLog()->startAction("load test users from '{$filename}'");
        // load the file
        $raw = @file_get_contents($filename);
        if (!$raw || empty($raw)) {
            throw new E5xx_ActionFailed(__METHOD__, "cannot open file '{$filename}' or file is empty");
        }
        $plainUsers = json_decode($raw);
        if ($plainUsers === null) {
            throw new E5xx_ActionFailed(__METHOD__, "file '{$filename}' contains invalid JSON");
        }
        if (!is_object($plainUsers)) {
            throw new E5xx_ActionFailed(__METHOD__, "file '{$filename}' must contain a JSON object");
        }
        // merge these in with any users we have already loaded
        $users = new BaseObject();
        $users->mergeFrom($plainUsers);
        // remember what we've loaded
        $this->st->setTestUsers($users);
        // all done
        $count = count(get_object_vars($users));
        $log->endAction("loaded {$count} test user(s)");
        return $users;
    }