/*
Looks up the storage factory on the container and sets initial state
on the instance if desired.
 TODO: v2.0 - Remove options and legacyKey
function createStorage(context, key, modelKey, options) {
  const owner = getOwner(context);
  const factoryType = 'storage';
  const storageFactory = `${factoryType}:${key}`;

  let storageKey;

  owner.registerOptionsForType(factoryType, { instantiate: false });

  if (options.legacyKey) {
    deprecate('Using legacyKey has been deprecated and will be removed in version 2.0.0', false, {
      id: 'ember-local-storage.storageFor.options.legacyKey',
      until: '2.0.0',
      url: 'https://github.com/funkensturm/ember-local-storage#deprecations'
    });

    storageKey = options.legacyKey;
  } else {
    storageKey = modelKey ? `${storageFactory}:${modelKey}` : storageFactory;
  }

  storageKey = _buildKey(context, storageKey);

  const initialState = {},
    defaultState = {
      _storageKey: storageKey
    },
    StorageFactory = owner.lookup(storageFactory);

  if (!StorageFactory) {
    throw new TypeError(`Unknown StorageFactory: ${storageFactory}`);
  }

  if (typeof(StorageFactory.initialState) === 'function') {
    initialState._initialContent = StorageFactory.initialState.call(context);
  } else if (StorageFactory.initialState) {
    throw new TypeError('initialState property must be a function');
  }

  assign(initialState, defaultState);

  if (StorageFactory.create) {
    return StorageFactory.create(initialState);
  }

  return Ember.Object.create(StorageFactory);
}