SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
Свои типы Entity:
зачем и как
использовать
Entity
Bundle 1

Entity Type

Field 1

Bundle 2

Field 2

Bundle 3

Field 3
hook_entity_info()
function node_entity_info() {

'bundle keys' => array(

$return = array(

'bundle' => 'type',

'node' => array(

),

'label' => t('Node'),

'bundles' => array(),

'controller class' => 'NodeController',

//...

'base table' => 'node',

),

'revision table' => 'node_revision',

);

'fieldable' => TRUE,

// …

'entity keys' => array(

foreach (node_type_get_names() as $type => $name) {

'id' => 'nid',

$return['node']['bundles'][$type] = array(

'revision' => 'vid',

// ...

'bundle' => 'type',

);

'label' => 'title',

}

'language' => 'language',
),

return $return;
}
Drupal core
●
●
●
●
●
●

Node
Comment
User
Taxonomy Term
Taxonomy Vocabulary
File
Contrib Modules
●
●
●
●
●

Drupal Commerce
Rules
Profile 2
Message
Field Collection

...
Форма для заполнения
Имя

Email

О себе

Послать
Обработка данных
Результат
Требования
● Гибкость
● Расширяемость
● Несколько форм: разные поля,
схожий функционал
● Сжатые сроки

Entity + Bundles + Fields
Почему не ноды?
● Не нужны некоторые
свойства
● Нужны
дополнительные
свойства
● не нужен некоторый
функционал / хуки
● нужен свой
функционал

● Не нужны
комментарии
● Не нужны ревизии
● Не нужна система
доступов
(node_access())
● нужна своя система
доступов
● не нужна страница
/node/[nid]
Entity API
https://drupal.org/project/entity
Views, Rules
Экспорт / Features
Token (Entity Tokens)
Admin UI
entity_metadata_wrapper()
$node = node_load(1);
$wrapper = entity_metadata_wrapper('node', $node);
$wrapper->title->value();
$wrapper->author->name->value();
$wrapper->field_multiple->value();
foreach ($wrapper->field_multiple as $delta =>
$field_wrapper) {
$field_wrapper->value();
}
$wrapper->field_price->value();
$wrapper->field_price->amount_decimal->value()
$wrapper->title->set('another title');
$wrapper->body->value->set('Lorem Ipsum');
Entity без полей
●
●
●
●
●

Views
Rules
Token
Admin UI
entity_metadata_wrapper()
также смотрите
●
●
●
●

Drupal Commerce
Profile 2
Entityforms
Entity Construction Kit (ECK)
Спасибо за
внимание !

Más contenido relacionado

La actualidad más candente

Python dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущееPython dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущееdelimitry
 
Реализация шаблонов корпоративных приложений в Magento
Реализация шаблонов корпоративных приложений в MagentoРеализация шаблонов корпоративных приложений в Magento
Реализация шаблонов корпоративных приложений в MagentoMagecom Ukraine
 
Лекция #5. Введение в язык программирования Python 3
Лекция #5. Введение в язык программирования Python 3Лекция #5. Введение в язык программирования Python 3
Лекция #5. Введение в язык программирования Python 3Яковенко Кирилл
 
Все дороги ведут в Checkout
Все дороги ведут в CheckoutВсе дороги ведут в Checkout
Все дороги ведут в CheckoutMagecom Ukraine
 
Индексирование в Magento
Индексирование в MagentoИндексирование в Magento
Индексирование в MagentoMagecom Ukraine
 
AddConf. Дмитрий Сошников - Будущее ECMAScript
AddConf. Дмитрий Сошников  - Будущее ECMAScriptAddConf. Дмитрий Сошников  - Будущее ECMAScript
AddConf. Дмитрий Сошников - Будущее ECMAScriptDmitry Soshnikov
 
Работа с БД в Drupal 7
Работа с БД в Drupal 7Работа с БД в Drupal 7
Работа с БД в Drupal 7Eugene Fidelin
 
Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1Vasya Petrov
 
Caching on highload Drupal site - Alexander Shumenko
Caching on highload Drupal site - Alexander ShumenkoCaching on highload Drupal site - Alexander Shumenko
Caching on highload Drupal site - Alexander ShumenkoDrupalCampDN
 
I tmozg js_school_jquery
I tmozg js_school_jqueryI tmozg js_school_jquery
I tmozg js_school_jqueryITmozg
 
Интуит. Разработка приложений для iOS. Лекция 5. Сложные Views
Интуит. Разработка приложений для iOS. Лекция 5. Сложные ViewsИнтуит. Разработка приложений для iOS. Лекция 5. Сложные Views
Интуит. Разработка приложений для iOS. Лекция 5. Сложные ViewsГлеб Тарасов
 
Python
PythonPython
Pythonpelid
 
