Class Drupal\twig_tweak\Twig_Extension not found in Drupal 10 - drupal

I'm developing a website on Drupal 10 and I need the module Twig Tweak to be installed and working in order to use drupal_entity() in templates.
I copy-pasted the module from the /modules directory of another website powered by Drupal 8.9 and changed the line core: 8.x in the twig_tweak.info.yml file to core_version_requirement: ^10
But when I run the new website powered by Drupal 10 on the browser I receive the error
Class "Drupal\twig_tweak\Twig_Extension" not found in include() ...
This error is not thrown on Drupal 8 and 9 - only in Drupal 10.
How to resolve the issue?

The version of the module you are using is incompatible with Drupal 10. Some methods get deprecated, so the core compatibility strategy (update only the yml files) will not work for all cases.
You should download the module via composer
composer require drupal/twig_tweak
This is the recommended way to work with contrib modules. If you have any custom code on it, you should patch it.
Here is some info about patches
https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupal/working-with-patches/making-a-patch
If somehow you can't use composer, try to download it from the module page. And check the core compatibility.
https://www.drupal.org/project/twig_tweak

Related

Use third party composer packages in TYPO3 extensions

I have integrated a Service Worker for receiving Push Notifications in my TYPO3 Extension.
Now I want so send Messages form backend to the clients web-push-php Library.
But how it is possible to integrate the library and its dependencies to TYPO3?
If you set up your project with composer you can just require minishlink/web-push and start using class Minishlink\WebPush\WebPush.
In case you‘re running in "legacy" mode (i.e. classic install without composer) or want to support both you‘ll need a different approach. IMO best practice is bundling composer requirements in .phar files - this way you can keep your IDE clean and your VCS footprint small. There‘s a blog post with a detailed description about phar bundling in TYPO3 extensions.
This method works for most composer requirements following PSR-0 or PSR-4 and should be viable in your case as minishlink/web-push seems to follow PSR-4.
You can even advance this by using scripts you can launch by running composer run <script> in your extension‘s root folder. TYPO3 extension typo3_console holds a composer.json defining such scripts.
If you need to run your extension in a TYPO3 6.2 environment you‘ll need to remove composer.json from extension folder as 6.2 fails coping with "real composer requirements" (i.e. non-TYPO3-extension packages).

How to make drupal module compatible to resolve the error ".zip or tar.gz does not contain any .info.yml files"

I worked on the following Drupal versions,
Drupal 7.5
Drupal 8.2
While working on Drupal 7.5, I never faced a problem while installing the following modules,
Form Module
Poll Module
Pane Module
But, now when I have started a new website on localhost with Drupal 8.2, the following modules are showing issues while trying to install. Maybe the issue is because these modules aren't compatible/ updated with the new Drupal 8.2. These modules are now showing the following error while uploading and trying to install in Drupal 8.2,
"module name".zip or tar.gz does not contain any .info.yml files"
What we can do in that case? I want the above modules to work in Drupal 8.2 as well.
which form module did you try? drupal 8 core provides the contact form. you dont need a module for this. (https://www.drupal.org/docs/8/core/modules/contact/overview)
the poll module has a drupal 8 port. are you sure you downloaded the latest version for drupal 8? (https://www.drupal.org/project/poll)
and finally the pane module is depricated in drupal 8. i think there comes your error because in the pane module is no module.info.yml.
you should try the panels module for drupal 8. (https://www.drupal.org/project/panels) or if you want to write modules yourself read something like here (https://www.drupal.org/docs/8/creating-custom-modules). its a bit more difficult because of the OOP, controller and routing.

Temporary scaffolding on rails 3

I'm new to rails and I'm actually reading a tutorial on it but unfortunately it's a very old one (2007). They talk about temporary scaffolding which is a one-line addition to a controller for example:
class StoryController < ApplicationController
scaffold :story
end
I tried it in my project but I'be got this error:
Routing Error
No route matches [GET] "/story"
Try running rake routes for more information on available routes.
I thought maybe it's because I'm running a different rails version, maybe the syntax have changed... So my question is how do we perform temporary scaffolding on rails 3.
I previously had to set config.assets.enabled to false because I had a route error.
I'm running under:
Rails 3.2.13
Windows 8 pro 32-bits
I'm very surprised to see this, because I wasn't around when Rails had this scaffold method you show. I've never heard of it before.
I searched the API documentation (and Rails source) and there is nothing like this now. Instead, there is the rails generate scaffold command. You can find more information at http://guides.rubyonrails.org/command_line.html.
As a suggestion: If you want to use a version of Rails from 2007, the tutorial you have now is fine. If you want to use a modern version, find a modern tutorial. The Ruby on Rails Guides site is good.

One plugin for drupal 6 and 7

I wrote drupal plugin, that compatible with drupal6 and drupal7. Is there any way to share it as one plugin?
in *.info file there is core = 7.x or core = 6.x. May be I can set smth like core = 6.x, 7.x?
Unfortunately you can't do that.
You'll have to duplicate the module files with different .info file.

Downgrade wordpress plugin to use older version of php

I developed a website in wordpress and used several plugins. One of the plugin was http://wordpress.org/extend/plugins/background-manager/
Every thing was working fine on my machine. But as i get uploaded it to client server. the whole site stuck due to lower version of PHP. This plugin requires PHP 5.3 and on server we have PHP 5.2. Since its a shared server, we can't upgrade its PHP.
Then i look into the code of this plugin it was using PHP 5.3 feature namespaces. Is there any way to downgrade this plugin that it will work with PHP 5.2?
This is a really tricky problem, and of course, it's really, really bad practice to use old code for plugins as they may have fixed security vulnerabilities or other serious problems. It would be better for you to move the site to a server with more up to date PHP.
Having given that important warning, you can, however, browse to the tags directory in the plugin repository and extract the files you want for the previous version. Plugin history is public and always maintained.
For instance, for the plugin you mentioned, you can visit the SVN part of the plugin repository at:
http://plugins.svn.wordpress.org/background-manager/
You'll find the previous versions there under the "tags" folder, named after their versions.

Resources