Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

models in plugins

Hi all

i have a model called "FacebookMeta" how can i use it on plugin?

<?php

use Phalcon\Events\Event,
Phalcon\Mvc\User\Plugin,
Phalcon\Mvc\Dispatcher,
Phalcon\Acl,
Phalcon\Mvc\Url,
Phalcon\Tag,
Phalcon\Mvc\View,
Phalcon\Mvc\Model;

class SetOgMeta extends Plugin
{

 public function setOgMeta()
{
    $uri = $this->router->getRewriteUri();

    $key = 'facebook_meta_'.md5($uri);

    if(!$this->ogMeta = $this->redis->get($key)){

    $fbMetas = FacebookMeta::findFirst(array("url = '".$uri."'"));          

    }

}

Fatal error: Class 'FacebookMeta' not found in /var/www/netmoda/app/plugins/SetOgMeta.php on line 134


6.5k
Accepted
answer

Add FacebookMeta to your use list?



30.0k

How i should do it ?

use Phalcon\Mvc\Model\FacebookMeta;



6.5k

How is your Loader set up?



30.0k

Thanks for all , i can setup without use parameters. Problem with my config , i made a mistake about models path.