The best way to install Arachne/EntityLoader is using Composer.
composer require arachne/entity-loader
Now you need to register the necessary extensions using your neon config file.
extensions:
contributte.cache: Contributte\Cache\DI\CacheFactoryExtension
contributte.eventDispatcher: Contributte\EventDispatcher\DI\EventDispatcherExtension
contributte.eventDispatcher.extra.application: Contributte\Events\Extra\DI\EventApplicationBridgeExtension
arachne.serviceCollections: Arachne\ServiceCollections\DI\ServiceCollectionsExtension
arachne.entityLoader: Arachne\EntityLoader\DI\EntityLoaderExtension
Next add the Arachne\EntityLoader\Application\EntityLoaderPresenterTrait
to your BasePresenter. It overrides the storeRequest & restoreRequest methods to make them work with object parameters.
use Arachne\EntityLoader\Application\EntityLoaderPresenterTrait;
use Nette\Application\UI\Presenter;
abstract class BasePresenter extends Presenter
{
use EntityLoaderPresenterTrait;
}
Finally you will need to specify the types of parameters in your application.
- Add types to all parameters of your action, render and handle methods.
- Add
@var
annotations to all your persistent parameters. - Add return types to all your createComponent methods.
These types are handled out of the box: int
, bool
, float
, string
, array
and mixed
.
EntityLoader is very strict about this and it will throw an exception if some type or annotation is missing.
If you're using Nextras/SecuredLinks replace the standard Nextras\Application\UI\SecuredLinksPresenterTrait
with Arachne\EntityLoader\Application\SecuredLinksPresenterTrait
.