I am trying to load in Entity classes and use within a loop in order to load content in dynamically from files into relating tables.
Is there any way i can load in all Entity files from the following
JavaScript
x
use AppBundleEntityaaPostcode;
use AppBundleEntityabPostcode;
use AppBundleEntityacPostcode;
use AppBundleEntityadPostcode;
in such a way like this?
JavaScript
use AppBundleEntity*
Not sure if this is possible in Symfony.
My next issue is using the the prefixedEntity within a loop like so –
JavaScript
new $entityPrefix
When i am setting $entityPrefix to the following format
JavaScript
$entityPrefix = str_replace([".csv"], "", $entityFilename) . "Postcode" . '()';
which returns the string of
JavaScript
"abPostcode()"
can anyone advise as to why calling
JavaScript
new $entityPrefix;
is not working
Thanks in advance for any help!
trying to call
JavaScript
new $entityPrefix();
returns
JavaScript
[SymfonyComponentDebugExceptionClassNotFoundException]
Attempted to load class "abPostcode" from the global namespace.
Did you forget a "use" statement for "AppBundleEntityabPostcode"?
even when i current am hrd coding the use stament to call
JavaScript
use AppBundleEntityabPostcode;
Advertisement
Answer
I solved this by pulling out the functionality into a helper and running a switch statement based on the input – in this case a {prefix}