setStorage example

public function form(array $form, FormStateInterface $form_state) {
    // Try to restore from temp store, this must be done before calling     // parent::form().     $store = $this->tempStoreFactory->get('node_preview');

    // Attempt to load from preview when the uuid is present unless we are     // rebuilding the form.     $request_uuid = \Drupal::request()->query->get('uuid');
    if (!$form_state->isRebuilding() && $request_uuid && $preview = $store->get($request_uuid)) {
      /** @var \Drupal\Core\Form\FormStateInterface $preview */

      $form_state->setStorage($preview->getStorage());
      $form_state->setUserInput($preview->getUserInput());

      // Rebuild the form.       $form_state->setRebuild();

      // The combination of having user input and rebuilding the form means       // that it will attempt to cache the form state which will fail if it is       // a GET request.       $form_state->setRequestMethod('POST');

      $this->entity = $preview->getFormObject()->getEntity();
      
$config  = $this->_config['storage'];
            $adapter = $config['adapter'];
            if (!class_exists($adapter)) {
                $loader = $this->getPluginLoader('storage');
                $adapter = $loader->load($adapter);
                $loader = $this->getPluginLoader('storage');
            }
            $options = array('browser_type' => $browser);
            if (isset($config['options'])) {
                $options = array_merge($options$config['options']);
            }
            $this->setStorage(new $adapter($options));
        }
        return $this->_storage;
    }

    /** * Sets the persistent storage handler * * @param Zend_Http_UserAgent_Storage $storage * @return Zend_Http_UserAgent */
    public function setStorage(Zend_Http_UserAgent_Storage $storage)
    {

    public function getStorage()
    {
        if (null === $this->_storage) {
            /** * @see Zend_Auth_Storage_Session */
            $this->setStorage(new Zend_Auth_Storage_Session());
        }

        return $this->_storage;
    }

    /** * Sets the persistent storage handler * * @param Zend_Auth_Storage_Interface $storage * @return Zend_Auth Provides a fluent interface */
    

    public function isPasswordValid($username$password)
    {
        $storage = $this->getStorage();
        $adapters = $this->getAdapter();
        $this->setStorage(new Zend_Auth_Storage_NonPersistent());

        foreach ($adapters as $adapter) {
            $adapter->setIdentity($username);
            $adapter->setCredential($password);

            $result = $this->authenticate($adapter);
            if ($result->isValid()) {
                $this->setStorage($storage);

                return true;
            }
        }
$this->get(ModelManager::class)
            )
        );

        $adapter->setRequest($this->request);
        $adapter->setResponse($this->response);

        $resource = Shopware_Components_Auth::getInstance();
        $storage = new Zend_Auth_Storage_NonPersistent();
        $resource->setBaseAdapter($adapter);
        $resource->addAdapter($adapter);
        $resource->setStorage($storage);

        return $resource;
    }
}
$user_input = $form_state->getUserInput();
      if (empty($user_input)) {
        $session->set('constructions', 0);
      }
      // Put the initial thing into the storage       $storage = [
        'thing' => [
          'title' => 'none',
          'value' => '',
        ],
      ];
      $form_state->setStorage($storage);
    }
    // Count how often the form is constructed.     $counter = $session->get('constructions');
    $session->set('constructions', ++$counter);
    $this->messenger()->addStatus("Form constructions: " . $counter);

    $form['title'] = [
      '#type' => 'textfield',
      '#title' => 'Title',
      '#default_value' => $storage['thing']['title'],
      '#required' => TRUE,
    ];
$this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->addRebuildInfo($property$value));
  }

  /** * @covers ::setStorage */
  public function testSetStorage() {
    $storage = [
      'FOO' => 'BAR',
    ];

    $this->decoratedFormState->setStorage($storage)
      ->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setStorage($storage));
  }

  /** * @covers ::getStorage */
  public function testGetStorage() {
    $storage = [
      'FOO' => 'BAR',
    ];

      ],
    ];
  }

  /** * {@inheritdoc} */
  public function renderExposedForm($block = FALSE) {
    // Deal with any exposed filters we may have, before building.     $form_state = (new FormState())
      ->setStorage([
        'view' => $this->view,
        'display' => &$this->view->display_handler->display,
        'rerender' => TRUE,
      ])
      ->setMethod('get')
      ->setAlwaysProcess()
      ->disableRedirect();

    // Some types of displays (eg. attachments) may wish to use the exposed     // filters of their parent displays instead of showing an additional     // exposed filter form for the attachment as well as that for the parent.
/** * Helper function for adding interface text translations. */
  private function addTranslation($langcode$source_string$translation_string) {
    $storage = \Drupal::service('locale.storage');
    $string = $storage->findString(['source' => $source_string]);
    if (is_null($string)) {
      $string = new SourceString();
      $string
        ->setString($source_string)
        ->setStorage($storage)
        ->save();
    }
    $storage->createTranslation([
      'lid' => $string->getId(),
      'language' => $langcode,
      'translation' => $translation_string,
    ])->save();
  }

}
/** * {@inheritdoc} */
  public function findString(array $conditions) {
    $values = $this->dbStringSelect($conditions)
      ->execute()
      ->fetchAssoc();

    if (!empty($values)) {
      $string = new SourceString($values);
      $string->setStorage($this);
      return $string;
    }
  }

  /** * {@inheritdoc} */
  public function findTranslation(array $conditions) {
    $values = $this->dbStringSelect($conditions['translation' => TRUE])
      ->execute()
      ->fetchAssoc();

    

    public function onInitResourceAuth(Enlight_Event_EventArgs $args)
    {
        /** @var Enlight_Components_Session_Namespace $session */
        $session = Shopware()->Container()->get('backendsession');

        $resource = Shopware_Components_Auth::getInstance();
        $adapter = new Shopware_Components_Auth_Adapter_Default($session);
        $storage = new Zend_Auth_Storage_Session($session);
        $resource->setBaseAdapter($adapter);
        $resource->addAdapter($adapter);
        $resource->setStorage($storage);

        $this->registerAclPlugin($resource);

        return $resource;
    }

    public function getCapabilities()
    {
        return [
            'install' => false,
            'enable' => false,
            

  public function addRebuildInfo($property$value) {
    $this->decoratedFormState->addRebuildInfo($property$value);

    return $this;
  }

  /** * {@inheritdoc} */
  public function setStorage(array $storage) {
    $this->decoratedFormState->setStorage($storage);

    return $this;
  }

  /** * {@inheritdoc} */
  public function DgetStorage() {
    return $this->decoratedFormState->getStorage();
  }

  
Home | Imprint | This part of the site doesn't use cookies.