$this->request->getArgument('group'); not working outside the plugin for breadcrums - typo3

I building an TYPO3 extension, withs contains a frond-end plugin. In the fluid template I'm using the following link. This links contains the argument named "group" to send the value "3" to the page.
<f:link.action pageUid="1" pluginName="PluginAds" controller="Ads" arguments="{group: 3}">
In the controller "PluginAds" under "AdsController" it works ok to get the value with the following action:
$this->request->getArgument('group');
But I also want to use the argument "group" for generating the correct breadcrums link. But when I use the same code in a different controller I'm getting the error that the argument does not exists. Can anyone help on this?

Inspect with browser tools how does f:link.action constructs prefixes for params of your plugin, it's i.e.: tx_extkey_pluginsname[myparam]
Within the plugin's actions you can get myparam by
$this->request->getArgument('myparam')
anyway anywhere else you need to get it as normal GET array, so it will be something like:
$pluginsParams = GeneralUtility::_GET('tx_extkey_pluginsname');
$myParam = $pluginsParams['myparam'];
Other thing is that you should always check if:
$this->request->hasArgument('group')
Before trying using it, otherwise it can lead you to null pointer exception.

Related

New enrolment method is not working properly in Totara (Moodle)

I am trying to add a new custom enrolment method to a base Totara (Moodle) installation. I decided to copy the existing "Self enrolment" enrolment method, because it is relatively simple and therefore seemed to be a good starting point for my custom method.
I changed the name and all of the references to the "Self enrolment" method to my new method name. This seemed to have worked because when I logged into the Totara dashboard I got the popup for a new plugin installation.
I went through the installation process and didn't run into any errors. Next I activated my plugin in the "Enrolment plugin" menu. Everything seemed fine until I tried to add my new method to a course.
Firstly the new method should be displayed bij default on the "Enrolment methods" page of the course but it isn't, however I can select it with the dropdown located below. When I do I am redirected to the config page of the enrolment method, so far so good. But when I click the button on the bottom of the page to add the method to the course it still isn't visible on the "Enrolment methods" page of the course.
When I log in as a regular user I can't access the course through my new method, so the method and the course haven't been properly linked. However when I look in the database I do see that my new method has been added to the course in the enrol table.
The problem doesn't seem to be caching related because I have purged it a couple of times already but the method still won't show up.
I am working with Totara version 16.2 (Moodle 3.4.9)
I found the problem, it seems that the "Self enrolment" plugin uses the get_name() function of the /server/lib/enrollib.php by default. However this function is written in a way to avoid "fancy" plugin names according to a comment in the function. The function explodes your plugin name on "_" and only uses the first part of your name, which means the records in enrol won't be recognised as records of your plugin because the names don't match.
I solved this by adding my own get_name() to my plugin, which returns the whole name.
The function:
/**
* Returns name of this enrol plugin
* #return string
*/
public function get_name() {
// second word in class is always enrol name, sorry, no fancy plugin names with _
$words = explode('_', get_class($this));
return $words[1];
}

Defining a new variable in order to make a huge iteration giving me an error

I have an endpoint, you can have informaciĆ³n about products
{{URL_API}}/products/
If i perform a GET method over that endpoint i will obtain the information of every product
BUT i can also specify the product that i want to know about, i.e:
{{URL_API}}/products/9345TERFER (the last code is the id of the product, called SKU)
The problem is that if i want to make a CSV in order to update the information of different products i have to define a variable called sku in the endpoint so i will be able to pass the corresponding SKU
I want to create the variable {{sku}} but i do not understand how to do that.. i tried so many times and i failed, i've searched a lot but i do not really understand
Also, should i use ":" before the declaration of the variable? i mean:
{{URL_API}}/products/:{{sku}}
or simply:
{{URL_API}}/ns/products/{{sku}}
Can you help me?
I'm super lost :(
EDIT:
I want to perform a PUT method, i want to pass different values to the body and then.. send the request (it throws an error: 404 not found)
This is what i did:
PUT|{{URL_API}}/products/{{sku}}
body:
{
"tax_percentage":"{{tax_percentage}}",
"store_code":"{{store_code}}",
"markup_top":"{{markup_top}}",
"status":"{{status}}",
"group_prices": [
{
"group":"{{class_a}}",
"price":"{{price_a}}",
"website":"{{website_a}}"
}
]
}
CSV:
POSTMAN:
Your issue seems to be just a basic understanding of how data files work with variables in Postman, here's a simple example that will work the same way for you too.
This is a basic request I'm using to resolve the variable from the data file - It's a GET request but that doesn't matter as all we're look at here is using a data file to resolve variables. All you need to do is ensure the URL is correct and that you SAVE the request before using the runner.
Here's a simple CSV file created in a text editor. The heading sku in the name on the variable it will reference inside the Postman request. Each value under that is the value that will be used for each iteration.
In the Runner, select your Collection from the list (If you have more than one) then select the CSV file. Once imported, you will be able to see a preview of the data.
If that's correct, press the Run button. The Runner will then iterate through the file and pick up the sku value in the CSV file and use it in the request. I've expanded one of the requests so you can see that the value was used in the request.

