У меня есть класс, который устанавливает значения $ this-> properties внутри метода attach.Я буду сокращать код здесь для простоты:
<?php
class Event
{
protected $properties = array();
public function attach( $event_name, $context, $event, $callback, $priority )
{
$this->properties [$event_name] = array(
$context,
$event,
$callback,
$priority,
);
}
public function dispatchAll( $context = '0' )
{
foreach( $this->properties as $p ) {
if( $p[0] == $context ) {
$this->dispatch( $p[1] );
} else {
continue;
}
}
}
public function dispath( $event_name )
{
// implentation not necessary for this question
}
}
Мне нужно отсортировать $this->properties
по «контексту, приоритету», чтобы я мог запустить код, соответствующий контексту моего приложения.в порядке возрастания.
Сильфон var_dump
только из 3 установленных свойств:
array(3) {
["StartUp"]=>
array(4) {
[0]=>
string(1) "1"
[1]=>
string(7) "StartUp"
[2]=>
array(3) {
[0]=>
string(9) "Bootstrap"
[1]=>
string(7) "startup"
[2]=>
array(2) {
[0]=>
int(1)
[1]=>
object(Event)#6 (4) {
["name":protected]=>
NULL
["target":protected]=>
NULL
["parameters":protected]=>
*RECURSION*
["result":protected]=>
NULL
}
}
}
[3]=>
int(0)
}
["View"]=>
array(4) {
[0]=>
string(1) "1"
[1]=>
string(4) "View"
[2]=>
array(2) {
[0]=>
string(9) "Bootstrap"
[1]=>
string(4) "view"
}
[3]=>
array(1) {
[0]=>
object(Event)#6 (4) {
["name":protected]=>
NULL
["target":protected]=>
NULL
["parameters":protected]=>
*RECURSION*
["result":protected]=>
NULL
}
}
}
["ShutDown"]=>
array(4) {
[0]=>
string(1) "3"
[1]=>
string(8) "ShutDown"
[2]=>
array(2) {
[0]=>
string(9) "Bootstrap"
[1]=>
string(8) "shutdown"
}
[3]=>
array(1) {
[0]=>
object(Event)#6 (4) {
["name":protected]=>
NULL
["target":protected]=>
NULL
["parameters":protected]=>
*RECURSION*
["result":protected]=>
NULL
}
}
}
}