6

"Use" directive when using ReflectionClass in the symfony application

 2 years ago
source link: https://www.codesd.com/item/use-directive-when-using-reflectionclass-in-the-symfony-application.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

"Use" directive when using ReflectionClass in the symfony application

advertisements

I have a class in my symfony 3 app with a method that should instantiate a Model class dynamically using the name that's passed in to the function, i.e.:

static function getInstance($modelName){

    use $modelName;

    $r = new \ReflectionClass($modelName);
    return $r->newInstanceArgs();
}

But there's a syntax error on the use directive.

I've tried adding specific use statements for every class at the top of the file; and I've also tried using require with a fully qualified path to the corresponding PHP file - but neither approach has worked.

Please advise how to correctly do this.


What about this? use qualified class name

static function getInstance($modelName){
    $r = new \ReflectionClass('AppBundle\Entity\\' . $modelName);
    return $r->newInstanceArgs();
}

Related Articles

Using cookies on the iOS application with AFNetworking

I'm building an iOS application which talks to a php web service. The web service also serves a web application. So there is a simple register and login functionality that uses a username and password, on the web application side when you log in you

Where exactly to use ngCloak in the existing application

We have an AngularJS app (not a SPA). We face this problem where some part of uncompiled template is displayed for brief moments, so I am applying ngCloak directive to the app. I'm not sure of where exactly should this directive be used - every singl

Use case for the Web Application API

Nowadays a lot of web applications are providing API for other applications to use. I am new to the usage of API so I want to understand the use cases for it. Lets take Basecamp as an example. What are the use cases for using their API in my web appl

Can I use Jquery in the Windows application?

I want to use some of the features of jquery like item drag and drop..So can we use jquery in windows application(c#)?You could include a WebBrowser control in your WinForms or WPF application and use jQuery from within the web browser. In addition t

Using graphics in the web application (negative value in the bar chart)

I want to use bar chart in web application. I have searched many libraries including google code, and many but many do not support negative values for bar charts.There are a couple of "hacks" to display negative values with the Google Charts API

Rendering the text of the colored list using HTML in the deployed application

Context I'm building a GUI that I plan to deploy. In the GUI there are listboxes in which I want the text to be of different colors. I found how to do it using HTML code, as an undocumented feature, here. Basically the code, copied/pasted from Yair's

Unable to deploy the symfony application to Heroku

At first, sorry for stupid question but I'm new in Heroku as in Symfony. I'm learning Symfony and now trying to deploy my app to Heroku. But after push to heroku I have error I can't solve. I searched for answers but didn't find the solution. My envi

Disabling the symfony application during maintenance

I'm looking for any way to disabled a Symfony application during maintenance support. I mean, in a very simple way: 1) I have a application where people can enter to see the info of the database. 2) The admin could change the info of the database. Du

How to do so in Linux, so that when reading a file, the current application receives data from another application?

Let's say I have a file "hello.txt" containing the text "Hello, world!" I have application "textreader", that reads the file hello.txt and puts it in stdout. Next, i have encrypted the file "hello.txt". Can decrypt

How to call the method automatically when changing views in the TabBar application with a single ViewController

My application uses UITabBarController with 4 tabs. Each tab will have a UIWebView along with other types of objects. When the app launches I need to call the method for this first webView to retrieve my web content. I have this method in my viewdidL

Runtime configuration for the Symfony application

I would like to add a "maintenance mode" to a Symfony application - a simple boolean configuration which I set during runtime. Controllers (or possibly the front controller) can check this value and either; process the request as normal, or retu

AccessControlException when using hibernation in the wso2 application cloud

I am trying to use hibernate in my appllication but, it is throwing a exception. Following is the stacktrace when I am trying to run it. When I try to connect in simple java it works fine. java.security.AccessControlException: access denied ("java.la

Do not use serialize for the Symfony user role

I have a project and a Symfony3 Silex 2 API that is based on the database created with SF3. The problem arises because of the ROLE field in the database, in effect symfony3 stores in the database the user roles via serialize, flint or using a string.

Is there a way to use ffmpeg in the c # application?

I'm using the ffmpeg.org and when I run ffmpeg -y -f vfwcap -r 25 -i 0 out.mp4 in command line I can grab the video from my webcam and write it to the out.mp4 file. However, I can't see that stream anywhere. I thought about writing some simple wrappe

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK