Skip to content

Commit

Permalink
zf3 updates: duplicate trait and interface
Browse files Browse the repository at this point in the history
  • Loading branch information
haroutweb committed Apr 14, 2017
1 parent d218030 commit f86f1d4
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Factory/PurifierFilterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

namespace Soflomo\Purifier\Factory;

use Soflomo\Purifier\MutableCreationOptionsInterface;
use Soflomo\Purifier\MutableCreationOptionsTrait;
use Soflomo\Purifier\PurifierFilter;
use Zend\Filter\FilterPluginManager;
use Zend\ServiceManager\MutableCreationOptionsInterface;
use Zend\ServiceManager\MutableCreationOptionsTrait;
use Zend\ServiceManager\ServiceManager;

class PurifierFilterFactory implements MutableCreationOptionsInterface
{
use MutableCreationOptionsTrait;

public function __invoke(FilterPluginManager $filterPluginManager)
public function __invoke(ServiceManager $serviceManager)
{
$htmlPurifier = $filterPluginManager->getServiceLocator()->get('HTMLPurifier');
$htmlPurifier = $serviceManager->get('HTMLPurifier');

return new PurifierFilter($htmlPurifier, $this->getCreationOptions());
}
Expand Down
21 changes: 21 additions & 0 deletions src/MutableCreationOptionsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Soflomo\Purifier;

interface MutableCreationOptionsInterface
{
/**
* Set creation options
*
* @param array $options
* @return void
*/
public function setCreationOptions(array $options);
}
42 changes: 42 additions & 0 deletions src/MutableCreationOptionsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Soflomo\Purifier;

/**
* Trait for MutableCreationOptions Factories
*/
trait MutableCreationOptionsTrait
{
/**
* @var array
*/
protected $creationOptions = array();

This comment has been minimized.

Copy link
@maestroevn

maestroevn Apr 14, 2017

@haroutweb Please use array short syntax [] instead of array()

This comment has been minimized.

Copy link
@jiromm

jiromm Apr 14, 2017

:D

This comment has been minimized.

Copy link
@maestroevn

maestroevn Apr 14, 2017

խասյաթա, նիչեվո նե պադելայեշ :D

This comment has been minimized.

Copy link
@haroutweb

haroutweb Apr 25, 2017

Author

Հին կոդա ախպեր :D


/**
* Set creation options
*
* @param array $creationOptions
* @return void
*/
public function setCreationOptions(array $creationOptions)
{
$this->creationOptions = $creationOptions;
}

/**
* Get creation options

This comment has been minimized.

Copy link
@maestroevn

maestroevn Apr 14, 2017

@haroutweb Please get rid of useless obvious comments 'Get creation options' it's obvious! method named like that getCreationOptions

*
* @return array
*/
public function getCreationOptions()
{
return $this->creationOptions;
}
}

0 comments on commit f86f1d4

Please sign in to comment.