TYPO3 dependency injection with mpdf/mpdf - dependency-injection

I'm currently upgrading a TYPO3 extension from v9 to v10 which uses mpdf/mpdf.
In Services.yaml I've added
mPDF\:
resource: '../../../../../vendor/mpdf/mpdf/'
But now I end up with this error message:
Expected to find class "mPDF\MpdfException" in file
"/var/www/xxxx/vendor/mpdf/mpdf/MpdfException.php" while importing
services from resource "../../../../../vendor/mpdf/mpdf/*", but it was
not found! Check the namespace prefix used with the resource.
The problem is, that the class is MpdfException and not mPDF\MpdfException.
I tried to add
MpdfException\:
resource: '../../../../../vendor/mpdf/mpdf/'
This didn't work.
Next I tried to add this to the global composer.json:
"autoload": {
"psr-4": { "mPDF\\": "vendor/mpdf/mpdf/" }
}
but that didn't work either.

Many thanks for your effort to help me, Julian! Much appreciated! It turned out that the extension had a requirement for an outdated version of mPDF. After using the latest version of mPDF it now works. Nevertheless I still need Services.yaml.

Related

Adding native swift code to NativeScript application

I'm trying to add native swift code to my NativeScript app. According to these instructions in the documentation I can just add a swift source file to App_Resources/iOS/src/ and then use any publicly exposed classes directly in my TypeScript code.
Unfortunately this just doesn't work. I'll just get Cannot find name 'TestClass' and that's it.
Steps to reproduce:
Get a fresh NS project with ios tns create my-app-name --template tns-template-blank-ts
Update: I actually created the App with vue init nativescript-vue/vue-cli-template testapp. That seems to have caused the problems.
Add a TestClass.swift to App_Resources/iOS/src/
import Foundation
public class TestClass: NSObject {
#objc public func echo(param: String) -> String {
return param
}
}
Instantiate it in any TypeScript source file let instance = new TestClass()
Do tns debug ios
Compilation will fail with Cannot find name 'TestClass'
I have also tried generating TypeScript typings with TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios or or just delcaring it as any with declare let KeyCommander: any; to eliminate the possibility that this is a TS related problem. The first approach doesn't generate any typings for my custom class so the TypeScript code will still not compile. The second approach let's the TS code compile but crashes on execution with JS ERROR ReferenceError: Can't find variable: TestClass.
I have also verified that the swift file is indeed getting compiled by inserting a syntax error which will crash the build process.
My NativeScript version is 6.4.0.
What am I missing?
Update: I just realized I actually created the App with vue init nativescript-vue/vue-cli-template testapp. I verified that as mentioned Tyler Blake's answer in an app created with the tns cli the described process actually works. In an app I just freshly created with vue init it doesn't, the objc!nsswiftsupport.d.ts is not being generated.
The question now is: What's causing the difference?
I followed your steps and I was able to get the typings to generate in objc!nsswiftsupport.d.ts. After you generate typings do you have that file with these contents?
declare class TestClass extends NSObject {
static alloc(): TestClass; // inherited from NSObject
static new(): TestClass; // inherited from NSObject
echoWithParam(param: string): string;
}
This shows that NS is able to pick up the Swift code.
All you need to do now is add tns-platform-declarations then in the references.d.ts file, add a line that points to the objc!nsswiftsupport.d.ts file. Then you'll get intellisense in your TS code.
Something like this:
/// <reference path="./typings/objc!nsswiftsupport.d.ts" />
Hope this helps!
I was able to solve the problem by inspecting the differences between the templates created with tns-cli and vue init. The difference is that the vue init template ships with an outdated version of the nativescript platform. You can just simply change
"tns-ios": {
"version": "6.0.1"
}
to version 6.4.0 (which the version the tns-cli template comes with) and then the process will work as described in the documentation.

Angular 4+ 3rd party module import 404 error with base tag

