简体   繁体   中英

Context Help for EWZ_SEARCH bundle Symfony Jobeet 2.3 to 2.8 upgrade

A while back I completed this series of tutorials and converted the jobeet from symfony 1 to symfony 2.

http://intelligentbee.com/blog/2013/08/07/symfony2-jobeet-day-1-starting-up-the-project/

I am now trying to upgrade it to 2.8

Everything works except for the lucene search.

I am attempting to implement EWZSearchBundle as a solution.

config.yml

ewz_search:
    indices:
        indexJob:
            path:                 %kernel.root_dir%/EwzLuceneIndices/%kernel.environment%/myIndexJob
            analyzer:             Zend\Search\Lucene\Analysis\Analyzer\Common\Utf8\CaseInsensitive

    # deprecated
    analyzer:             Zend\Search\Lucene\Analysis\Analyzer\Common\TextNum\CaseInsensitive
    path:                 %kernel.root_dir%/cache/%kernel.environment%/lucene/index        

search action in controller

public function searchAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $query = $this->getRequest()->get('query');

        if(!$query) {
            if(!$request->isXmlHttpRequest()) {
                return $this->redirect($this->generateUrl('ibw_job'));
            } else {
                return new Response('No results.');
            }
        }

        $jobs = $em->getRepository('AcmeJobeetBundle:Job')->getForLuceneQuery($query);

        if($request->isXmlHttpRequest()) {
            if('*' == $query || !$jobs || $query == '') {
                return new Response('No results.');
            }

            return $this->render('AcmeJobeetBundle:Job:list.html.twig', array('jobs' => $jobs));
        }

    }

function in entity repository

 static public function getLuceneIndex()
    {
       $luceneSearchForFooIndex = $this->get('ewz_search.lucene.manager')->getIndex('indexJob');

        return $luceneSearchForFooIndex ;
    }

The error that I get in app_dev.php

 Error: Using $this when not in object context
500 Internal Server Error - FatalErrorException 

I know that "$this" is out of context and that is why I am getting the error but I have absolutely no id on how to fix it.

Any help/links to docs/ideas for a solution is greatly appreciated.

Thanks in advance.

Composer Saved the Day

     "sonata-project/doctrine-orm-admin-bundle": "2.3.*",
     "zf1/zend-search-lucene": "~1.12"

After a day or so of trying to make the other search functions work. I was able to the the zend framework work by adding the specific framework component through composer.

It now all works in 2.8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM