Code Monkey home page Code Monkey logo

Comments (1)

cviebrock avatar cviebrock commented on May 18, 2024

Yeah, that looks like a simple oversight on my part. MR it and I’ll accept.

Thanks!

On Oct 31, 2014, at 10:10 AM, nimbol [email protected] wrote:

Hi,

I've implemented the SluggableTrait on one of my classes and I wanted to dynamically get the reserved slugs using a closure, like so:

['title'], 'save_to' => 'slug', 'separator' => '-', ); public function __construct(array $attributes = array()) { parent::__construct($attributes); $this->sluggable['reserved'] = function() { $result = []; // ??? -> $$$ return $result; }; } ``` } // And the following is added just so you can see it in action: $page = new StaticPage; $page->title = 'About'; $page->sluggify(); Now, when trying to generate the slug, an UnexpectedValueException is thrown: Sluggable reserved is not null, an array, or a closure that returns null/array. This happens because the class (or the trait) is namespaced, but the type checks (SluggableTrait line 57 and 87) say: ``` // check for reserved names if ( $reserved instanceof Closure ) ``` Thanks to PHP's namespaces, this should have been: ``` // check for reserved names if ( $reserved instanceof \Closure ) ``` I can submit a pull request with the fix for this, but I cannot provide unittests because I can't get them to work on my machine. Cheers! — Reply to this email directly or view it on GitHub.

from eloquent-sluggable.

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.