Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->submitCustomerForm($form, $form_state);
     $values = $form_state->getValues();
     $order = $this->storage->create(['type' => $values['type'], 'mail' => $values['mail'], 'uid' => [$values['uid']], 'store_id' => [$values['store_id']]]);
     $order->save();
     // Redirect to the edit form to complete the order.
     $form_state->setRedirect('entity.commerce_order.edit_form', ['commerce_order' => $order->id()]);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->submitCustomerForm($form, $form_state);
     $values = $form_state->getValues();
     $order_data = ['type' => $values['type'], 'mail' => $values['mail'], 'uid' => [$values['uid']], 'store_id' => [$values['store_id']]];
     if (!empty($values['custom_placed_date']) && !empty($values['placed'])) {
         $order_data['placed'] = $values['placed']->getTimestamp();
     }
     $order = $this->storage->create($order_data);
     $order->save();
     // Redirect to the edit form to complete the order.
     $form_state->setRedirect('entity.commerce_order.edit_form', ['commerce_order' => $order->id()]);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function create(array $values = array())
 {
     $store_config = \Drupal::config('uc_store.settings');
     // Set the primary email address.
     if (empty($values['primary_email']) && !empty($values['uid'])) {
         if ($account = User::load($values['uid'])) {
             $values['primary_email'] = $account->mail;
         }
     }
     // Set the default order status.
     if (empty($values['order_status'])) {
         $values['order_status'] = uc_order_state_default('in_checkout');
     }
     // Set the default currency.
     if (empty($values['currency'])) {
         $values['currency'] = $store_config->get('currency.code');
     }
     // Set the default country codes.
     if (empty($values['billing_country'])) {
         $values['billing_country'] = $store_config->get('address.country');
     }
     if (empty($values['delivery_country'])) {
         $values['delivery_country'] = $store_config->get('address.country');
     }
     // Set the created time to now.
     if (empty($values['created'])) {
         $values['created'] = REQUEST_TIME;
     }
     return parent::create($values);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  *
  * @param array $values
  *   An array of values to set, keyed by property name. A value for the
  *   vocabulary ID ('vid') is required.
  */
 public function create(array $values = array()) {
   // Save new terms with no parents by default.
   if (empty($values['parent'])) {
     $values['parent'] = array(0);
   }
   $entity = parent::create($values);
   return $entity;
 }
Esempio n. 5
0
 /**
  * Test external destinations.
  */
 public function testExternal()
 {
     $redirect = $this->storage->create();
     $redirect->setSource('a-path');
     // @todo Redirect::setRedirect() assumes that all redirects are internal.
     $redirect->redirect_redirect->set(0, ['uri' => 'https://www.example.org']);
     $redirect->setStatusCode(301);
     $redirect->save();
     $this->assertRedirect('a-path', 'https://www.example.org');
 }
 /**
  * {@inheritdoc}
  */
 public function create(array $values = [])
 {
     /** @var \Drupal\payment\Entity\PaymentInterface $payment */
     $payment = parent::create($values);
     $payment_type = $this->paymentTypeManager->createInstance($values['bundle']);
     $payment_type->setPayment($payment);
     $payment->get('payment_type')->setValue($payment_type);
     $status = $this->paymentStatusManager->createInstance('payment_created')->setCreated(time());
     $payment->setPaymentStatus($status);
     return $payment;
 }
 /**
  * Tests groupby with filters.
  */
 public function testGroupByCountOnlyFilters()
 {
     // Check if GROUP BY and HAVING are included when a view
     // doesn't display SUM, COUNT, MAX, etc. functions in SELECT statement.
     for ($x = 0; $x < 10; $x++) {
         $this->storage->create(array('name' => 'name1'))->save();
     }
     $view = Views::getView('test_group_by_in_filters');
     $this->executeView($view);
     $this->assertTrue(strpos($view->build_info['query'], 'GROUP BY'), 'Make sure that GROUP BY is in the query');
     $this->assertTrue(strpos($view->build_info['query'], 'HAVING'), 'Make sure that HAVING is in the query');
 }
Esempio n. 8
0
 /**
  * Test external destinations.
  */
 public function testExternal()
 {
     $redirect = $this->storage->create();
     $redirect->setSource('a-path');
     // @todo Redirect::setRedirect() assumes that all redirects are internal.
     $redirect->redirect_redirect->set(0, ['uri' => 'https://www.example.org']);
     $redirect->setStatusCode(301);
     $redirect->save();
     $this->assertRedirect('a-path', 'https://www.example.org');
     $this->drupalLogin($this->adminUser);
     $this->drupalPostForm('admin/config/search/redirect/settings', ['redirect_deslash' => 1], t('Save configuration'));
     $this->drupalGet('/2015/10/10/');
     $this->assertResponse(404);
 }
 /**
  * @covers ::create
  */
 public function testCreate()
 {
     $language_manager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
     $language = new Language(array('id' => 'en'));
     $language_manager->expects($this->any())->method('getCurrentLanguage')->will($this->returnValue($language));
     $this->container->set('language_manager', $language_manager);
     $this->container->set('entity.manager', $this->entityManager);
     $this->container->set('module_handler', $this->moduleHandler);
     $entity = $this->getMockBuilder('Drupal\\Core\\Entity\\ContentEntityBase')->disableOriginalConstructor()->setMethods(array('id'))->getMockForAbstractClass();
     $this->entityType->expects($this->atLeastOnce())->method('id')->will($this->returnValue($this->entityTypeId));
     $this->entityType->expects($this->atLeastOnce())->method('getClass')->will($this->returnValue(get_class($entity)));
     $this->entityType->expects($this->atLeastOnce())->method('getKeys')->will($this->returnValue(array('id' => 'id')));
     // ContentEntityStorageBase iterates over the entity which calls this method
     // internally in ContentEntityBase::getProperties().
     $this->entityManager->expects($this->once())->method('getFieldDefinitions')->will($this->returnValue(array()));
     $this->entityType->expects($this->atLeastOnce())->method('isRevisionable')->will($this->returnValue(FALSE));
     $this->entityManager->expects($this->atLeastOnce())->method('getDefinition')->with($this->entityType->id())->will($this->returnValue($this->entityType));
     $this->setUpEntityStorage();
     $entity = $this->entityStorage->create();
     $entity->expects($this->atLeastOnce())->method('id')->will($this->returnValue('foo'));
     $this->assertInstanceOf('Drupal\\Core\\Entity\\EntityInterface', $entity);
     $this->assertSame('foo', $entity->id());
     $this->assertTrue($entity->isNew());
 }