The AdminUser entity extends the User entity. It is created to enable administrator accounts that have access to the administration panel.
How to create an AdminUser programmatically?¶
The AdminUser is created just like every other entity, it has its own factory. By default it will have an administration role assigned.
/** @var AdminUserInterface $admin */ $admin = $this->container->get('sylius.factory.admin_user')->createNew(); $admin->setEmail('firstname.lastname@example.org'); $admin->setPlainPassword('pswd'); $this->container->get('sylius.repository.admin_user')->add($admin);
In Sylius by default you have got the administration panel routes (
/admin/*) secured by a firewall - its configuration
can be found in the security.yml file.
Only the logged in AdminUsers are eligible to enter these routes.