2017 © Pedro PelĂĄez
 

library akismet-bundle

Akismet Bundle

image

openclassrooms/akismet-bundle

Akismet Bundle

  • Wednesday, December 14, 2016
  • by openclassrooms-admin
  • Repository
  • 16 Watchers
  • 1 Stars
  • 16,343 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 14 % Grown

The README.md

AkismetBundle

SensioLabsInsight Build Status Coverage Status, (*1)

The AkismetBundle offers integration of the Akismet Library. Akismet Library is a PHP5 library that provides Akismet Spam Protection service functionality in your application. See Akismet for full details., (*2)

Installation

This bundle can be installed using composer:, (*3)

composer require openclassrooms/akismet-bundle, (*4)

or by adding the package to the composer.json file directly:, (*5)

{
    "require": {
        "openclassrooms/akismet-bundle": "*"
    }
}

After the package has been installed, add the bundle to the AppKernel.php file:, (*6)

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new OpenClassrooms\Bundle\AkismetBundle\OpenClassroomsAkismetBundle(),
    // ...
);

Configuration

# app/config/config.yml

openclassrooms_akismet:
    key:  %akismet.key%
    blog: %akismet.blog%

Usage

Default Service

$commentBuilder = $container->get('openclassrooms.akismet.models.comment_builder');
$akismet = $container->get('openclassrooms.akismet.services.default_akismet_service');

$comment = $commentBuilder->create()
                          ...
                          ->build();

if ($akismet->commentCheck($comment)) {
 // store the comment and mark it as spam (in case of a mis-diagnosis).
} else {
 // store the comment normally
}

// and

$akismet->submitSpam($comment);

// and

$akismet->submitHam($comment);

Bridge Service

The Bundle integrates a bridge service which gets the Symfony2 requestStack to automatically set the UserIP, UserAgent and Referrer., (*7)

<service id="openclassrooms.akismet.services.akismet_service" class="OpenClassrooms\Bundle\AkismetBundle\Services\Impl\AkismetServiceImpl">
    <call method="setAkismet">
        <argument type="service" id="openclassrooms.akismet.services.default_akismet_service"/>
    </call>
    <call method="setRequestStack">
        <argument type="service" id="request_stack"/>
    </call>
</service>

You can use it by getting this service id:, (*8)

$akismet = $container->get('openclassrooms.akismet.services.akismet_service');

instead of:, (*9)

$akismet = $container->get('openclassrooms.akismet.services.default_akismet_service');

The Versions

14/12 2016

dev-master

9999999-dev

Akismet Bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arnaud Lefèvre
by OpenClassrooms

14/12 2016
16/03 2016