I am putting an angular portion into my MVC app. As such, I have added a tag to my layout view to find the Angular source code, and this is working great.
My issue arises in trying to add a 3rd party module to my project. I added it through the package.json with no problem, and added the module to my app.module.ts as follows:
import { FileUploadModule } from 'primeng/fileupload';
The reference is found, Visual Studio is happy, everything is fine. However, when I run the project locally, I get the following 404 error:
GET http://localhost:59911/src/primeng/fileupload 404 (Not Found)
It seems to me likely that the tag is causing the issue, but I can't remove it without killing the rest of the Angular functionality. Any hints? Can I add an override to the imports call?
Thanks, Mike
On PrimeNG's official website they suggested using import { FileUploadModule } from 'primeng/fileupload'; but it doesn't work any more. I guess they didn't update the docs.
You need { FileUploadModule } from 'primeng/primeng';
The structure is
In the primeng.d.ts file PrimeNG re-exported all modules.
export * from './components/fileupload/fileupload';
For now, no matter which PrimeNG module is used, it is all from primeng/primeng. Here's the imported modules in my project:
import {
ButtonModule,
CodeHighlighterModule,
ConfirmDialogModule,
FieldsetModule,
FileUploadModule,
GrowlModule,
MessagesModule
} from 'primeng/primeng';
The version I use is "primeng": "^4.2.1"
The issue was that primeng was not in the mapping, so it was looking for it in src.
I added the following to systemjs.config.js:
in maps:
'primeng': 'npm:primeng',
in packages:
primeng: {
defaultExtension: 'js'
}
Thanks for the help everyone!

Cannot resolve symbol parse

experts out there! I need your help. I am trying to make my own instant messenger. I refer to this website, and I am stuck at this. There is a read underline bottom of the word, 'parse' and it says Cannot resolve symbol parse. I did everything I could. I put parse-1.10.2.zip in libs file. I added compile fileTree(include: ['*.jar'], dir: 'libs'), compile files('libs/Parse-1.10.2.jar') in build gradle, and added the jar in dependencies. However, the error still there. Can anybody fix this problem? Here's my code:
public class MyApplication extends Application {
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
Parse.initialize(this, "APPLICATION ID", "CLIENT KEY");
}
Have you extracted your zip-archive? I'm no expert but you should put the jar-Files into libs-directory - not a zip-file.
Otherwise try this templates:

Could not find class 'weka.core.FastVector',

I am using weka for my project. but get the error info"could not find class weka.core.FastVector" on the line below. I have already added weka.jar from the build path of the project by adding external jar file. How should I solve this problem? Thanks a lot for your time on reviewing my question.
import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
FastVector atts;
private void setUpARFF(){
atts = new FastVector();}
I know that FastVector was marked as obsolete a while back, perhaps they've finally removed it. Are you using the dev version of weka (or what version are you using)? FastVector can be replaced with ArrayList (in dev version) so use that instead.

Adding Symfony Yaml To Silex

I am looking to add symfony's yaml component to Silex however I am having issues with adding the 5.3 version. Adding the none namespaced version works fine but I would rather have the namespaced version from https://github.com/symfony/Yaml. This is my service provider:
public function register(Application $app)
{
if (isset($app['classPath'])) {
$app['autoloader']->registerNamespace('Symfony\Component\Yaml', $app['classPath']);
}
}
But when I do this is code:
use Symfony\Component\Yaml\Yaml;
Yaml::load(__DIR__ . '/../configuration/application.yml');
I receive the error of:
Fatal error: Class 'Symfony\Component\Yaml\Yaml' not found in
/mnt/hgfs/silex/web/index.php on line 20
Full Correct Answer:
gregoire made a comment about registering the Symfony namespace, not the Symfony\Comonent\Yaml so I basically recreated the directory structure for the namespace and registed the root of the to the Symfony namespace and that works great.
Now that silex is using composer, I am just using composer to include it.

Resources