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
use Drupal\commerce_product\Entity\Product; | |
use Drupal\field_collection\Entity\FieldCollectionItem; | |
$product = Product::load(34); | |
$fc_item = FieldCollectionItem::create([ | |
'field_name' => 'ENTITY_FIELD_COLLECTION_FIELD', | |
]); | |
$fc_item->set('field_horizontal_position', $horizontal_pos); | |
$fc_item->set('field_vertical_position', $vertical_pos); |
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\builder_module\Element; | |
use Drupal\Core\Form\FormStateInterface; | |
use Drupal\Core\Render\Element\FormElement; | |
/** | |
* Provides a form element for numeric range. | |
* |
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
sudo certbot --nginx -d site.com.ua -d www.site.com.ua | |
more info: | |
https://www.digitalocean.com/community/tutorials/how-to-set-up-let-s-encrypt-certificates-for-multiple-apache-virtual-hosts-on-ubuntu-14-04 |
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
/** | |
* Implements hook_admin_paths(). | |
*/ | |
function global_price_table_admin_paths() { | |
$paths = array( | |
'node/*/global_price_table' => TRUE, | |
); | |
return $paths; | |
} |
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
$default_process_fn = \Drupal::service('element_info')->getInfoProperty('managed_file', '#process', NULL); | |
$form['field_photo'] = [ | |
'#type' => 'managed_file', | |
'#required' => TRUE, | |
'#title' => $this->getFieldTitle($product, 'field_photo'), | |
'#description' => $this->getFieldDescription($product, 'field_photo'), | |
'#upload_location' => 'public://', | |
'#process' => array_merge($default_process_fn, [[get_class($this), 'managedFileProcess']]), | |
'#upload_validators' => [ | |
'file_validate_extensions' => [ |
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
/** | |
* Implements hook_mail_alter(). | |
*/ | |
function MYMODULE_mail_alter(&$message) { | |
if ($message['key'] == 'register_confirmation_with_pass') { | |
$user = $message['params']['account']; | |
// If user account need to approve we ignore standard mail after registration | |
// because we have custom mails for this case. | |
if (lb_registration_account_need_to_approve($user)) { |
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
// Clean 'account' menu cache. | |
\Drupal\Core\Cache\Cache::invalidateTags(['config:system.menu.account']); |
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
$query = new EntityFieldQuery(); | |
$result = $query->entityCondition('entity_type', 'commerce_product') | |
->fieldCondition('field_brand', 'tid', 52) | |
->execute(); |
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
if (isset($form['#id']) && $form['#id'] == 'VIEW_FILTER_ID') { | |
$filters_list = array(); | |
// Get filters names. | |
foreach($form['#info'] as $filter_name => $filter_info) { | |
// Return filter name without 'filter-' prefix. | |
$filters_list[] = substr($filter_name, 7); | |
} | |
foreach($filters_list as $filter) { |
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
/** | |
* Implements hook_form_alter(). | |
*/ | |
function MODULE_form_alter(&$form, &$form_state, $form_id) { | |
// We prepared product type filter, code below must display only node types | |
// which have added content. | |
if (isset($form['#id']) && $form['#id'] == 'EXPLOSE_FILTER_FORM_ID') { | |
$selected_brand = menu_get_object('taxonomy_term', 2); |