Download the PHP package wieni/wmpresenter without Composer

On this page you can find all versions of the php package wieni/wmpresenter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wmpresenter

Entity Presenter

Latest Stable Version Total Downloads License

Adds support for creating & injecting view presenters on top of entity classes

Why?

Presenters are a principle taken from Model-view-presenter, a software design pattern similar to Model-view-controller. We use it to transform data before displaying it. Some example use cases:

Installation

This package requires PHP 7.1 and Drupal 8 or higher. It can be installed using Composer:

How does it work?

Creating presenters

Presenter classes should implement PresenterInterface.

AbstractPresenter is the recommended base class, it provides magic methods allowing you to call methods of the entity class directly on the presenter class. The @mixin docblock can be used to tell IDE's about this behaviour. The @property docblock can be used if you don't like magic and prefer to call the entity's methods directly on the entity.

Presenters should be registered as services. It's important to set shared: false on the presenter service, otherwise all presenters of the same type will work with the same entity.

Presenters can be assigned to entities by making the entity class implement HasPresenterInterface. The getPresenterService method should return the presenter service ID.

Entities having presenters don't have to implement EntityInterface. Any class can be used.

Automatically injecting presenters

Entities are automatically converted to their presenter counterparts when including them in a Twig template. Some examples:

Manually loading presenters

In code, presenters can be loaded using PresenterFactoryInterface::getPresenterForEntity.

In Twig, presenters can be loaded by passing the entity through the p or presenter filters. When passing an array of entities, all entities will be converted to their presenter counterparts.

Twig\Sandbox\SecurityError: Calling method on a \<presenter> object is not allowed

Twig has a whitelist feature that prevent people from calling methods on unknown classes in Twig templates. In order to allow you to use presenters in Twig templates, you'll have to change the whitelist by adding the following to your settings.php:

Changelog

All notable changes to this project will be documented in the CHANGELOG file.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

License

Distributed under the MIT License. See the LICENSE file for more information.


All versions of wmpresenter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
drupal/core Version ^9.1 || ^10
wieni/wmtwig Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wieni/wmpresenter contains the following files

Loading the files please wait ....