Сущности в Drupal 7
Сущности в Drupal 7Сущности в Drupal 7
Сущности в Drupal 7Itech4Web
 
Пластилиновый код: как перестать кодить и начать жить
Пластилиновый код: как перестать кодить и начать житьПластилиновый код: как перестать кодить и начать жить
Пластилиновый код: как перестать кодить и начать житьMoscow.pm
 
Yii development
Yii developmentYii development
Yii developmentMageCloud
 
Enterprise Patterns in Magento
Enterprise Patterns in MagentoEnterprise Patterns in Magento
Enterprise Patterns in MagentoVrann Tulika
 
Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1Vasya Petrov
 

La actualidad más candente (20)

Python dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущееPython dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущее
 
Реализация шаблонов корпоративных приложений в Magento
Реализация шаблонов корпоративных приложений в MagentoРеализация шаблонов корпоративных приложений в Magento
Реализация шаблонов корпоративных приложений в Magento
 
Лекция #5. Введение в язык программирования Python 3
Лекция #5. Введение в язык программирования Python 3Лекция #5. Введение в язык программирования Python 3
Лекция #5. Введение в язык программирования Python 3
 
Все дороги ведут в Checkout
Все дороги ведут в CheckoutВсе дороги ведут в Checkout
Все дороги ведут в Checkout
 
Индексирование в Magento
Индексирование в MagentoИндексирование в Magento
Индексирование в Magento
 
AddConf. Дмитрий Сошников - Будущее ECMAScript
AddConf. Дмитрий Сошников  - Будущее ECMAScriptAddConf. Дмитрий Сошников  - Будущее ECMAScript
AddConf. Дмитрий Сошников - Будущее ECMAScript
 
Yserver
YserverYserver
Yserver
 
Работа с БД в Drupal 7
Работа с БД в Drupal 7Работа с БД в Drupal 7
Работа с БД в Drupal 7
 
Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1
 
Caching on highload Drupal site - Alexander Shumenko
Caching on highload Drupal site - Alexander ShumenkoCaching on highload Drupal site - Alexander Shumenko
Caching on highload Drupal site - Alexander Shumenko
 
I tmozg js_school_jquery
I tmozg js_school_jqueryI tmozg js_school_jquery
I tmozg js_school_jquery
 
Интуит. Разработка приложений для iOS. Лекция 5. Сложные Views
Интуит. Разработка приложений для iOS. Лекция 5. Сложные ViewsИнтуит. Разработка приложений для iOS. Лекция 5. Сложные Views
Интуит. Разработка приложений для iOS. Лекция 5. Сложные Views
 
Python
PythonPython
Python
 
Perl: Symbol table
Perl: Symbol tablePerl: Symbol table
Perl: Symbol table
 
Mojo. The web in a box!
Mojo. The web in a box!Mojo. The web in a box!
Mojo. The web in a box!
 
Сущности в Drupal 7
Сущности в Drupal 7Сущности в Drupal 7
Сущности в Drupal 7
 
Пластилиновый код: как перестать кодить и начать жить
Пластилиновый код: как перестать кодить и начать житьПластилиновый код: как перестать кодить и начать жить
Пластилиновый код: как перестать кодить и начать жить
 
Yii development
Yii developmentYii development
Yii development
 
Enterprise Patterns in Magento
Enterprise Patterns in MagentoEnterprise Patterns in Magento
Enterprise Patterns in Magento
 
Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1Подробная презентация JavaScript 6 в 1
Подробная презентация JavaScript 6 в 1
 

Más de ADCI Solutions

Drupal front-end performance
Drupal front-end performance Drupal front-end performance
Drupal front-end performance ADCI Solutions
 
Introduction to cron queue
Introduction to cron queueIntroduction to cron queue
Introduction to cron queueADCI Solutions
 
Drupal. Advantages and disadvantages. Igor Rodionov.
Drupal. Advantages and disadvantages. Igor Rodionov.Drupal. Advantages and disadvantages. Igor Rodionov.
Drupal. Advantages and disadvantages. Igor Rodionov.ADCI Solutions
 
Drupal theming must knows. Kate Kalashnikova.
Drupal theming must knows. Kate Kalashnikova.Drupal theming must knows. Kate Kalashnikova.
Drupal theming must knows. Kate Kalashnikova.ADCI Solutions
 
Drupal. History and Future. Sergey Susikov.
Drupal. History and Future. Sergey Susikov.Drupal. History and Future. Sergey Susikov.
Drupal. History and Future. Sergey Susikov.ADCI Solutions
 
Data Import From the Server of The Central Bank of the Russian Federation: Ho...
Data Import From the Server of The Central Bank of the Russian Federation: Ho...Data Import From the Server of The Central Bank of the Russian Federation: Ho...
Data Import From the Server of The Central Bank of the Russian Federation: Ho...ADCI Solutions
 
Drupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinDrupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinADCI Solutions
 
