Skip to content

Instantly share code, notes, and snippets.

Create tag

git tag -a v1.9.3 -m "v1.9.3"

Push tag

git push origin tag v1.9.3

Delete remote tag

<?php
// LOAD
// You can load up the menu tree with MenuLinkTree::load, which will give you an array of menu links to work with. From there it's just a matter of looping through and getting what you need, e.g.
$tree = \Drupal::menuTree()->load('main', new \Drupal\Core\Menu\MenuTreeParameters());
foreach ($tree as $item) {
$title = $item->link->getTitle();
$url_obj = $item->link->getUrlObject();
$has_children = $item->hasChildren;
// etc...

EntityQuery Conditions

The EntityQuery class can be loaded manually (if you know the entity type):

$query = \Drupal::service('entity_type.manager')->getStorage('node')->getQuery();

public function condition($field, $value = NULL, $operator = NULL, $langcode = NULL);

The $operator can take one of several options see core/lib/Drupal/Core/Entity/Query/QueryInterface.php::condition

<?php
// node, block, block_content, user, view, fiel, taxonomy_term, menu, menu_link_content, migration, ...
$storage = 'block';
$service = \Drupal::service('entity_type.manager')->getStorage($storage);
// LOAD
// One entity
$entity = $service->load($id);

Make Strings Translatable

Placeholders

@variable

Use this style of placeholder for most use-cases. Special characters in the text will be converted to HTML entities.

t('Hello @name, welcome back!', array('@name' => $user->getDisplayName()));

Output example:

Para acceder al valor de un campo field_date:

$timestamp = $node->field_date->date->getTimestamp();
  1. Poner el código sin la carpeta node_modules y platforms.

  2. Actualizar ionic y cordova:

    $ sudo npm uninstall ionic cordova
    $ sudo npm install ionic cordova
    
  3. Ejecutar dentro del proyecto: