Closed rifats closed 9 years ago
Hello, I tried again to install the bundle in an empty project to test the operation and I can not replicate the error!
the file orm.xml contains the following statements:
<service id="dcs_rating.manager.rating.default" class="%dcs_rating.manager.rating.default.class%">
<argument type="service" id="event_dispatcher" />
<argument type="service" id="doctrine.orm.entity_manager" />
<argument>%dcs_rating.model.rating.class%</argument>
</service>
<service id="dcs_rating.manager.vote.default" class="%dcs_rating.manager.vote.default.class%">
<argument type="service" id="event_dispatcher" />
<argument type="service" id="doctrine.orm.entity_manager" />
<argument>%dcs_rating.model.vote.class%</argument>
</service>
and the "event_dispatcher" is passed correctly. Try to clear the cache manually by running from a console rm-rf app/cache/*
Let me know if the problem persists!
thanks :-)
Thanks for the answer. I can not find the cause. But this problem in the project at S2.5.5. There is no problem at S2.3.2. Оne more question. In the FireFox rating stars not active and behave as plain text. How do you solve this?
As often happens, вug disappears as soon as it is reported. So, in the FireFox stars work fine! And what about a custom number of stars? If you need 10 stars? Thank you.
I updated the plugin and I have added the ability to specify a maximum value for the voting (number of stars displayed).
The configuration is called max_value
and the default value is 5
Thank you so much! It works fine.
Hi,
In VoteManager and RatingManager, model and entity, you will use EventDispatcherInterface and not EventDispatcher.
On pages without DCSRating occurring this error:
INACTIVESCOPEEXCEPTION: YOU CANNOT CREATE A SERVICE ("REQUEST") OF AN INACTIVE SCOPE ("REQUEST").
How fix this?
Hi,
I discover when this 2 problems occurs when the development environment is enabled. In production environment is ok!
Solve the erro with Request using (see http://stackoverflow.com/questions/17942738/error-you-cannot-create-a-service-templating-helper-assets-of-an-inactive-s), the constructor of DCS\RatingBundle\EventListener\RatingUpdateInfoEventListener:
public function __construct(Container $container) { $container->enterScope('request'); $container->set('request', new Request(), 'request'); $this->request = $container->get('request'); }
Hello silasrm, have perfectly right with regard to the interfaces. Would try though a solution as regards the problem of the "scope" on "request": (see http://symfony.com/doc/2.3/cookbook/service_container/scopes.html#using-a-synchronized-service)
// DCSRatingBundle/EventListener/RatingUpdateInfoEventListener.php
//... use
class RatingUpdateInfoEventListener implements EventSubscriberInterface
{
/**
* @var Request
*/
private $request;
/**
* Set request
*
* @param Request $request
*/
public function setRequest(Request $request = null)
{
$this->request = $request;
}
public static function getSubscribedEvents()
{
return array(
DCSRatingEvents::RATING_PRE_PERSIST => 'updatePermalink',
);
}
public function updatePermalink(RatingEvent $event)
{
if (null === $this->request) {
return;
}
$rating = $event->getRating();
if (null === $rating->getPermalink()) {
$rating->setPermalink($this->request->get('permalink'));
}
if (null === $rating->getSecurityRole()) {
$rating->setSecurityRole($this->request->get('securityRole'));
}
}
}
<service id="dcs_rating.listener.rating_update_info" class="%dcs_rating.listener.rating_update_info.class%">
<call method="setRequest">
<argument type="service" id="request" on-invalid="null" strict="false" />
</call>
<tag name="kernel.event_subscriber" />
</service>
what do you say?
Hi Damiano,
I don't tried yet, but if is total functional, then is a good solution.
I'm send a pull request, but I used the solution posted before. Your solution is much better.
Thks
Hi silasrm, I accepted your "pull request" and I introduced the solution that offers the cookbook symonfy. If you will not have problems will release a stable version. I await your own feedback.
thanks
Hi Damiano,
I have no problem. Release the kraken! :D
Thks
Hi silasrm, I released a new stable release! :-D
Hi damianociarla,
Congrats! Thanks for your bundle.
I go update soon.
What's wrong?
{% include 'DCSRatingBundle:Rating:control.html.twig' with { 'id': post.id } %}
CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Argument 1 passed to DCS\RatingBundle\Entity\RatingManager::__construct() must be an instance of Symfony\Component\EventDispatcher\EventDispatcher, instance of Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher given, called in ..\app\cache\dev\appDevDebugProjectContainer.php on line 1003 and defined in ..\vendor\damianociarla\rating-bundle\DCS\RatingBundle\Entity\RatingManager.php line 27") in "DCSRatingBundle:Rating:control.html.twig" at line 3." at ...\app\cache\dev\classes.php line 4569