1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-08 22:26:55 +02:00

#431 general structure changes

This commit is contained in:
Awilum
2018-03-05 00:22:55 +03:00
parent a616757ee0
commit 0b94ad6d1e
19 changed files with 390 additions and 833 deletions

View File

@@ -1,4 +1,5 @@
<?php
namespace Monstra;
/**
* This file is part of the Monstra.
@@ -9,8 +10,15 @@
* file that was distributed with this source code.
*/
class Filter
{
/**
* @var Monstra
*/
protected $monstra;
/**
* Filters
*
@@ -20,13 +28,11 @@ class Filter
protected static $filters = [];
/**
* Protected constructor since this is a static class.
*
* @access protected
* Construct
*/
protected function __construct()
public function __construct(Monstra $c)
{
// Nothing here
$this->monstra = $c;
}
/**
@@ -41,7 +47,7 @@ class Filter
* @param mixed $value The value on which the filters hooked.
* @return mixed
*/
public static function apply($filter_name, $value)
public function dispatch($filter_name, $value)
{
// Redefine arguments
$filter_name = (string) $filter_name;
@@ -93,7 +99,7 @@ class Filter
* @param integer $accepted_args The number of arguments the function accept default is 1.
* @return boolean
*/
public static function add($filter_name, $function_to_add, $priority = 10, $accepted_args = 1)
public function addListener($filter_name, $function_to_add, $priority = 10, $accepted_args = 1)
{
// Redefine arguments
$filter_name = (string) $filter_name;
@@ -101,6 +107,8 @@ class Filter
$priority = (int) $priority;
$accepted_args = (int) $accepted_args;
//die($function_to_add);
// Check that we don't already have the same filter at the same priority. Thanks to WP :)
if (isset(static::$filters[$filter_name]["$priority"])) {
foreach (static::$filters[$filter_name]["$priority"] as $filter) {