Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Wont work when used from Plugin #5

Open
sasilen opened this issue Dec 12, 2015 · 1 comment
Open

Wont work when used from Plugin #5

sasilen opened this issue Dec 12, 2015 · 1 comment

Comments

@sasilen
Copy link

sasilen commented Dec 12, 2015

Hi,

this still has this bug I issued for Grafikart's version, [https://github.com/Grafikart/CakePHP-Media/issues/38].

If you use this from the plugin, using following 'Posts.Posts' as a Model.
echo $this->Media->iframe('Posts.Posts',$post->id); MediasController.php will fail on line 60.

if (! in_array('Media', $this->$ref->Behaviors()->loaded())) {

$this->loadModel($ref) works fine, it loads Posts.Posts. but when $this->$ref->Behaviors is used, Posts.Posts wont work, you have to use now just plain model name 'Posts'. (At least it's how I managed to get over this first error).

My fix was to add after loadModel (line 58) if condition which removes "PLUGIN." from the $ref if dot is found.

58 $this->loadModel($ref);
if (($pos = strpos($ref,".")) !== FALSE) {
$ref = substr($ref,$pos+1);
}`

@Romano83
Copy link
Owner

Hi,

can you open a pull request for this issue please ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants