This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\api_client_example\Service; | |
use Drupal\Component\Serialization\Json; | |
use Drupal\Core\Site\Settings; | |
use GuzzleHttp\ClientInterface; | |
/** | |
* Class ApiClientInterface. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\pathauto\PathautoState; | |
$node->set('path', ['alias' => $extra_data['URL'], 'pathauto' => PathautoState::SKIP]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\Core\Database\Query\PagerSelectExtender; | |
use Drupal\Core\Database\Query\TableSortExtender; | |
// Field = column name in your table. | |
$header = [ | |
'status' => ['data' => $this->t('Order status'), 'field' => 'status'], | |
'order_id' => ['data' => $this->t('Order number'), 'field' => 'order_id', 'sort' => 'desc'], | |
'placed' => ['data' => $this->t('Order date'), 'field' => 'placed'], | |
'seller' => ['data' => $this->t('Seller'), 'field' => 'seller'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\Component\Utility\SortArray; | |
// Sort by `weight` | |
$exapmle_array = [ | |
['nid' => 21, 'weight' => -10], | |
['nid' => 3, 'weight' => 10], | |
['nid' => 1, 'weight' => -100], | |
]; | |
uasort($data, [SortArray::class, 'sortByWeightElement']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\gurei\Form; | |
use Drupal\Component\Utility\NestedArray; | |
use Drupal\Core\Cache\Cache; | |
use Drupal\Core\Entity\EntityTypeManagerInterface; | |
use Drupal\Core\Form\FormBase; | |
use Drupal\Core\Form\FormStateInterface; | |
use Drupal\Core\State\StateInterface; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function buildForm(array $form, FormStateInterface $form_state) { | |
$form = parent::buildForm($form, $form_state); | |
if ($this->entities) { | |
/** @var \Drupal\commerce_promotion\Entity\Promotion $promotion */ | |
foreach ($this->entities as $promotion) { | |
$form['promotions'][$promotion->id()]['name'] = [ | |
'name' => $form['promotions'][$promotion->id()]['name'], | |
]; | |
$has_parent = FALSE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Workspaces-specific entity query implementation. | |
*/ | |
class QueryFactory extends BaseQueryFactory { | |
/** | |
* {@inheritdoc} | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\Core\Link; | |
$link = Link::createFromRoute(t('My shopping lists'), 'commerce_wishlist.page', [], ['set_active_class' => TRUE]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
destination: | |
plugin: entity:user | |
# If the destination is going to update an existing user, you can optionally | |
# specify the properties that should be overwritten. For example, if the | |
# migration tries to import user 31 and user 31 already exists in the | |
# destination database, only the 'name' and 'mail' properties of the user | |
# will be overwritten. If user 31 doesn't exist, it will be created and | |
# the overwrite_properties list will be ignored. | |
overwrite_properties: | |
- name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\gurei\Service; | |
use Drupal\Core\StringTranslation\StringTranslationTrait; | |
use Drupal\Core\StringTranslation\TranslationInterface; | |
/** | |
* Class CompanyService. | |
*/ | |
class CompanyService { |
NewerOlder