Error: Unable to find an element with the role "alert" (react-testing-library example)

I'm using the stock codesandbox example from react-testing-library and I've added two files, Login.jsx and __tests__/Login.js . These files are copied directly from the react-testing-library examples on the main readme.md.
However, when the test suites run, I get an error:
Error: Unable to find an element with the role "alert
When I debug this, the html output does not appear to have any role attributes in any of the divs. What am I doing wrong?
Codesandbox: https://codesandbox.io/s/react-testing-library-examples-dh1e7
Probably it's too late. But anyway.
Your components does not set success field it relies later on:
{state.success ? (
<div role="alert">Congrats! You're signed in!</div>
) : null}
Probably it should be state.resolved

how to verify text present in placeholder in selenium IDE

I want to verify the text present in placeholder. I have located the element and i am using Assert text command. I've entered the same string in value. On executing it is showing actual value did not match
Use assertAttribute or verifyAttribute command.
Example:
verifyAttribute | css=#search#placeholder | Sample String
Notes:
In the Target column of Selenium IDE, you need to provide the proper path of the element followed by an # sign
and then the name of the attribute. (placeholder in your case)
Using
verifyAttibute will still continue running the test case once an
error is detected while using assertAttribute doesn't.
You need to understand that assertText function can only check static text on your webpage.
You must be getting an error message.
This is perfectly normal.
What can help in this situation is using the assertAttribute or verifyAttribute functions.
Both these functions perform the same task; the former stops the test after receiving an error message in the text box while verifyValue just records the error in the log and runs the next commands.
While giving the target, either specify the XPath or refer by using the name=name#placeholder format.
You can find the name value by inspecting the box with a firefox addon called Firepath which runs with another firefox tool called Firebug. Install them if you don't already have.
Hope this helps!
Xpath contains() is the best way.
driver.find_element_by_xpath('//input[contains(#placeholder,"email")]')
Format : '//tag[contains(#attribute,"value")]'

Apache Wicket event on Page "page was mouted on ..."

I have mount Page in this form (with one predefined parameter):
mountPage("/lista/${variant}", StronaEntityV2.class);
when parameter "variant" is given all is OK. But when parameter is absent (is OK too from application point of view) URL is build in form
wicket/bookmarkable/all....package...StronaEntityV2?8
It is ok too, but I will know that situation. In simple situation (with one predefined parameter) checking parameter is good, but in more complicated isn't so simple (and must maintain code in distinct places).
My ideal imaged solution is event
page.OnPageIsMountedOn(URL to_me)
I will accept wide range of solutions.
FORMAL: please integrate synonyms on tags wicket-1.6 & wicket-6, and create new wicket-7
Your page is configured to listen to /lista/${variant}.
When you do: setResponsePage(StronaEntityV2.class, paramsWithVariant) then Wicket will use the mount point and produce: /lista/variantValue.
But if you do: setResponsePage(StronaEntityV2.class), i.e. no PageParameters provided, then Wicket will ignore /lista/${variant} (because it doesn't match) and will produce a "default" page url, i.e. /wicket/bookmarkable/com.example.StronaEntityV2.
So the application controls which url should be used.
You can use optional parameter placeholder: /lista/#{variant}. Note that I use # instead of $ now. This way Wicket will produce /lista/ when there is no variant parameter provided. In the page constructor you will know that the url is always "/lista" but the parameter may be null, so better use: pageParameters.get("variant").toXyz(defaultValue) or .toOptionalXyz().