/**
* Implements hook_theme_suggestions_page_alter().
*/
function my_module_theme_suggestions_page_alter(array &$suggestions, array $variables) {
$node_revision = \Drupal::routeMatch()->getParameter('node_revision');
This file contains 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 | |
/** | |
* Controller. Implements ContainerInjectionInterface | |
*/ | |
namespace Drupal\gurei\Controller; | |
use Drupal\Core\Controller\ControllerBase; | |
use Drupal\Core\DependencyInjection\ContainerInjectionInterface; | |
use Drupal\gurei\Service\CompanyService; | |
use Symfony\Component\DependencyInjection\ContainerInterface; |
This file contains 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\field\Entity\FieldStorageConfig; | |
use \Drupal\field\Entity\FieldConfig; | |
function mymodule_update_9001() { | |
$database = \Drupal::database(); | |
$table = 'node__field_name'; | |
$entity_type = 'node'; | |
$field_name = 'field_name'; |
This file contains 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\my_module; | |
use Drupal\Core\Entity\Sql\SqlContentEntityStorage; | |
use Drupal\Core\Field\BaseFieldDefinition; | |
use Drupal\Core\Field\FieldStorageDefinitionInterface; | |
/** | |
* Adds a new property to an existing field type. |
This file contains 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\my_module\Controller; | |
use Drupal\Core\Controller\ControllerBase; | |
/** | |
* Debug access. | |
*/ | |
class DebugAccessController extends ControllerBase { |
This file contains 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 | |
/** | |
* @file | |
*/ | |
namespace Drupal\my_module\Plugin\views\filter; | |
use Drupal\views\Plugin\views\display\DisplayPluginBase; | |
use Drupal\views\Plugin\views\filter\InOperator; |
This file contains 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 | |
/** | |
* @file | |
*/ | |
namespace Drupal\my_module\Plugin\Field\FieldFormatter; | |
use Drupal\Core\Field\FormatterBase; | |
use Drupal\Core\Field\FieldItemListInterface; | |
/** |
$subdivisionRepo = \Drupal::service('address.subdivision_repository');
$address = $node->get('field_address')->first()->toArray();
$city = $address['locality'];
// $subdivisionRepo->get() returns an object of type CommerceGuys\Addressing\Subdivision\Subdivision.
$state = $subdivisionRepo->get($address['administrative_area'], [$address['country_code']])->getName();
NewerOlder