Git Product home page Git Product logo

Comments (12)

stof avatar stof commented on May 27, 2024

The sluggable listener is registered when using the bundle. The point here is adding a way to configure the transliterator used instead of always using the default one.

from stofdoctrineextensionsbundle.

l3pp4rd avatar l3pp4rd commented on May 27, 2024

you can always get the sluggable listener as service and change transliterator.

from stofdoctrineextensionsbundle.

HelloGrayson avatar HelloGrayson commented on May 27, 2024

@stof aah I see. I was getting an error, so I must not have been doing something right. Do you need to do something config-wise to get the listener to register with the bundle? I must be missing something.

from stofdoctrineextensionsbundle.

HelloGrayson avatar HelloGrayson commented on May 27, 2024

@stof. Looks like I didn't activate the extension for the orm entity manager. After searching and being stuck for a day, I'd say this is a common gotcha for new adopters. Do you mind if I put a small note about the exception you would get if you didn't configure correctly in the documentation? This would have saved me alot of time and future searches on the subject would be cleared up at the source. I'll submit the pull if that's cool.

from stofdoctrineextensionsbundle.

ruipenso avatar ruipenso commented on May 27, 2024

The bundle already handles setting the slug? I've searched thought the past issues, and I'm having the same problem as the issue #23 (Column 'slug' cannot be null). Any help? :) Thanks.

from stofdoctrineextensionsbundle.

HelloGrayson avatar HelloGrayson commented on May 27, 2024

@ruipenso please post a gist with your config.yml entry for stof_doctrine_extensions, you're entity, and the place where you are persisting the entity.

from stofdoctrineextensionsbundle.

ruipenso avatar ruipenso commented on May 27, 2024

Hi @Merrix, my gist https://gist.github.com/1047590.
Thanks in advance.

from stofdoctrineextensionsbundle.

l3pp4rd avatar l3pp4rd commented on May 27, 2024

The problem is in annotations:

use Gedmo\Mapping\Annotation as Gedmo;

and when use same style for annotating your properties:

@Gedmo\Sluggable

or

@Gedmo\Slug(separator="-", unique=true)

The annotation mapping was not updated in blog, and docs since it is quite new implementation and users haven't migrated yet.

from stofdoctrineextensionsbundle.

ruipenso avatar ruipenso commented on May 27, 2024

Nice :) Thank you.

from stofdoctrineextensionsbundle.

qpleple avatar qpleple commented on May 27, 2024

I am trying to find a workaround for the bug in slug generation of DoctrineExtensions library (https://github.com/l3pp4rd/DoctrineExtensions/issues/27).

In the thread, @l3pp4rd said that changing the transliterator function could fix the bug by calling:

$sluggableListener->setTransliterator(array('Gedmo\Sluggable\Util\Urlizer', 'urlize'));

I tried to override the service and add a method call to setTransliterator by declaring in my bundle config/services.xml :

<service id="stof_doctrine_extensions.listener.sluggable" class="%stof_doctrine_extensions.listener.sluggable.class%" public="false">
    <call method="setAnnotationReader">
        <argument type="service" id="annotation_reader" />
    </call>
    <call method="setTransliterator">
        <argument type="collection">
            <argument>Gedmo\Sluggable\Util\Urlizer</argument>
            <argument>urlize</argument>
        </argument>
    </call>
</service>

But it does not work because I get at first slug generation:

Integrity constraint violation: 1048 Column 'slug' cannot be null

Do you have any ideas ?

from stofdoctrineextensionsbundle.

l3pp4rd avatar l3pp4rd commented on May 27, 2024

if overriding does not work, you can extend sluggable listener with new class, and in constructor set the transliterator callable. I do not know how DIC prioritizes these services :) read stof docs how to set custom listener classes

from stofdoctrineextensionsbundle.

qpleple avatar qpleple commented on May 27, 2024

Thanks @l3pp4rd, this is working. Here is what it looks like for me now : https://gist.github.com/1170877

from stofdoctrineextensionsbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.