Skip to content

Commit

Permalink
New fields available (date, daterange, and maps), phpDocs compliant, …
Browse files Browse the repository at this point in the history
…Improved config validation - Version bump to 3.0.3
  • Loading branch information
Alberto Parziale committed Sep 24, 2019
1 parent 1c09a12 commit 9427643
Show file tree
Hide file tree
Showing 116 changed files with 5,329 additions and 1,091 deletions.
31 changes: 29 additions & 2 deletions Aeria/Action/ActionDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,42 @@
use Aeria\Action\Traits\ListManagerTrait;
use Aeria\Container\Container;

/**
* ActionDispatcher is in charge of registering Actions to WP
*
* @category Action
* @package Aeria
* @author Jacopo Martinelli <jacopo.martinelli@caffeina.com>
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license
* @link https://github.com/caffeinalab/aeria
*/
class ActionDispatcher
{
use ListManagerTrait;

/**
* Registers a new Action to the list
*
* @param ActionInterface $action the new action
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function register(ActionInterface $action)
{
$this->push($action);
}

/**
* Dispatches the saved actions to WP
*
* @param Container $container Aeria's container
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function dispatch(Container $container)
{
foreach ($this->list() as $action) {
Expand Down
41 changes: 37 additions & 4 deletions Aeria/Action/Actions/AdminEnqueueScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,54 @@
use Aeria\Action\Interfaces\ActionInterface;
use Aeria\Action\Traits\ListManagerTrait;
use Aeria\Container\Container;

/**
* AdminEnqueueScripts is in charge of enqueuing scripts to WP
*
* @category Action
* @package Aeria
* @author Jacopo Martinelli <jacopo.martinelli@caffeina.com>
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license
* @link https://github.com/caffeinalab/aeria
*/
class AdminEnqueueScripts implements ActionInterface
{
use ListManagerTrait;

/**
* Returns the type
*
* @return string the type = 'admin_enqueue_scripts'
*
* @access public
* @since Method available since Release 3.0.0
*/
public function getType(): string
{
return 'admin_enqueue_scripts';
}

/**
* Registers a new Enqueuer
*
* @param EnqueuerInterface $enqueuer the new enqueuer
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function register(EnqueuerInterface $enqueuer)
{
$this->push($enqueuer);
}

/**
* Dispatches the enqueuers
*
* @param Container $container Aeria's container
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function dispatch(Container $container)
{
wp_enqueue_editor();
Expand Down
36 changes: 34 additions & 2 deletions Aeria/Action/Enqueuers/ScriptsEnqueuer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
use Aeria\Container\Container;
use Closure;

/**
* ScriptsEnqueuer is in charge of enqueuing scripts to WP
*
* @category Action
* @package Aeria
* @author Jacopo Martinelli <jacopo.martinelli@caffeina.com>
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license
* @link https://github.com/caffeinalab/aeria
*/
class ScriptsEnqueuer implements EnqueuerInterface
{

Expand All @@ -14,7 +23,21 @@ class ScriptsEnqueuer implements EnqueuerInterface
protected $deps;
protected $ver;
protected $in_footer;

/**
* Constructs the ScriptsEnqueuer object
*
* @param string $name the handle
* @param string $path the scripts path
* @param array $deps the script dependencies
* @param string|bool|null $ver the script version number
* @param bool $in_footer whether the script has to be in
* the head, or footer
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function __construct(
string $name,
string $path,
Expand All @@ -28,7 +51,16 @@ public function __construct(
$this->ver = $ver;
$this->in_footer = $in_footer;
}

/**
* Constructs the ScriptsEnqueuer object
*
* @param Container $container Aeria's container
*
* @return Closure the script enqueuer
*
* @access public
* @since Method available since Release 3.0.0
*/
public function getEnqClosure(Container $container): Closure
{
$name = $this->name;
Expand Down
37 changes: 37 additions & 0 deletions Aeria/Action/Interfaces/ActionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,46 @@
use Aeria\Action\Interfaces\EnqueuerInterface;
use Aeria\Container\Container;

/**
* ActionInterface describes an Action class
*
* @category Action
* @package Aeria
* @author Jacopo Martinelli <jacopo.martinelli@caffeina.com>
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license
* @link https://github.com/caffeinalab/aeria
*/
interface ActionInterface
{
/**
* Returns the type
*
* @return string the type
*
* @access public
* @since Method available since Release 3.0.0
*/
public function getType(): string;
/**
* Registers a new Enqueuer
*
* @param EnqueuerInterface $enqueuer the new enqueuer
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function register(EnqueuerInterface $enqueuer);
/**
* Dispatches the enqueuers
*
* @param Container $container Aeria's container
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function dispatch(Container $container);
}
20 changes: 20 additions & 0 deletions Aeria/Action/Interfaces/EnqueuerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@

use Aeria\Container\Container;
use Closure;

/**
* ActionInterface describes an Enqueuer class
*
* @category Action
* @package Aeria
* @author Jacopo Martinelli <jacopo.martinelli@caffeina.com>
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license
* @link https://github.com/caffeinalab/aeria
*/
interface EnqueuerInterface
{
/**
* Constructs the ScriptsEnqueuer object
*
* @param Container $container Aeria's container
*
* @return Closure the script enqueuer
*
* @access public
* @since Method available since Release 3.0.0
*/
public function getEnqClosure(Container $container): Closure;
}
31 changes: 30 additions & 1 deletion Aeria/Action/ServiceProviders/ActionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,42 @@
use Aeria\Action\Enqueuers\ScriptsEnqueuer;
use Aeria\Action\Actions\AdminEnqueueScripts as AdminEnqueueScriptsAction;

/**
* ActionProvider is in charge of registering the Action service
* to the container
*
* @category Action
* @package Aeria
* @author Jacopo Martinelli <jacopo.martinelli@caffeina.com>
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license
* @link https://github.com/caffeinalab/aeria
*/
class ActionProvider implements ServiceProviderInterface
{
/**
* Registers the service to the provided container, as a singleton
*
* @param Container $container Aeria's container
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function register(Container $container)
{
$container->singleton('action', ActionDispatcher::class);
}

/**
* In charge of booting the service.
*
* @param Container $container Aeria's container
*
* @return bool true: service booted
*
* @access public
* @since Method available since Release 3.0.0
*/
public function boot(Container $container): bool
{
$dispatcher = $container->make('action');
Expand Down
38 changes: 35 additions & 3 deletions Aeria/Action/Traits/ListManagerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,53 @@

namespace Aeria\Action\Traits;

/**
* ListManagerTrait makes a class able to manage a list
*
* @category Action
* @package Aeria
* @author Jacopo Martinelli <jacopo.martinelli@caffeina.com>
* @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license
* @link https://github.com/caffeinalab/aeria
*/
trait ListManagerTrait
{

protected $list;

/**
* Constructs the list
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function __construct()
{
$this->list = [];
}

/**
* Pushes an element to the list
*
* @param mixed $elem the element to add
*
* @return void
*
* @access public
* @since Method available since Release 3.0.0
*/
public function push($elem)
{
$this->list[] = $elem;
}

/**
* Returns the full list
*
* @return array the list
*
* @access public
* @since Method available since Release 3.0.0
*/
public function list(): array
{
return $this->list;
Expand Down
Loading

0 comments on commit 9427643

Please sign in to comment.