*/ public function app(): array { return array( 'order' => 20, 'category' => 'core', 'core' => true, 'deps' => array( ), 'default' => true, 'label_key' => 'app_notes', 'desc_key' => 'app_notes_desc', 'icon' => 'notes', 'cron' => array( ), ); } /** * @return array{label: string, desc: string} */ public function labels(): array { return array( 'label' => __( 'Notes', 'plugixa-crm' ), 'desc' => __( 'Free text written against any record.', 'plugixa-crm' ), ); } public function migrate(): void { Schema::install(); } /** * @return array */ public function capabilities(): array { // Reading and writing a note is covered by the permission on the record it hangs off. // A capability of its own would be a second answer to a question already settled. return array(); } public function registerServices( Container $container ): void { unset( $container ); } public function registerRoutes( Container $container ): void { $container->get( NotesController::class )->register_routes(); } public function registerHooks( Container $container ): void { add_filter( 'plugixa_crm_admin_i18n_strings', static fn( array $strings ): array => array_merge( $strings, Strings::all() ) ); // When a record is destroyed, its notes go with it. This is the last moment the row // exists, and nothing else will ever clean these up. add_action( 'plugixa_crm_before_purge', static function ( string $entity, int $id ) use ( $container ): void { if ( self::OWN === $entity ) { return; } $container->get( NoteRepository::class )->purge_for_record( $entity, $id ); }, 10, 2 ); } }