Contextly. Dmitry Tartynov
Contextly. Dmitry TartynovContextly. Dmitry Tartynov
Contextly. Dmitry TartynovADCI Solutions
 
Vagrant. Halturin Artem
Vagrant. Halturin ArtemVagrant. Halturin Artem
Vagrant. Halturin ArtemADCI Solutions
 
Must-knows and common mistakes in theming. Kate Kalashnikova.
Must-knows and common mistakes in theming. Kate Kalashnikova.Must-knows and common mistakes in theming. Kate Kalashnikova.
Must-knows and common mistakes in theming. Kate Kalashnikova.ADCI Solutions
 
Drupal 8. Movement towards. Susikov Sergey
Drupal 8. Movement towards. Susikov SergeyDrupal 8. Movement towards. Susikov Sergey
Drupal 8. Movement towards. Susikov SergeyADCI Solutions
 
Upgrade with 6 to 7. Denis Komel'kov
Upgrade with 6 to 7. Denis Komel'kovUpgrade with 6 to 7. Denis Komel'kov
Upgrade with 6 to 7. Denis Komel'kovADCI Solutions
 
Responsive website building approach. Olga Smolyankina and Kate Kalashnikova
Responsive website building approach. Olga Smolyankina and Kate KalashnikovaResponsive website building approach. Olga Smolyankina and Kate Kalashnikova
Responsive website building approach. Olga Smolyankina and Kate KalashnikovaADCI Solutions
 
LESS and even more. Anton Shubkin.
LESS and even more. Anton Shubkin.LESS and even more. Anton Shubkin.
LESS and even more. Anton Shubkin.ADCI Solutions
 
Selenium. Stas Kuzminov
Selenium. Stas KuzminovSelenium. Stas Kuzminov
Selenium. Stas KuzminovADCI Solutions
 

Más de ADCI Solutions (15)

Drupal front-end performance
Drupal front-end performance Drupal front-end performance
Drupal front-end performance
 
Introduction to cron queue
Introduction to cron queueIntroduction to cron queue
Introduction to cron queue
 
Drupal. Advantages and disadvantages. Igor Rodionov.
Drupal. Advantages and disadvantages. Igor Rodionov.Drupal. Advantages and disadvantages. Igor Rodionov.
Drupal. Advantages and disadvantages. Igor Rodionov.
 
Drupal theming must knows. Kate Kalashnikova.
Drupal theming must knows. Kate Kalashnikova.Drupal theming must knows. Kate Kalashnikova.
Drupal theming must knows. Kate Kalashnikova.
 
Drupal. History and Future. Sergey Susikov.
Drupal. History and Future. Sergey Susikov.Drupal. History and Future. Sergey Susikov.
Drupal. History and Future. Sergey Susikov.
 
Data Import From the Server of The Central Bank of the Russian Federation: Ho...
Data Import From the Server of The Central Bank of the Russian Federation: Ho...Data Import From the Server of The Central Bank of the Russian Federation: Ho...
Data Import From the Server of The Central Bank of the Russian Federation: Ho...
 
Drupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinDrupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton Shubkin
 
Contextly. Dmitry Tartynov
Contextly. Dmitry TartynovContextly. Dmitry Tartynov
Contextly. Dmitry Tartynov
 
Vagrant. Halturin Artem
Vagrant. Halturin ArtemVagrant. Halturin Artem
Vagrant. Halturin Artem
 
Must-knows and common mistakes in theming. Kate Kalashnikova.
Must-knows and common mistakes in theming. Kate Kalashnikova.Must-knows and common mistakes in theming. Kate Kalashnikova.
Must-knows and common mistakes in theming. Kate Kalashnikova.
 
Drupal 8. Movement towards. Susikov Sergey
Drupal 8. Movement towards. Susikov SergeyDrupal 8. Movement towards. Susikov Sergey
Drupal 8. Movement towards. Susikov Sergey
 
Upgrade with 6 to 7. Denis Komel'kov
Upgrade with 6 to 7. Denis Komel'kovUpgrade with 6 to 7. Denis Komel'kov
Upgrade with 6 to 7. Denis Komel'kov
 
Responsive website building approach. Olga Smolyankina and Kate Kalashnikova
Responsive website building approach. Olga Smolyankina and Kate KalashnikovaResponsive website building approach. Olga Smolyankina and Kate Kalashnikova
Responsive website building approach. Olga Smolyankina and Kate Kalashnikova
 
LESS and even more. Anton Shubkin.
LESS and even more. Anton Shubkin.LESS and even more. Anton Shubkin.
LESS and even more. Anton Shubkin.
 
Selenium. Stas Kuzminov
Selenium. Stas KuzminovSelenium. Stas Kuzminov
Selenium. Stas Kuzminov
 

Entity. Anton Shubkin and Yaroslav Ponomarev