This used to work in TYPO3 9 and TYPO3 10 but is not working from me in TYPO3 11:
EXTDIR/Configuration/RequestMiddlewares.php
<?php
return [
'frontend' => [
'varioous/rest/mail-chimp-middleware' => [
'target' => Varioous\Rest\MailChimpMiddleware::class,
'before' => [
'typo3/cms-frontend/eid',
'typo3/cms-frontend/tsfe',
],
],
],
];
I've looked at this description here https://docs.typo3.org/m/typo3/reference-coreapi/11.5/en-us/ApiOverview/RequestHandling/Index.html but I can't find the problem. The code is from this example: https://various.at/news/typo3-tipps-und-tricks-psr-15-mideelware-am-beispiel-mailchimp-webhook and has been adjusted to a custom made extension that has been working fine with TYPO3 9 and TYPO3 10. The particular extension belongs to the customer and I am not permitted to post it here. It is configured exactly as the mailchimp extension is in the how-to and I am sure the author used that how-to as a reference. As it seems, the mailchimp extension from the TER stopped using middleware - so I can't use the current version as a reference to fix my problem.
With this temporary workaround it's working fine:
<?php
return [
'frontend' => [
'varioous/rest/mail-chimp-middleware' => [
'target' => Varioous\Rest\MailChimpMiddleware::class,
'before' => [
# 'typo3/cms-frontend/eid',
# 'typo3/cms-frontend/tsfe',
],
],
],
];
How do I have to adjust the references to 'typo3/cms-frontend/eid' and 'typo3/cms-frontend/tsfe' for TYPO3 11? When I look up HTTP Middlewares (PSR-15) in the Configuration BackEnd module I can find them in the frontend category:
typo3/cms-frontend/eid = TYPO3\CMS\Frontend\Middleware\EidHandler
typo3/cms-frontend/tsfe = TYPO3\CMS\Frontend\Middleware\TypoScriptFrontendInitialization
FYI Further description of the Problem:
Once the extension is activated, ALL local extbase extensions stop working. For Example:
#1316104317 TYPO3\CMS\Extbase\Mvc\Exception
The default controller for extension "News" and plugin "Pi1" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.
Of course there is nothing wrong with the news extension. I temporarily added a debug output in the file typo3/sysext/extbase/Classes/Mvc/Web/RequestBuilder.php
protected function loadDefaultValues()
{
$configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
print_r($configuration);
When the extension with the middleware is activated, the value "controllerConfiguration" in the array returned from the ConfigurationManager is empty (for all local extensions).
Related
I create a Vue 2 project by Vue-Cli 5, then I want to remove "use strick" in the complied code.
As I Know, the #babel/plugin-transform-strick-mode may be enabled via #babel/plugin-transform-modules-commonjs, and the plugin is included in #babel/preset-env under the modules option.
But the Vue-Cli used a preset #vue/babel-preset-app by a plugin #vue/cli-plugin-babel for babel.
So my question is How pass strictMode: false as an option to the transform-modules-commonjs by #vue/babel-preset-app which preset is in the #vue/cli-plugin-babel ?
module.exports = {
presets: [["#vue/cli-plugin-babel/preset", { modules: "auto" }]],
plugins: [
// I tried this way, but it throw many errors like:
/**
ERROR in ./node_modules/axios/dist/node/axios.cjs 11:15-32
Module not found: Error: Can't resolve 'stream' in 'D:\workspace\cqset_offical_website\node_modules\axios\dist\node'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
*/
["#babel/plugin-transform-modules-commonjs", {}],
[
"component",
{
libraryName: "element-ui",
styleLibraryName: "theme-chalk",
},
],
],
};
In https://www.mediawiki.org/wiki/Extension:TinyMCE, there a section with Toolbar buttons including a Citation/reference button which looks like this:
Furthermore, it says: "Depending on configuration, some or all of these buttons may be shown".
It is not clear however how to enable/disable specific buttons in LocalSettings.php.
In the https://www.mediawiki.org/wiki/Extension:TinyMCE/Configuration page, there are instructions on how to add buttons to toolbars, and based on that I have added this to my LocalSettings.php:
wfLoadExtension( "TinyMCE" );
$wgTinyMCEEnabled = true;
$wgTinyMCESettings = [
".tox-tinymce" => [
"toolbar+" => " | citation",
],
];
.tox-tinymce being the selector for the text box where TinyMCE applies.
The citation button does not appear currently, and before I debug, I'd like to know (1) if I am on the right track, and (2) how can i know the machine name of a button (I assume it's citation, but maybe it's "footnote" or "cite", it is not clear where to find the mapping of machine names to buttons).
I have gone through the mediawiki-extensions-TinyMCE-master
Inside custom plugin directory mediawiki/plugins I saw 12 custom plugins.
I have opened one by one plugin code I observed only 3 plugins wikitext, wikitoggle , wikiupload are loaded in tinymce plugin manager. Ex:-
tinymce.PluginManager.add('wikitoggle', wikitoggle);
I could enable these buttons directly in load-extensions.php.
wfLoadExtension( "TinyMCE" );
$wgTinyMCEEnabled = true;
$wgTinyMCESettings = [
"#wpTextbox1" => [
"toolbar" => 'wikitext wikitoggle wikiupload',
],
];
I saw wikireference code at the end it has plugin function defination.
function Plugin () {
// only load plugin if the 'cite' extension is enabled
// in the wiki, eg, if 'ref' tag is in extension tag list
if ( extensionTagsList.split('|').indexOf('ref') > -1 ) {
pluginManager.add('wikireference', function (editor) {
registerCommands( editor );
registerButtons( editor );
setup( editor );
});
}
}
Plugin();
// only load plugin if the 'cite' extension is enabled
// in the wiki, eg, if 'ref' tag is in extension tag list
from the plugin method comments I could figure it out how to load reference and comment buttons.
first we need to download and install Cite extension plugin
echo 'Downloading and installing Cite'
echo 'See https://www.mediawiki.org/wiki/Extension:Cite#Installation'
curl -O -L https://github.com/wikimedia/mediawiki-extensions-Cite/archive/refs/heads/master.zip
unzip master.zip
rm master.zip
mv mediawiki-extensions-Cite-master extensions/Cite
Enable reference and comment button in load-extensions.php
[
"toolbar" => 'reference comment',
],
];
I have a question regarding symfony/form using as a standalone component and security-csrf running with PHP build-in server. I hardly remember having such issue with the Symfony framework.
When setting symfony/form as a standalone component I tried this code for both v4.2 and v5.1 https://github.com/xmgcoyi/standalone-forms/tree/4.2+twig. A rewrite of webmozart's example mentioned here https://symfony.com/doc/current/components/form.html
The csrf token is generated with twig-bridge, but when submitting the form - on calling$form->isValid() - invalid csrf error appears.
By default csrf protection is enabled, setting to false - the form submits.
Tried CSRF component with both setups with NativeSessionTokenStorage and SessionTokenStorage + Session of HttpFoundation.
Could you give any hint on what I'm doing wrong and where to look at?
P.S.
Code samples with csrf error on submission:
https://github.com/xmgcoyi/standalone-forms/tree/4.2+twig
https://github.com/liorchamla/pratique-symfony-form/tree/06-protection-csrf
UPD
The apps above work well, the problem was in browser storage filled with garbage.
Setting to false in $formFactory->createBuilder(FormType::class, null, ['csrf_protection' => false]) submits the form
This is a bit of a guess but the 4.2 linked repo has:
$csrfManager = new CsrfTokenManager($csrfGenerator, $csrfStorage);
$csrfTokenManager = new CsrfTokenManager();
Two token managers. One is used in the twig form engine and one is used in the form factory extension. Does not seem like a reasonable thing to do.
Here is an updated 5.1 working example. I stripped it down even more from your linked repo. But the only thing that I really changed was the token manager.
# index.php
require_once '../vendor/autoload.php';
$app = new App();
$app->run();
final class App
{
public function run()
{
$csrfGenerator = new UriSafeTokenGenerator();
$csrfStorage = new NativeSessionTokenStorage();
$csrfManager = new CsrfTokenManager($csrfGenerator, $csrfStorage);
$twig = new Environment(new FilesystemLoader([
'../templates',
'../vendor/symfony/twig-bridge/Resources/views/Form',
]));
$formEngine = new TwigRendererEngine(['form_div_layout.html.twig'], $twig);
$twig->addRuntimeLoader(new FactoryRuntimeLoader([
FormRenderer::class => function () use ($formEngine,$csrfManager) {
return new FormRenderer($formEngine, $csrfManager);
},
]));
$twig->addExtension(new TranslationExtension());
$twig->addExtension(new FormExtension());
$formFactory = Forms::createFormFactoryBuilder()
->addExtension(new CsrfExtension($csrfManager))
//->addExtension(new ValidatorExtension($validator))
->getFormFactory();
$form = $formFactory->createBuilder()
->add('firstName', TextType::class)
->getForm();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$form->submit($_POST[$form->getName()]); // form
if ($form->isValid()) {
dump('form is valid');
}
}
echo $twig->render('index.html.twig', [
'form' => $form->createView(),
]);
}
}
The composer.json is simply:
{
"require": {
"symfony/form": "^5.1",
"symfony/twig-bridge": "^5.1",
"symfony/translation": "^5.1",
"symfony/security-csrf": "^5.1"
},
"require-dev": {
"symfony/var-dumper": "^5.1"
}
}
If you still have trouble then I would suggest tracking down where the sessions are stored and then verifying the that csrf token is being properly stored. It should look something like:
_csrf|a:1:{s:4:"form";s:43:"9v1tUNe3J3eYVOmEPwVdz5_iISfzBg8Qa9pLMV8tSN4";}
This was actually kind of an interesting exercise in using the twig system for standalone forms. Thanks.
i want to imeplement the extension sr_freecap in an own extension in a TYPO3 9 LTS. The viewhelper shows the text and the correct html but the link to the image looks like this:
mydomain.com/index.php?eIDSR=sr_freecap_EidDispatcher&id=9781&vendorName=SJBR&extensionName=SrFreecap&pluginName=ImageGenerator&controllerName=ImageGenerator&actionName=show&formatName=png&L=0&set=571e0
When i call this url manually i get the whole page and not the image. Is eIDSR correct? I was in the opinion that the correct call should be eID= ... I can't find information about it.
Any help appreciated!
I missed the existing bug report: https://forge.typo3.org/issues/89735
I tried the above solution and it works:
Put in your extension in which you implements sr_freecap this file:
/your-extension/Configuration/RequestMiddlewares.php
with the following content:
<?php
return [
'frontend' => [
'srfreecap-eidhandler' => [
'target' => \SJBR\SrFreecap\Middleware\EidHandler::class,
'before' => [
'typo3/cms-frontend/content-length-headers',
],
]
]
];
this will work. Seems like a necaissary feature which is not mentioned in the manual.
So I am using Kevin Hill's excellent PHP wrapper for Google Charts, 'LavaCharts' and am following his guide on how to access the image URI of each (I need to output the charts in an image format so that I can export the page as a PDF).
https://github.com/kevinkhill/lavacharts/wiki/Getting-a-chart-as-an-image-3.0.x
I am getting the following error: 'getImageCallBack is not defined'
I am registering the 'getImageCallBack' event on each chart from the Controller:
\Lava::PieChart('TotalCallsReceived', $totalCallsReceived, [
'events' => ['ready' => 'getImageCallBack'],
'title' => 'Total Calls Received & Transferred',
'is3D' => false,
]);
And then in the head of my page I have the following. (I will figure out what to do with the URI once I've solved this error. For now logging it is fine)
<script type="text/javascript">
function getImageCallback(event, chart) {
console.log(chart.getImageURI());
// This will return in the form of "data:image/png;base64,iVBORw0KGgoAAAAUA..."
}
</script>
Has anybody else overcome this problem?
the function names are different and need to match case...
the "B" is capitalized here...
'events' => ['ready' => 'getImageCallBack'],
and not here...
function getImageCallback(event, chart) {