@@ -47,15 +47,23 @@ def convert(self, manifest: Dict[str, Any], **kwargs):
4747 from .conversion_result import ConversionResult
4848 import asyncio
4949
50- # Run async conversion
50+ # Determine default class name from metadata title
51+ metadata = manifest .get ('metadata' , {})
52+ title = metadata .get ('title' , 'Component' )
53+ class_name_base = '' .join (ch for ch in title .title () if ch .isalnum ()) or 'Component'
54+ # Ensure suffix 'Component'
55+ class_name = class_name_base if class_name_base .endswith ('Component' ) else f"{ class_name_base } Component"
56+
57+ # Run async conversion with class_name passed through
5158 try :
5259 loop = asyncio .get_event_loop ()
5360 except RuntimeError :
5461 loop = asyncio .new_event_loop ()
5562 asyncio .set_event_loop (loop )
5663
57- php_content = loop .run_until_complete (self .convert_manifest (manifest , ** kwargs ))
58- return ConversionResult (content = php_content , format = "php" )
64+ php_content = loop .run_until_complete (self .convert_manifest (manifest , class_name = class_name , ** kwargs ))
65+ filename = f"{ class_name } .php"
66+ return ConversionResult (content = php_content , format = "php" , filename = filename )
5967
6068 async def convert_manifest (self ,
6169 manifest : Dict [str , Any ],
@@ -574,6 +582,21 @@ def _generate_php_utility_methods(self, **options) -> str:
574582 self ._decrease_indent ()
575583 utility_methods .append (f'{ self ._indent ()} }}' )
576584
585+ utility_methods .append ("" )
586+
587+ # Data setter to demonstrate typed array parameter
588+ utility_methods .append (f'{ self ._indent ()} /**' )
589+ utility_methods .append (f'{ self ._indent ()} * Set component data' )
590+ utility_methods .append (f'{ self ._indent ()} * @param array $data Data array' )
591+ utility_methods .append (f'{ self ._indent ()} * @return void' )
592+ utility_methods .append (f'{ self ._indent ()} */' )
593+ utility_methods .append (f'{ self ._indent ()} protected function setData(array $data): void' )
594+ utility_methods .append (f'{ self ._indent ()} {{' )
595+ self ._increase_indent ()
596+ utility_methods .append (f'{ self ._indent ()} // In a full implementation, this would store $data for rendering' )
597+ self ._decrease_indent ()
598+ utility_methods .append (f'{ self ._indent ()} }}' )
599+
577600 return '\n ' .join (utility_methods )
578601
579602 def _generate_php_helper_functions (self , ** options ) -> str :
0 commit comments