Joomla - Overriding getItem method - joomla

I want to override the method getItem() found in file \administrator\components\com_content\models\article.php
line 257 public function getItem($pk = null)
I need to modify the return value based on the value of variable $pk.
How do I do this?
I am hoping to find a way to not to modify the core.
Also, if override is possible, can I make a plugin out of it?
Am using Joomla 2.5.9

With some more searching, came across a beautiful solution.
All I needed was to override the model (article.php) under com_content. This got it done.
Using the Plugin Override plugin the Joomla core can be overridden. Found a great article on the same on digitaldisseny
The documentation on overriding Joomla! core's MVC using this is here
Hope it helps others too.
Any better ideas are highly welcome.

Related

Joomla4: howto create a controller via MVCFactory

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?

Liferay Hook for liferay-multi-vm-clustered.xml

I am trying to override the default liferay-multi-vm-clustered.xml for application level caching using a liferay hook. Any instruction or links? Already spent much time googling but didn't find anything useful.
Thanks in advance.
PS: Already know i can override it via manual deployment and portal.properties.
PPS: Sorry for the format new to stackoverflow.
I'm assuming that you're referring to Liferay 6.x
I'm not aware of any hook that can override this file. Specifically because hooks are only deployed after Liferay has fully been set up and started, it'd be changing the setup after the fact.
You can introduce a new file and reference it in portal-ext.properties. If you want to package this in a plugin, I'm afraid it'll be an ext-plugin. Even though I don't like to suggest using ext, in this case it's a well maintainable ext, so it does not bring the same maintenance-danger as code-containing ext plugins.

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).

Correct place to exend FLOW3 Bootstrap?

currently I am trying to register a Doctrine-Eventlistener for every request in my FLOW3-Package. Some research pointed me to the Package.php, but unfortunately the ObjectManager is not available when the boot()-Method is called.
I searched the whole FLOW3-Documentation http://flow3.typo3.org/documentation/guide/partiii/bootstrapping.html without luck
Any hints on which is the right place to do package-wide setup with access to the object manager?
thanks and best regards
Your are bit to early in the bootstrap to get every object, I have a problem, maybe related to yours, you can check my bug report on http://forge.typo3.org/issues/33838
Why do you need a Doctrine Eventlistener, maybe you can use AOP to have this kind of feature ?

Resources