Reference a Function in Another File in Another Directory - symfony

I have a component in my Store bundle that needs to access a function getCode() in my Foundation bundle. I have tried referencing this file via use \project\FondationBundle\Foundation\collection\GlobalCollection. This did not work. Any suggestions?
The error reported:
Fatal error: Call to undefined function project\CmsBundle\Cms\Components\getCurrencyCode() in...
It seems that Symfony is looking in the wrong directory.
EDIT - Fixed a typo. The proper path is \project\FondationBundle\Foundation\collection\GlobalCollection

The solution is a customized solution only for my project. My co-worker wrote some code that I just ended up copying. Upon doing further research, the direction that cheesemacfly has directed me is correct, however, not possible to implement in my situation.

Related

Using "UNSAFE_componentWillMount" in strict mode. But I'm not sure where the issue is

I have a Next.js application that when run, gives me this issue on the browsers console.
Warning: Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.
* Move code with side effects to componentDidMount, and set initial state in the constructor.
Please update the following components: SideEffect(NullComponent)
I am not sure what SideEffect(NullComponent) is and searching through all the text in my project returns no result. So I'm not sure where the problem is coming from in order to try and resolve it, or be able to provide some relevant code in here.
What does this error mean, and how can I locate at least what file is causing the issue?
The error that you see is most likely the be in a package that you are using
Try to search for the whole project (including node_modules folder) or look more carefully in the console error (name of the file that generates the error).
This way you will know which package uses the outdated code and decide to keep it or update it or use another similar package.
To search for the whole project including node_modules

Packages not defined

i wrote a script in javascript and used it in rules (share). The script start with:
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
I m getting an error telling me that "Reference error: Packages is not defined".
How can i solve this issue?
The Packages object is only available for code which is considered "secure". This is most likely failing because the code is from a node in the Repository/Data-Dictionary. Put it somewhere in the classpath (e.g. classes/alfresco/templates/webscripts/...).
I don't think you can use this object in javascript, you won't find that code anywhere in Share javascript files. According to this link, Package root scope object is only available for web script implementations placed into the Java classpath, due to security reasons.
Try writing Java code for your rule.

Symfony2 install ChillDevProxyTemplatingBundle - Cannot import resource

i´ve just installed the ChillDevProxyTemplating Bundle for symfony2, described here:
https://github.com/chilloutdevelopment/ChillDevProxyTemplatingBundle/blob/master/Resources/doc/installation.md
My templates was rennamed correctly by the bundle (from 'default' to 'php'), but when i try to call my controller I get the following error:
Cannot import resource "." from (...)app/cache/dev/assetic/routing.yml". (The following loader(s) are not registered: default).
Has anyone an idea how to fix??
Thanks a lot !
As explained here: https://github.com/chilloutdevelopment/ChillDevFileManagerBundle/issues/27
You might just need to install ChillDevViewHelpersBundle to get it working.
I previously added answer to this question, but it was removed by moderator since my reputation was not high enough to post a comment.
But now thanks to support of community I was able to investigate this problem:
https://github.com/chilloutdevelopment/ChillDevProxyTemplatingBundle/issues/2
It's now fixed :). Thank you for pointing the problem.
The problem was, that Assetic, in dev environment tries to parse all the templates based on templating engine name so it needs loader for each templating engine - of course for "default" there was no loader and thus caused an exception.

Invalid Type Error Occasionally in Symfony 2 Console

I have a Symfony 2 environment in which I am using a custom data type with Doctrine's MongoDB ODM mappings. This all works, except occasionally; when I go to clear the cache or install the assets I sometimes receive the following error:
[InvalidArgumentException]
Invalid type specified "..."
This seems to always happen with the next command I issue to the console after I have cleared the cache, later operations all succeed. Doctrine seems to have issues intermittently finding it, and I suspect it has to do with where I'm registering the type and when that occurs with relationship to when Doctrine processes the mappings.
The type is being added as part of the boot() method in another bundle which may not always be included.
What is happening here?
Can I somehow ensure that the type is loaded earlier, or provide it in a configuration file? As far as I can tell there is no way, at present, using the MongoDB configuration to specify custom types in a .yml file as described for the ORM here.
I found a good solution in this post.
The short answer is to add
\Doctrine\ODM\MongoDB\Mapping\Types\Type::registeredType('mytype', 'My\Type\Class');
in MyBundleClass::__consruct(). This will get the type registered before any warmup happens with the cache.
Using Type::registeredType() instead of Type::addType() will avoid checking to see if the type is already registered. In the case of Type::addType() will throw an exception if it has already been added.
To answer the second of my two questions above, I seem to have found a work-around for this, but I don't like it very much. It feels more like a hack than a proper solution.
In app/autoload.php after I register the annotation registry and driver, I call:
\Doctrine\ODM\MongoDB\Mapping\Types\Type::addType('mytype', 'My\Type\Class');
... and this appears to ensure that the type is registered when calling the console commands.

Runtime error but project compiles fine - Imports/using missing

I am very confused right now. I have VS2008 at my job right now and I have a weird behavior that I have been searching for a while now.
When I compile the project, it works fine, but in runtime I have an error saying object not defined or something like that. The problem is that the imports/using is missing in my class but why does it compile?
In fact, I want to be able to see that error when compiling not when running the webapp.
REEDITED: Here is an example. Lets say i want to use a typed list, I am declaring my object list(of int) for example without having added my imports (system.collection.generic) in the class. then I compile, it works and then I run it, it fails because of the imports missing. is this normal behavior or not?
REREEDITED: I just noticed that the DLL of all my references were not copied in my bin folders even though all of them are set to "Copy local = true". Is it possible that it has to do with our shared directory (all external dlls) being on a network drive (\server\shared). I am really out of ideas on this issue....
problem was because we were having the classes in the app_data folder
The answer to the current question - why you are getting this error - is that ASP.NET does not show many errors at compile-time. You will need to manually go through the application to verify that all pages work correctly. This is very common with ASP.NET development, due to the nature of the environment.
If you post the real errors (probably should be as another SO question), we can perhaps help you with them.
Remove all the dll, etc from bin...
rebuild the whole solution then run
It should run fine...

Resources