PHP code example of proklung / bitrix-fixture-database-generator-bundle
1. Go to this page and download the library: Download proklung/bitrix-fixture-database-generator-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
proklung / bitrix-fixture-database-generator-bundle example snippets
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\EnumGenerator;
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\ImageGenerator;
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\LinkElementGenerator;
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\SentenceGenerator;
return [
// 'PREVIEW_TEXT' => 'bitrix_fixture_generator.preview_text_generator',
// 'DETAIL_TEXT' => 'bitrix_fixture_generator.detail_text_generator',
// 'NAME' => 'bitrix_fixture_generator.name_generator', // Alias сервиса
'PROPERTY_VALUES' => [
'STRING' => SentenceGenerator::class, // Сервис, помеченный тэгом fixture_generator.item.
'FILE' => ImageGenerator::class, // Сервис, помеченный тэгом fixture_generator.item.
'MULTIPLE_STRING' => 'bitrix_fixture_generator.multiple_string_generator', // Штатный сервис-генератор из бандла.
'MULTIPLE_FILE' => 'bitrix_fixture_generator.multiple_image_generator',
'ENUM' => EnumGenerator::class,
'MULTIPLE_ENUM' => 'bitrix_fixture_generator.multiple_enum_generator',
'LINK' => LinkElementGenerator::class,
'MULTIPLE_LINK' => 'bitrix_fixture_generator.multiple_link_generator',
]
];
[
'PREVIEW_PICTURE' => 'bitrix_fixture_generator.preview_picture_generator',
'DETAIL_PICTURE' => 'bitrix_fixture_generator.detail_picture_generator', // Сервис, помеченный тэгом fixture_generator.item.
'ACTIVE_FROM' => DateGenerator::class,
'CREATED_BY' => UserIdGenerator::class,
'MODIFIED_BY' => UserIdGenerator::class,
'PREVIEW_TEXT' => 'bitrix_fixture_generator.preview_text_generator',
'PREVIEW_TEXT_TYPE' => 'html',
'DETAIL_TEXT' => 'bitrix_fixture_generator.detail_text_generator',
'DETAIL_TEXT_TYPE' => 'html',
'NAME' => 'bitrix_fixture_generator.name_generator', // Alias сервиса
'CODE' => CodeGenerator::class,
];
[
'NAME' => 'bitrix_fixture_generator.name_generator', // Alias сервиса
'CODE' => CodeGenerator::class,
'PICTURE' => 'bitrix_fixture_generator.preview_picture_generator',
'DETAIL_PICTURE' => 'bitrix_fixture_generator.detail_picture_generator',
'DESCRIPTION' => 'bitrix_fixture_generator.preview_text_generator',
'DESCRIPTION_TYPE' => 'html',
'MODIFIED_BY' => UserIdGenerator::class,
];
use Prokl\BitrixFixtureGeneratorBundle\Services\Annotations\FieldParams;
use Prokl\BitrixFixtureGeneratorBundle\Services\Contracts\FixtureInterface;
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\EnumGenerator;
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\ImageGenerator;
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\LinkElementGenerator;
use Prokl\BitrixFixtureGeneratorBundle\Services\Generators\SentenceGenerator;
class ContentCommonFixture implements FixtureInterface
{
/**
* ID фикстуры (тип инфоблока . код инфоблока).
*
* @return string
*/
public function id() : string
{
return 'content.common';
}
/**
* Фикстура
* @FieldParams(
* params={
* "PREVIEW_PICTURE"= { "width"=400, "height"=400 },
* "PROPERTY_VALUES" = {
* "STRING"= { "length"=22 }
* }
* }
* )
*/
public function fixture() : array
{
return [
'PREVIEW_PICTURE' => ImageGenerator::class,
'PROPERTY_VALUES' => [
'STRING' => SentenceGenerator::class,
'FILE' => ImageGenerator::class,
'MULTIPLE_STRING' => 'bitrix_fixture_generator.multiple_string_generator',
'MULTIPLE_FILE' => 'bitrix_fixture_generator.multiple_image_generator',
'ENUM' => EnumGenerator::class,
'MULTIPLE_ENUM' => 'bitrix_fixture_generator.multiple_enum_generator',
'LINK' => LinkElementGenerator::class,
'MULTIPLE_LINK' => 'bitrix_fixture_generator.multiple_link_generator',
// 'YES' => 1,
]
];
}
}
public function generate(?array $payload = null)
{
$width = array_key_exists('width', $payload['params']) ? $payload['params']['width'] : 0;
}