Coder Social home page Coder Social logo

Resolving through IOC about laravel-akismet HOT 4 CLOSED

nickurt avatar nickurt commented on August 25, 2024
Resolving through IOC

from laravel-akismet.

Comments (4)

garygreen avatar garygreen commented on August 25, 2024

For instance doing app('App\Spam\Checker') on the below should ideally resolve the depdency-injected Akismet class through laravel's IOC which will set the api details, but it doesn't because of the way it's bound in the service provider:

<?php namespace App\Spam;

use nickurt\Akismet\Akismet;

class Checker {

    /**
     * Spam checker.
     *
     * @var nickurt\Akismet\Akismet
     */
    protected $checker;

    /**
     * Start spam checker.
     *
     * @param Akismet $checker
     */
    public function __construct(Akismet $checker)
    {
        $this->checker = $checker;
    }

    /**
     * Determine if given array of options is spam.
     *
     * @param  array $data
     * @return boolean
     */
    public function isSpam(array $data)
    {
        if (!is_null($name = array_get($data, 'name')))
        {
            $this->checker->setCommentAuthor($name);
        }

        if (!is_null($email = array_get($data, 'email')))
        {
            $this->checker->setCommentAuthorEmail($email);
        }

        $this->checker->setCommentContent($data['message']);

        return $this->checker->isSpam();
    }

}

from laravel-akismet.

nickurt avatar nickurt commented on August 25, 2024

Can you do a Pull Request for this?

from laravel-akismet.

nickurt avatar nickurt commented on August 25, 2024

Ping @garygreen ?

from laravel-akismet.

nickurt avatar nickurt commented on August 25, 2024

Solved

from laravel-akismet.

Related Issues (12)

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.