Joomla4: howto create a controller via MVCFactory - for-loop

I am in the process to cleanup the code of my extensions to fit the requirements for the joomla4 API.
Unfortunately there are no migration documentations available to support this effort. I also could not find any refrences or
implementations with the current joomla4 code. If you look into this code you will find mostly the use of depecated (old) methods.
Also searching the web did not help either. Would be fine if someone could help with some hints - especially with this
topic below:
Create a controller instance version 3.0 API:
$controller = BaseController::getInstance($prefix);
I get a hint for the deprecated "getInstance":
Joomla\CMS\MVC\Controller\BaseController::getInstance(string $prefix, array $config=[]) : static
Deprecated. 5.0 Get the controller through the MVCFactory instead
Unfortunately there are no docs nor any samples how to create my controller via MVCFactory - can somebody help with this issue?

Related

Wagtail alongside Django Rest Framework drf-yasg?

I am implementing a Wagtail powered blog within a larger (primarily DRF) driven app. I'm attempting to use drf-yasg for my documentation.
Since installing wagtail, the docs are now throwing
'Request' object has no attribute 'wagtailapi_router'
It looks to be related to the introspection that drf-yasg does, and all I can find about excluding views from drf-yasg is done at the code level. Being an installed module obviously I want to avoid that.
Has anyone got these 2 (3) components playing nicely together?
It's been a very long time since you asked this question, but as I found this while looking for an answer myself, I thought I might share what worked for me.
Note that I'm not using drf-yasg, but rather DRF's own schema generator. They do however have a lot in common.
The problem in my case was that the schema generator URL was defined like this:
path(
"schema/",
get_schema_view(title="My API Schema"),
name="openapi-schema",
),
What I needed to add was a patterns= argument that referenced my API specifically, leaving out the other non-API urls (like Wagtail):
path(
"v3/schema/",
get_schema_view(title="My API Schema", patterns=router.urls),
name="openapi-schema",
),
I hope that helps... someone :-D

elastic search admin API preparePutIndexedScript does not exist anymore

I need to use exactly this method on the adminClusterApi,
client.preparePutIndexedScript()
.setScriptLang("painless")
.setId("script1")
.setSource("script", "_score * doc['my_numeric_field'].value")
.execute()
.actionGet();
I tried the following elastic-search-client version.
* 5.6.1
* 5.3.1
* 5.3.3
but sadly I can't find this method and even the preparePutIndexedScript on the Java Api anymore, does someone have any idea?
according with the documentation this class still exists -> https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/indexed-scripts.html
I found the answer
All the methods related to interacting with indexed scripts have been
removed. The Java API methods for interacting with stored scripts have
been added under ClusterAdminClient class. The sugar methods that used
to exist on the indexed scripts API methods don’t exist on the methods
for stored scripts. The only way to provide scripts is by using
BytesReference implementation, if a string needs to be provided the
BytesArray class should be used.
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_scripting.html#_indexed_scripts_java_apis
would be nice though if the other documentation part that i mentioned would be upgrade was a bit hard to find this.

MvvmCross 4.x in shared project

I am totally new in developing with Xamarin and I try to use the MvvmCross library in a shared project for all platforms. It seems that I succesfully added the libraries in each project, but now I am confused how to start. I tried to follow the documentation, but I think I didnt understand it right. I can use the CreatableTypes Method, but there are no EndingWith or the other Methods from the documentation. The examples that I found are mostly about PCL. I even dont know if this is a version problem or if I missed something important at all. Any hint or link would be helpfull.
First of all be careful what informations you read, always check the date or you will waste your time with some articles which are outdated. The most important ressources are prolly the official sample: https://github.com/MvvmCross/MvvmCross-Samples
Normally you use the PCL for all the background stuffand there should be some class like this https://github.com/MvvmCross/MvvmCross-Samples/blob/master/TipCalc/TipCalc.Core/App.cs . In this class you should be able to register all your services like this for IoC:
public override void Initialize()
{
CreatableTypes().EndingWith("Service").AsInterfaces().RegisterAsSingleton();
And then MVVMCross automatically takes care of initializing it, if you do a constructor injection in the ViewModel as a Example...
public MainViewModel(IPreferenceService preferenceService)
{
// Do Something here with the Service
}
...and you just need to call to show it with it connected view:
ShowViewModel<MainViewModel>();
So basically try to understand the samples first, i think TipCalc is still mostly up to date, atleast it is MVVMCross 4.0 https://github.com/MvvmCross/MvvmCross-Samples/tree/master/TipCalc

Hidden Laravel Methods (5.1)

First, I have IDE helper, and the php storm plugin. I tried the Gist pre made too. There are some similar questions, but no one seems to get answers. I'll probably poke laracasts and ide helper bug list if I don't get anything here.
So I'm following along to some of the into laracasts, and the guy keeps using methods that are not defined as far as I can tell. Situation:
I created a eloquent model called Article. It extends
Illuminate\Database\Eloquent\Model
So now I have App\Article and I can call any of the methods available to model. For example:
$article = \App\Article::all();
PHPStorm is happy. He keeps pulling stuff like ::find() or ::findOrFail()
It's in the docs
I just don't under stand how that works, I don't see the methods defined in model. If this is what ide helper is supposed to fix, then I'm not certain it's working correctly. I can RTFM, I'm pretty sure I followed the directions to a tee.
Ya know, I just found it. I see this question out and about, so I'll answer it here.
https://github.com/barryvdh/laravel-ide-helper/issues/248#issuecomment-131503475
Fixed find or fail for me. find is still MIA. I'm surprised laravel doesn't support their code base in the forms of plugins or dedicated IDE's bit more. It's all just people out there creating a community and moving the world forward so I can't complain too much.
It works because Model implements __callStatic() which dispatches it to itself on a new instance: __callStatic() implementation on Model
It creates a new instance (new static) of the model in question and dispatches the statically called method on the instance.
Effectively, Model::foo($bar) is the same as (new Model)->foo($bar).

restkit and RKManagedObjectSearchEngine

I'm looking for a sample code using RKManagedObjectSearchEngine.
Class are available but not test case and no documentation is available on the API
I have posted this question on the forum but no support :(
Any help is welcome...
The RestKit managed object search engine has been substantially overhauled and completely documented. Please see: https://github.com/RestKit/RestKit/tree/development/Code/Search

Resources