generated_content

所属分类:collect
开发工具:PHP
文件大小:0KB
下载次数:0
上传日期:2023-03-10 23:16:37
上 传 者sh-1993
说明:  Drupal模块以编程方式生成内容。
(Drupal module to programmatically generate content.)

文件列表:
generated_content-1.x/ (0, 2023-12-15)
generated_content-1.x/LICENSE (35149, 2023-12-15)
generated_content-1.x/assets/ (0, 2023-12-15)
generated_content-1.x/assets/dummy1.doc (22528, 2023-12-15)
generated_content-1.x/assets/dummy1.docx (11777, 2023-12-15)
generated_content-1.x/assets/dummy1.gif (2294, 2023-12-15)
generated_content-1.x/assets/dummy1.jpeg (10323, 2023-12-15)
generated_content-1.x/assets/dummy1.jpg (10323, 2023-12-15)
generated_content-1.x/assets/dummy1.mp3 (254415, 2023-12-15)
generated_content-1.x/assets/dummy1.mp4 (56609, 2023-12-15)
generated_content-1.x/assets/dummy1.pdf (30278, 2023-12-15)
generated_content-1.x/assets/dummy1.png (1438, 2023-12-15)
generated_content-1.x/assets/dummy1.svg (6518, 2023-12-15)
generated_content-1.x/assets/dummy1.xls (8704, 2023-12-15)
generated_content-1.x/assets/dummy1.xlsx (5715, 2023-12-15)
generated_content-1.x/assets/dummy2.doc (22528, 2023-12-15)
generated_content-1.x/assets/dummy2.docx (11774, 2023-12-15)
generated_content-1.x/assets/dummy2.gif (2851, 2023-12-15)
generated_content-1.x/assets/dummy2.jpeg (11769, 2023-12-15)
generated_content-1.x/assets/dummy2.jpg (11769, 2023-12-15)
generated_content-1.x/assets/dummy2.pdf (43911, 2023-12-15)
generated_content-1.x/assets/dummy2.png (2225, 2023-12-15)
generated_content-1.x/assets/dummy2.svg (221, 2023-12-15)
generated_content-1.x/assets/dummy2.xls (8704, 2023-12-15)
generated_content-1.x/assets/dummy2.xlsx (5715, 2023-12-15)
generated_content-1.x/assets/dummy3.jpeg (12541, 2023-12-15)
generated_content-1.x/assets/dummy3.jpg (12541, 2023-12-15)
generated_content-1.x/assets/dummy3.png (2716, 2023-12-15)
generated_content-1.x/composer.json (888, 2023-12-15)
generated_content-1.x/drush.services.yml (213, 2023-12-15)
generated_content-1.x/generated_content.api.php (2278, 2023-12-15)
generated_content-1.x/generated_content.info.yml (136, 2023-12-15)
generated_content-1.x/generated_content.install (1174, 2023-12-15)
generated_content-1.x/generated_content.links.menu.yml (202, 2023-12-15)
generated_content-1.x/generated_content.module (2793, 2023-12-15)
generated_content-1.x/generated_content.permissions.yml (125, 2023-12-15)
generated_content-1.x/generated_content.routing.yml (290, 2023-12-15)
generated_content-1.x/generated_content.services.yml (226, 2023-12-15)
generated_content-1.x/modules/ (0, 2023-12-15)
... ...

# Generated Content Drupal module to programmatically generate content. [![CircleCI](https://circleci.com/gh/AlexSkrypnyk/generated_content.svg?style=shield)](https://circleci.com/gh/AlexSkrypnyk/generated_content) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/drevops/generated_content) ![LICENSE](https://img.shields.io/github/license/drevops/generated_content) Drupal.org module page: https://www.drupal.org/project/generated_content ## User stories As a site owner I want to see generated content before I have content So that I can see how my site looks As a Drupal developer I want to control what is put into generated content So that I could have control over what is being generated As a Drupal developer I want to have a list of pre-generated pages with URLs So that I could use then for Visual Regression testing during site releases ## Installation composer require drupal/generated_content ## How it works 1. The module provides callbacks system to generate content entities within a code of a custom module sitting in `generated_content/{entity_type}/{entity_bundle}.inc`. 2. The module provides a helper (singleton) class to generate random and static content. It also supports extending this class in your custom module to enhance with your site-specific generation helpers. 3. Generated content entities are tracked in the Repository so that they could be referenced from other generated entities (e.g., generated Articles using generated Tags). 4. Content can be generated from UI `/admin/config/development/generated-content` or through a Drush command `drush generated-content:create-content {entity_type} {bundle}`. 5. Content can also be generated on module install if `GENERATED_CONTENT_CREATE` environment variable is set to `1`. Generation can be further filtered by specified types in `GENERATED_CONTENT_ITEMS` environment variable as a comma-separated list of `{entity_type}-{bundle}` values: # Generate all items in my_module module when it is enabled. GENERATED_CONTENT_CREATE=1 drush pm-enable my_module # Generate only selected items in my_module module when it is enabled. GENERATED_CONTENT_CREATE=1 GENERATED_CONTENT_ITEMS=media-image,taxonomy_term-tags,node-page drush pm-enable my_module See test [example module 1](modules/generated_content_example1) and [test example module 2](modules/generated_content_example2) for extensive examples. See [`generated_content.api.php`](generated_content.api.php) for API of callbacks system. ## Example to generate Tags ```php 'tags', 'name' => 'Generated term ' . ($i + 1), ]); // Save term instance. $term->save(); // Track saved term instance to return. $terms[] = $term; // Log creation of this entity. $helper::log( 'Created "%s" term "%s" [ID: %s] %s', $term->bundle(), $term->toLink()->toString(), $term->id(), Link::createFromRoute('Edit', 'entity.taxonomy_term.edit_form', ['taxonomy_term' => $term->id()])->toString() ); } // Return created term instances. return $terms; } ``` ## Generation helper Generation helper class `GeneratedContentHelper` is a Singleton class which provides: 1. Random non-Drupal scalar values generation. 2. Static non-Drupal scalar values generation. 3. Random asset generator (files of different types). 4. Static asset generator (files from pre-defined assets). 5. Random Drupal entity values generation. 6. Static Drupal entity values generation. ### Extending generation helper See example of class extension: [`modules/generated_content_example2/src/GeneratedContentExample2Helper.php`](modules/generated_content_example2/src/GeneratedContentExample2Helper.php) See example of class usage: [`modules/generated_content_example2/generated_content/node/article.inc`](modules/generated_content_example2/generated_content/node/article.inc) ## Random vs Static content Sometimes, it is sufficient to simply populate entities with random content to make the site look "not empty". Depending on your deployment strategy (if you are enabling content generation modules on every deployment on top of the fresh database), this may change the content on every deployment. However, there are times when all generated content can still be a "placeholder" content, but it should be "static" between deployments, so that all content and it's aliases would not change. This is specifically important for Visual Regression testing during a release: the tool can compare generated pages with known aliases in 2 environments and report differences, if any. ## Roadmap 1. Add more random and static generators. 2. Add tests for existing random and static generators. 3. [Suggest yours](https://www.drupal.org/project/issues/generated_content).

近期下载者

相关文件


收藏者