enterprisephp / display-bundle
This Bundle provides generate view for given object
Installs: 2 115
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 7
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^5.5.9|~7.0
- psr/log: ^1.0
- symfony/framework-bundle: ^2.7|^3.0
Requires (Dev)
- jms/serializer-bundle: ^1.0
- sensio/framework-extra-bundle: ^3.0
- symfony/browser-kit: ^2.7|^3.0
- symfony/dependency-injection: ^2.7|^3.0
- symfony/form: ^2.7|^3.0
- symfony/phpunit-bridge: ~2.7|^3.0
- symfony/security-bundle: ^2.7|^3.0
- symfony/serializer: ^2.7|^3.0
- symfony/twig-bundle: ^2.7|^3.0
- symfony/validator: ^2.7|^3.0
- symfony/web-profiler-bundle: ^2.7|^3.0
- symfony/yaml: ^2.7|^3.0
Suggests
- jms/serializer-bundle: Add support for advanced serialization capabilities, recommended, requires ^1.0
- sensio/framework-extra-bundle: Add support for route annotations and the view response listener, requires ^3.0
- symfony/expression-language: Add support for using the expression language in the routing, requires ^2.7|^3.0
- symfony/serializer: Add support for basic serialization capabilities and xml decoding, requires ^2.7|^3.0
- symfony/validator: Add support for validation capabilities in the ParamFetcher, requires ^2.7|^3.0
This package is not auto-updated.
Last update: 2024-11-19 19:42:53 UTC
README
Easily generate view for given entity/object
Very Basic Screenshot;
Related Links;###
- academic/vipa#990
- https://github.com/ojs/ojs/blob/master/src/Ojs/CoreBundle/Service/Twig/DisplayExtension.php
- Development steps can be followed from https://github.com/behramcelen/symfony-bundle-develop
- A basic test and logic controller and view can be found in https://github.com/behramcelen/symfony-bundle-develop/blob/master/src/AppBundle/Controller/DisplayController.php#L16
- https://github.com/behramcelen/symfony-bundle-develop/blob/master/src/AppBundle/Resources/views/Display/display.html.twig#L7
Installation
Step 1: Download the Bundle
Open a command console, go to your project directory and execute the following command to download the latest version of this bundle:
$ composer require enterprisephp/display-bundle "dev-master"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new EP\DisplayBundle\EPDisplayBundle(), ); // ... } // ... }
DisplayTrait
use DisplayTrait on which you want to display objects/entities (!important):
namespace AppBundle\Entity; use EP\DisplayBundle\Entity\DisplayTrait; class MyEntity { use DisplayTrait; }
Configuration
Add below configs to config.yml
file:
ep_display:
global:
image_render: true # (optinal) defaults to true
file_render: true # (optinal) defaults to true
template: EPDisplayBundle::display.html.twig # (optinal) defaults to EPDisplayBundle:display.html.twig template
exclude_vars: # (optinal) defaults to empty array
- excludeField
- hiddenField
- password
array_collection_render: true # (optinal) defaults to true
collection_item_count: 5 # (optinal) defaults to 10
Usage
If you do not want to any extreme things. Only display on template;
{{ display(entity) }} # so easy isn't it 😉
You can override all bundle configs via class annotation:
related : https://github.com/EnterprisePHP/EPDisplayBundle/blob/master/Annotation/Display.php#L11
namespace AppBundle\Entity; use EP\DisplayBundle\Annotation as Display; /** * @Display\Display( * image_render=false, # optinal * file_render=false, # optinal * template="my_entity_special_template.html.twig", # optinal * array_collection_render=true, # optinal * collection_item_count=8, # optinal * ) */ class MyEntity {
If you exclude spesific fields of entity use Exclude annotation:
related : https://github.com/EnterprisePHP/EPDisplayBundle/blob/master/Annotation/Exclude.php
namespace AppBundle\Entity; use EP\DisplayBundle\Annotation as Display; class DummyEntity { /** * @Display\Exclude */ protected $unPublicfieldForOnlyThisEntity;
Expose field. All fields defaultly exposes but if you excluded from config but only one time you want to expose this field;
namespace AppBundle\Entity; use EP\DisplayBundle\Annotation as Display; class DummyEntity { /** * @Display\Expose */ protected $oneTimeExposeField;
File expose with link;
namespace AppBundle\Entity; use EP\DisplayBundle\Annotation as Display; class DummyEntity { /** * @Display\File(path="uploads/files") */ protected $mainFile;
Image expose with img tag;
namespace AppBundle\Entity; use EP\DisplayBundle\Annotation as Display; class DummyEntity { /** * @Display\Image( * path="uploads/files", * height="50", * width="70", * ) */ protected $cover;
You can spesify all configs from template as second param on display function;
{{ display(entity, { files: { my_file: { path: "web/uploads" } }, images: { header: { path: "web/images", width: "70", height: "50" } }, exclude: "myVeryPrivateField", // can be array expose: "onlyForThisPageExposeVar", // can be array image_render: true, file_render: true, array_collection_render: false, collection_item_count: 90, template: "my_stylish_template.html.twig" }) }}
Reporting an issue or a feature request
Issues and feature requests are tracked in the Github issue tracker.
When reporting a bug, it may be a good idea to reproduce it in a basic project built using the Symfony Standard Edition to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.