77
88use  OCP \Collaboration \AutoComplete \IManager ;
99use  OCP \Collaboration \AutoComplete \ISorter ;
10- use  OCP \IServerContainer ;
10+ use  Psr \Container \ContainerExceptionInterface ;
11+ use  Psr \Container \ContainerInterface ;
12+ use  Psr \Log \LoggerInterface ;
1113
1214class  Manager implements  IManager {
1315	/** @var string[] */ 
@@ -17,7 +19,8 @@ class Manager implements IManager {
1719	protected  array  $ sorterInstances
1820
1921	public  function  __construct (
20- 		private  IServerContainer $ container
22+ 		private  ContainerInterface $ container
23+ 		private  LoggerInterface $ logger
2124	) {
2225	}
2326
@@ -27,7 +30,7 @@ public function runSorters(array $sorters, array &$sortArray, array $context): v
2730			if  (isset ($ sorterInstances$ sorter
2831				$ sorterInstances$ sortersort ($ sortArray$ context
2932			} else  {
30- 				$ this container -> getLogger () ->warning ('No sorter for ID "{id}", skipping ' , [
33+ 				$ this logger ->warning ('No sorter for ID "{id}", skipping ' , [
3134					'app '  => 'core ' , 'id '  => $ sorter
3235				]);
3336			}
@@ -41,16 +44,23 @@ public function registerSorter($className): void {
4144	protected  function  getSorters (): array  {
4245		if  (count ($ this sorterInstances ) === 0 ) {
4346			foreach  ($ this sorters  as  $ sorter
44- 				/** @var ISorter $instance */ 
45- 				$ instance$ this container ->resolve ($ sorter
47+ 				try  {
48+ 					$ instance$ this container ->get ($ sorter
49+ 				} catch  (ContainerExceptionInterface 
50+ 					$ this logger ->notice (
51+ 						'Skipping not registered sorter. Class name: {class} ' ,
52+ 						['app '  => 'core ' , 'class '  => $ sorter
53+ 					);
54+ 					continue ;
55+ 				}
4656				if  (!$ instanceinstanceof  ISorter) {
47- 					$ this container -> getLogger () ->notice ('Skipping sorter which is not an instance of ISorter. Class name: {class} ' ,
57+ 					$ this logger ->notice ('Skipping sorter which is not an instance of ISorter. Class name: {class} ' ,
4858						['app '  => 'core ' , 'class '  => $ sorter
4959					continue ;
5060				}
5161				$ sorterIdtrim ($ instancegetId ());
5262				if  (trim ($ sorterId'' ) {
53- 					$ this container -> getLogger () ->notice ('Skipping sorter with empty ID. Class name: {class} ' ,
63+ 					$ this logger ->notice ('Skipping sorter with empty ID. Class name: {class} ' ,
5464						['app '  => 'core ' , 'class '  => $ sorter
5565					continue ;
5666				}
0 commit comments