Skip to content

Misc development stuff

Aloïs Guillopé edited this page Jul 9, 2024 · 4 revisions

Create a new (admin) user

In the application directory

php bin/console nucleos:user:create [username]
php bin/console nucleos:user:activate [username]
php bin/console nucleos:user:promote

Implement soft deletion

Soft deletion is not enabled by default, so you will have to filter out manually records, check the end of this list

  1. In the Entity.orm.xml, add in doctrine-mapping property xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
  2. In the Entity.orm.xml add
<field name="deletedAt" type="datetime" column="deleted_at" nullable="true"/>
<gedmo:soft-deleteable field-name="deletedAt" time-aware="false" hard-delete="false" />
  1. In the Entity.php file add
use Gedmo\SoftDeleteable\Traits\SoftDeleteable;
use SoftDeleteable;
  1. Edit src/Doctrine/EventSubscriber/PostSoftDeleteSubscriber.php if you want to implement some behaviour on soft deletion
  2. If you want to filter out soft deleted in a specific endpoint, add the name of the route here : src/Api/EventSubscriber/SoftDeletedSubscriber.php
  3. If you want to filter out soft deleted object in a specific part of code
$this->getDoctrine()->getManager()->getFilters()->enable('soft_deleteable');
// some queries you want to filter out here
$stores = $this->getDoctrine()->getRepository(Store::class)->findBy([], ['name' => 'ASC']);
$this->getDoctrine()->getManager()->getFilters()->disable('soft_deleteable');

Use API Http Client from the TWIG templates

See the documentation on Notion