Показаны сообщения с ярлыком drupal 8. Показать все сообщения
Показаны сообщения с ярлыком drupal 8. Показать все сообщения

21 янв. 2021 г.

Drupal 8. Entity API




Entity types in core come in two variants. Content & Config

 The Entity System is the API for entities manipulation (CRUD: create, read, update, delete). Entity validation has its own API (which could validate an Entity saved via REST, rather than a form, for example).

Entities are typed classes with methods


Configuration Entity
Used by the Configuration System. Supports translations and can provide custom defaults for installations. Configuration entities are stored within the common config database table as rows.
Content Entity
Consist of configurable and base fields, and can have revisions and support translations. Content entities are stored within a custom database table as rows. The table name is the same as the content entity "id", and the columns are defined by the entity's "baseFieldDefinitions" method.

Охватывает методы API общего объекта

  • Entity::create()
  • Entity::load()
  • Entity::save()
  • Entity::id()
  • Entity::bundle()
  • Entity::isNew()
  • Entity::label()


В Drupal 8 бандлы представляют собой тип контейнера для информации, которая содержит определения полей или настроек.



Annotations

Annotations are read and parsed at runtime by an annotation engine. Drupal 8 uses the Doctrine annotation parser, which turns it into an object that PHP can use.










17 янв. 2021 г.

Drupal 8. Drupal Console and Drush

Installation

https://hechoendrupal.gitbooks.io/drupal-console/en/index.html 

http://docs.drush.org/en/master/ 

https://www.webwash.net/drupal-cli-drush-and-drupal-console/


install drush via composer

$ composer global require drush/drush:dev-master

Установка с помощью приложения Composer

Перейти в папку с Drupal:

cd /path/to/drupal8.dev

Установка командой composer require:

composer require drupal/console:~1.0 \
--prefer-dist \
--optimize-autoloader

Скачать шаблон DrupalComposer

composer create-project \
drupal-composer/drupal-project:8.x-dev \
drupal8.dev \
--prefer-dist \
--no-progress \
--no-interaction

Обновить Drupal Console:

composer update drupal/console --with-dependencies

Установка пускового файла Drupal Console

С помощью командного приложения curl:

curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal

ИЛИ если командное приложение curl не установлено

php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar

Capabilities

https://github.com/hechoendrupal/drupal-console h

ttps://drushcommands.com/ 

https://pantheon.io/drupal-8/introduction-drush-and-drupal-console 

https://valuebound.com/resources/blog/developing-drupal-8-sites-a-smarter-way-drupal-console

Custom commands

https://hechoendrupal.gitbooks.io/drupal-console/en/extending/creating-custom-commands.html https://valuebound.com/resources/blog/how-to-write-custom-drush-commands-drupal-8 https://www.droptica.com/blog/your-own-drush-command-drupal-8/ https://drupalize.me/tutorial/drupal-console?p=2766 https://valuebound.com/resources/blog/power-of-drupal-console-in-drupal-8


13 янв. 2021 г.

Drupal 8: Services

 https://niklan.net/blog/150

Drupal 8 Authentication API

 https://niklan.net/blog/166


https://www.drupal.org/docs/8/core/modules/basic_auth/overview

Here is an example of a route that uses Basic Auth to authenticate users:

# core/modules/system/tests/modules/router_test_directory/router_test.routing.yml
module.router_test_11:
  path: '/router_test/test11'
  options:
    _auth: [ 'basic_auth' ]
  requirements:
    _user_is_logged_in: 'TRUE'
  defaults:
    _content: '\Drupal\router_test\TestContent::test11'

In order to access to /router_test/test11, you have to fill the Authentication header with a valid Drupal user who has permissions to access to that page.

Note that Basic Auth is NOT a means of logging into a Drupal site in order to make service GET requests that depend on the identity of the logged-in user (e.g. a views REST display that uses an Authored By relationship to return content belonging to the logged-in user). It is cookie authentication that makes views Relationships possible. See Using other authentication protocols for more on how to login from a client application and get the session cookie.

Drupal 8 Configuration

 


https://www.drupal.org/docs/8/modules/configuration-split/split-directory-structure

best method to organize configuration location is

sites/default/files/config/sync

Grouped splits: 


../config/

├── sync

│    config.yml

│     ...

└── splits

    ├── dev

    │    config.yml

    │     ...

    └── live

         config.yml


https://www.drupal.org/docs/8/configuration-management/changing-the-storage-location-of-the-sync-directory

https://www.drupal.org/docs/8/configuration-management/workflow-using-the-drupal-ui

https://www.drupal.org/docs/8/configuration-management/changing-the-storage-location-of-the-sync-directory


https://www.drupal.org/docs/8/configuration-management/workflow-using-drush


https://www.drupal.org/docs/8/configuration-management/workflow-using-drush

https://www.drupal.org/project/config_readonly


https://www.drupal.org/docs/8/api/configuration-api/configuration-override-system

https://www.drupal.org/docs/8/modules/configuration-split

https://www.drupal.org/project/config_split


https://www.drupal.org/docs/8/modules/configuration-split/cli-integration

https://www.drupal.org/docs/8/modules/configuration-split/per-environment-configuration

https://www.drupal.org/docs/8/configuration-management/file-system-based-workflow

https://www.drupal.org/docs/8/configuration-management/keeping-your-local-and-remote-sites-synchronized-drupal-8


https://medium.com/@ChandeepKhosa/easy-drupal-8-configuration-management-with-fellow-developers-743018498d6f



https://www.drupal.org/docs/8/modules/configuration-split/creating-a-simple-split-configuration-dev-modules-only-in-dev

in settings.php

$settings['config_exclude_modules'] = ['devel', 'stage_file_proxy'];

Configuration schema-metadata

https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-schemametadata

https://drupalbook.org/ru/docs/8/api/configuration-api/configuration-schemametadata