@@ -85,22 +85,10 @@ public function buildForm(array $form, FormStateInterface $form_state) {
8585 '#default_value ' => (int ) $ config ->get ('phpfastcache_default_ttl ' ),
8686 '#description ' => $ this ->t ('Enable or disable all the PhpFastCache components ' ),
8787 '#required ' => TRUE ,
88- '#title ' => $ this ->t ('PhpFastCache default <abbr title="Time to live">TTL</abbr> ' ),
88+ '#title ' => $ this ->t ('Default <abbr title="Time to live">TTL</abbr> ' ),
8989 '#type ' => 'textfield ' ,
9090 ];
9191
92- $ form [ 'general ' ][ 'phpfastcache_settings_wrapper ' ][ 'phpfastcache_htaccess ' ] = [
93- '#default_value ' => (bool ) $ config ->get ('phpfastcache_htaccess ' ),
94- '#description ' => $ this ->t ('Automatically generate htaccess for files-based drivers such as Files, Sqlite, etc. ' ),
95- '#required ' => TRUE ,
96- '#options ' => [
97- '0 ' => t ('No ' ),
98- '1 ' => t ('Yes ' ),
99- ],
100- '#title ' => $ this ->t ('PhpFastCache auto-htaccess generation ' ),
101- '#type ' => 'select ' ,
102- ];
103- 10492 $ driversOption = [];
10593 foreach (CacheManager::getStaticSystemDrivers () as $ systemDriver ) {
10694 $ driversOption [ strtolower ($ systemDriver ) ] = t (ucfirst ($ systemDriver ));
@@ -112,8 +100,53 @@ public function buildForm(array $form, FormStateInterface $form_state) {
112100 '#description ' => $ this ->t ('Enable or disable all the PhpFastCache components ' ),
113101 '#required ' => TRUE ,
114102 '#options ' => $ driversOption ,
115- '#title ' => $ this ->t ('PhpFastCache driver ' ),
103+ '#title ' => $ this ->t ('Cache driver ' ),
104+ '#type ' => 'select ' ,
105+ ];
106+ 107+ $ form [ 'general ' ][ 'phpfastcache_settings_wrapper ' ][ 'phpfastcache_htaccess ' ] = [
108+ '#default_value ' => (bool ) $ config ->get ('phpfastcache_htaccess ' ),
109+ '#description ' => $ this ->t ('Automatically generate htaccess for files-based drivers such as Files, Sqlite and Leveldb. ' ),
110+ '#required ' => TRUE ,
111+ '#options ' => [
112+ '0 ' => t ('No ' ),
113+ '1 ' => t ('Yes ' ),
114+ ],
115+ '#title ' => $ this ->t ('Auto-htaccess generation ' ),
116116 '#type ' => 'select ' ,
117+ '#states ' => [
118+ 'visible ' => [
119+ 'select[name="phpfastcache_default_driver"] ' => [
120+ ['value ' => 'files ' ],
121+ ['value ' => 'sqlite ' ],
122+ ['value ' => 'leveldb ' ]
123+ ],
124+ ],
125+ ],
126+ ];
127+ 128+ 129+ $ binDescCallback = function ($ binName , $ binDesc = '' )
130+ {
131+ return '<span> ' . t (ucfirst ($ binName )) . '</span> ' . ($ binDesc ? ' - <small> ' . t ($ binDesc ) . '</small> ' : '' );
132+ };
133+ 134+ $ form [ 'general ' ][ 'phpfastcache_settings_wrapper ' ][ 'phpfastcache_bins ' ] = [
135+ '#default_value ' => (array ) $ config ->get ('phpfastcache_bins ' ),
136+ '#description ' => 'See /core/core.services.yml for more information about bin uses ' ,
137+ '#required ' => false ,
138+ '#options ' => [
139+ 'default ' => $ binDescCallback ('default ' , 'Default bin if not specified by modules/core ' ),
140+ 'menu ' => $ binDescCallback ('menu ' , 'Menu tree/items ' ),
141+ 'bootstrap ' => $ binDescCallback ('bootstrap ' , 'Drupal bootstrap/core initialization ' ),
142+ 'render ' => $ binDescCallback ('render ' , 'You must expect the cache size to grow up quickly, make sure that the driver you choose have enough memory/disk space. ' ),
143+ 'config ' => $ binDescCallback ('config ' , 'You will have to purge the cache after each settings changes ' ),
144+ 'dynamic_page_cache ' => $ binDescCallback ('dynamic page cache ' , '' ),
145+ 'entity ' => $ binDescCallback ('entity ' , 'You will have to purge the cache after each entity changes ' ),
146+ 'discovery ' => $ binDescCallback ('discovery ' , 'Used for plugin manager, entity type manager, field manager, etc. ' ),
147+ ],
148+ '#title ' => $ this ->t ('Bins handled by PhpFastCache ' ),
149+ '#type ' => 'checkboxes ' ,
117150 ];
118151
119152 /***********************
@@ -330,6 +363,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
330363 ->set ('phpfastcache_default_ttl ' , (int ) $ form_state ->getValue ('phpfastcache_default_ttl ' ))
331364 ->set ('phpfastcache_htaccess ' , (bool ) $ form_state ->getValue ('phpfastcache_htaccess ' ))
332365 ->set ('phpfastcache_default_driver ' , (string ) $ form_state ->getValue ('phpfastcache_default_driver ' ))
366+ ->set ('phpfastcache_bins ' , array_values (array_filter ((array ) $ form_state ->getValue ('phpfastcache_bins ' ))))
333367 /*****************
334368 * Drivers settings
335369 *****************/
0 commit comments