{"id":202234,"date":"2013-11-15T12:35:03","date_gmt":"2013-11-15T08:35:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=202234"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=202234","title":{"rendered":"<span class=\"post_title\">\u0414\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0443&nbsp;\u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432&nbsp;\u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0438&nbsp;\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u043d\u0430&nbsp;Packagist-\u0435 \u044f&nbsp;\u043d\u0430\u0448\u0435\u043b \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/packagist.org\/packages\/evenement\/evenement\">Evenement<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b \u043f\u043e\u0434 \u043c\u043e\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u043e&nbsp;\u0432\u0441\u0435&nbsp;\u0436\u0435 \u043e\u0442\u0431\u043e\u0440 \u043e\u043d&nbsp;\u043d\u0435&nbsp;\u043f\u0440\u043e\u0448\u0435\u043b \u0438\u0437-\u0437\u0430 \u0434\u0432\u0443\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:  <\/p>\n<ul>\n<li>\u0431\u044b\u043b\u0430 \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u043e&nbsp;\u0448\u0430\u0431\u043b\u043e\u043d\u0443;<\/li>\n<li>\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043d\u0435&nbsp;\u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f.<\/li>\n<\/ul>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e&nbsp;\u0436\u0435, \u044f&nbsp;\u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0438&nbsp;\u043f\u0440\u0438\u0447\u0435\u0441\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u00ab\u043f\u043e\u0434 \u0441\u0435\u0431\u044f\u00bb.<\/p>\n<h4>\u041f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u043e&nbsp;\u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/h4>\n<p>  \u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0438\u043c\u0435\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043b\u044e\u0447\u0438 (<code>foo.bar.baz<\/code>).<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439:  <\/p>\n<ul>\n<li><code>some.event<\/code><\/li>\n<li><code>another.event<\/code><\/li>\n<li><code>yet.another.event<\/code><\/li>\n<li><code>something.new<\/code><\/li>\n<\/ul>\n<p>  \u041d\u0443\u0436\u043d\u043e \u043f\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430&nbsp;\u00abevent\u00bb. \u0418\u043b\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430&nbsp;\u00abyet\u00bb \u0438&nbsp;\u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430&nbsp;\u00abevent\u00bb, \u0438&nbsp;\u043d\u0435&nbsp;\u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u0432&nbsp;\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>Eventable<\/h4>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439 \u044f&nbsp;\u043f\u0440\u0438\u043d\u044f\u043b\u0441\u044f \u043a&nbsp;\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430&nbsp;\u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u043c Evenement.<\/p>\n<h5>\u0414\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h5>\n<p>  \u0414\u0443\u043c\u0430\u044f \u043d\u0430\u0434 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u044f \u043f\u043e\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u043b \u043d\u0430&nbsp;jQuery \u0438&nbsp;\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441&nbsp;\u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438: <code>on()<\/code>, <code>one()<\/code>, <code>off()<\/code>, <code>trigger()<\/code>. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u0448\u0435\u043b\u0441\u044f \u043c\u043d\u0435 \u043f\u043e&nbsp;\u0434\u0443\u0448\u0435 \u043f\u043e&nbsp;\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438\u0437-\u0437\u0430 \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u0438&nbsp;\u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0412&nbsp;\u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:  <\/p>\n<pre><code class=\"php\">Dispatcher {     public Dispatcher on(string $event, callable $listener)     public Dispatcher once(string $event, callable $listener)     public Dispatcher off([string $event [, callable $listener ]])     public Dispatcher trigger(string $event [, array $args ])     public Dispatcher fire(string $event [, array $args ]) } <\/code><\/pre>\n<p>  \u0422\u0430\u043a, \u043c\u0435\u0442\u043e\u0434 <code>off()<\/code> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0438&nbsp;\u0442\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u041e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440&nbsp;&mdash; \u0432&nbsp;\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0432\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u0418\u043b\u0438 \u043d\u0435&nbsp;\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438&nbsp;\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430&nbsp;\u043d\u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432.<\/p>\n<p>  <code>trigger()<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u043a\u043b\u044e\u0447\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0438&nbsp;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<br \/>  <code>fire()<\/code> \u0432&nbsp;\u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043e\u0434\u043d\u043e, \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b, \u043e\u043d&nbsp;\u0432\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043d\u0430&nbsp;\u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>once()<\/code><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Dispatcher.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">namespace Yowsa\\Eventable;  class Dispatcher {     protected $events = [];      public function on($event, callable $listener)     {         if (!KeysResolver::isValidKey($event)) {             throw new \\InvalidArgumentException('Invalid event name given');         }          if (!isset($this-&gt;events[$event])) {             $this-&gt;events[$event] = [];         }          $this-&gt;events[$event][] = $listener;          return $this;     }      public function once($event, callable $listener)     {         $onceClosure = function () use (&$onceClosure, $event, $listener) {             $this-&gt;off($event, $onceClosure);             call_user_func_array($listener, func_get_args());         };         $this-&gt;on($event, $onceClosure);          return $this;     }      public function off($event = null, callable $listener = null)     {         if (empty($event)) {             $this-&gt;events = [];         } elseif (empty($listener)) {             $this-&gt;events[$event] = [];         } elseif (!empty($this-&gt;events[$event])) {             $index = array_search($listener, $this-&gt;events[$event], true);              if (false !== $index) {                 unset($this-&gt;events[$event][$index]);             }         }          return $this;     }      public function trigger($event, array $args = [])     {         $matchedEvents = KeysResolver::filterKeys($event, array_keys($this-&gt;events));          if (!empty($matchedEvents)) {             if (is_array($matchedEvents)) {                 foreach ($matchedEvents as $eventName) {                     $this-&gt;fire($eventName, $args);                 }             } else {                 $this-&gt;fire($matchedEvents, $args);             }         }          return $this;     }      public function fire($event, array $args = [])     {         foreach ($this-&gt;events[$event] as $listener) {             call_user_func_array($listener, $args);         }          return $this;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<h5>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043b\u044e\u0447\u0435\u0439<\/h5>\n<p>  \u041f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0434\u0435\u043b\u0430\u043d\u0430&nbsp;&mdash; \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0438&nbsp;\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433&nbsp;&mdash; \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u043e&nbsp;\u0448\u0430\u0431\u043b\u043e\u043d\u0443.<br \/>  \u0428\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0441\u0435 \u0442\u0435&nbsp;\u0436\u0435 \u043a\u043b\u044e\u0447\u0438, \u043d\u043e&nbsp;\u0441&nbsp;\u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438:   <\/p>\n<ul>\n<li><code>*<\/code> &mdash;&nbsp;\u043e\u0434\u0438\u043d \u0441\u0435\u0433\u043c\u0435\u043d\u0442, \u0434\u043e&nbsp;\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f;<\/li>\n<li><code>**<\/code> &mdash;&nbsp;\u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432.<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u043a\u043b\u044e\u0447\u0430 <code>application.user.signin.error<\/code> \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b:  <\/p>\n<ul>\n<li><code>application.**.error<\/code><\/li>\n<li><code>**.error<\/code><\/li>\n<li><code>application.user.*.error<\/code><\/li>\n<li><code>application.user.**<\/code><\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430:  <\/p>\n<pre><code class=\"php\">KeysResolver {     public static int isValidKey(string $key)     public static string getKeyRegexPattern(string $key)     public static mixed filterKeys(string $pattern [, array $keys ]) } <\/code><\/pre>\n<p>  \u041d\u0438\u0447\u0435\u0433\u043e \u0432\u043e\u0435\u043d\u043d\u043e\u0433\u043e: \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0430, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432&nbsp;\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438&nbsp;\u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u043b\u044e\u0447\u0435\u0439.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">KeysResolver.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">namespace Yowsa\\Eventable;  class KeysResolver {     public static function isValidKey($key)     {         return preg_match('\/^(([\\w\\d\\-]+)\\.?)+[^\\.]$\/', $key);     }      public static function getKeyRegexPattern($key)     {         $pattern = ('*' === $key)                 ? '([^\\.]+)'                 : (('**' === $key)                     ? '(.*)'                     : str_replace(                         array('\\*\\*', '\\*'),                         array('(.+)', '([^.]*)'),                         preg_quote($key)                     )                 );          return '\/^' . $pattern . '$\/i';     }      public static function filterKeys($pattern, array $keys = array())     {         $matched = preg_grep(self::getKeyRegexPattern($pattern), $keys);         if (empty($matched)) {             return null;         }         if (1 === count($matched)) {             return array_shift($matched);         }          return array_values($matched);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0412\u0435\u0441\u044c \u043f\u0430\u043a\u0435\u0442 \u0432\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432&nbsp;\u0434\u0432\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430, \u043b\u0435\u0433\u043a\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0438&nbsp;\u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d composer-\u043f\u0430\u043a\u0435\u0442\u043e\u043c.<\/p>\n<h4>Does it&nbsp;work<\/h4>\n<p>  \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u043a\u0430\u043a Eventable \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438&nbsp;\u0432&nbsp;\u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440.  <\/p>\n<pre><code class=\"php\">require_once __DIR__ . '\/..\/vendor\/autoload.php';  $dispatcher = new Yowsa\\Eventable\\Dispatcher(); $teacher    = 'Mrs. Teacher'; $children   = ['Mildred', 'Nicholas', 'Kevin', 'Bobby', 'Anna',                'Kelly', 'Howard', 'Christopher', 'Maria', 'Alan'];  \/\/ teacher comes in the classroom \/\/ and children welcome her once  $dispatcher-&gt;once('teacher.comes', function($teacher) use ($children) {     foreach ($children as $kid) {         printf(&quot;%-12s- Hello, %s!\\n&quot;, $kid, $teacher);     } });  \/\/ every kid answers to teacher once foreach ($children as $kid) {     $dispatcher-&gt;once(&quot;children.{$kid}.says&quot;, function() use ($kid) {         echo &quot;Hi {$kid}!\\n&quot;;     }); }  \/\/ boddy cannot stop to talk $dispatcher-&gt;on('children.Bobby.says', function() {     echo &quot;\\tBobby: I want pee\\n&quot;; });   \/\/ trigger events  echo &quot;{$teacher} is entering the classroom.\\n\\n&quot;; $dispatcher-&gt;trigger('teacher.comes', [$teacher]);  echo &quot;\\n\\n{$teacher} welcomes everyone personally\\n\\n&quot;; $dispatcher-&gt;trigger('children.*.says');  for ($i = 0; $i &lt; 5; $i++) {     $dispatcher-&gt;trigger('children.Bobby.says'); } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u044e\u043b\u044c\u0442\u0430\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">Mrs. Teacher is&nbsp;entering the classroom.  Mildred&nbsp;&mdash; Hello, Mrs. Teacher! Nicholas&nbsp;&mdash; Hello, Mrs. Teacher! Kevin&nbsp;&mdash; Hello, Mrs. Teacher! Bobby&nbsp;&mdash; Hello, Mrs. Teacher! Anna&nbsp;&mdash; Hello, Mrs. Teacher! Kelly&nbsp;&mdash; Hello, Mrs. Teacher! Howard&nbsp;&mdash; Hello, Mrs. Teacher! Christopher&nbsp;&mdash; Hello, Mrs. Teacher! Maria&nbsp;&mdash; Hello, Mrs. Teacher! Alan&nbsp;&mdash; Hello, Mrs. Teacher!  Mrs. Teacher welcomes everyone personally  Hi&nbsp;Mildred! Hi&nbsp;Nicholas! Hi&nbsp;Kevin! Hi&nbsp;Bobby! \tBobby: I&nbsp;want pee Hi&nbsp;Anna! Hi&nbsp;Kelly! Hi&nbsp;Howard! Hi&nbsp;Christopher! Hi&nbsp;Maria! Hi&nbsp;Alan! \tBobby: I&nbsp;want pee \tBobby: I&nbsp;want pee \tBobby: I&nbsp;want pee \tBobby: I&nbsp;want pee \tBobby: I&nbsp;want pee <\/code><\/pre>\n<\/div>\n<\/div>\n<h5>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h5>\n<p>  \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b\u0441\u044f:  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/balkonsmoke\/yowsa-eventable\">https:\/\/github.com\/igorw\/evenement<\/a><\/li>\n<li><a href=\"https:\/\/packagist.org\/packages\/evenement\/evenement\">https:\/\/packagist.org\/packages\/evenement\/evenement<\/a><\/li>\n<\/ul>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:  <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/balkonsmoke\/yowsa-eventable\">https:\/\/github.com\/balkonsmoke\/yowsa-eventable<\/a><\/li>\n<li><a href=\"https:\/\/packagist.org\/packages\/yowsa\/eventable\">https:\/\/packagist.org\/packages\/yowsa\/eventable<\/a><\/li>\n<\/ul>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/202234\/\"> http:\/\/habrahabr.ru\/post\/202234\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0443&nbsp;\u043c\u0435\u043d\u044f \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432&nbsp;\u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0438&nbsp;\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u043d\u0430&nbsp;Packagist-\u0435 \u044f&nbsp;\u043d\u0430\u0448\u0435\u043b \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/packagist.org\/packages\/evenement\/evenement\">Evenement<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b \u043f\u043e\u0434 \u043c\u043e\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u043e&nbsp;\u0432\u0441\u0435&nbsp;\u0436\u0435 \u043e\u0442\u0431\u043e\u0440 \u043e\u043d&nbsp;\u043d\u0435&nbsp;\u043f\u0440\u043e\u0448\u0435\u043b \u0438\u0437-\u0437\u0430 \u0434\u0432\u0443\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:  <\/p>\n<ul>\n<li>\u0431\u044b\u043b\u0430 \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u043e&nbsp;\u0448\u0430\u0431\u043b\u043e\u043d\u0443;<\/li>\n<li>\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043d\u0435&nbsp;\u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f.<\/li>\n<\/ul>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e&nbsp;\u0436\u0435, \u044f&nbsp;\u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0438&nbsp;\u043f\u0440\u0438\u0447\u0435\u0441\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u00ab\u043f\u043e\u0434 \u0441\u0435\u0431\u044f\u00bb.<\/p>\n<h4>\u041f\u043e\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u043e&nbsp;\u0448\u0430\u0431\u043b\u043e\u043d\u0443<\/h4>\n<p>  \u041c\u043d\u0435 \u043d\u0443\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0438\u043c\u0435\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043b\u044e\u0447\u0438 (<code>foo.bar.baz<\/code>).<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439:  <\/p>\n<ul>\n<li><code>some.event<\/code><\/li>\n<li><code>another.event<\/code><\/li>\n<li><code>yet.another.event<\/code><\/li>\n<li><code>something.new<\/code><\/li>\n<\/ul>\n<p>  \u041d\u0443\u0436\u043d\u043e \u043f\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430&nbsp;\u00abevent\u00bb. \u0418\u043b\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430&nbsp;\u00abyet\u00bb \u0438&nbsp;\u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430&nbsp;\u00abevent\u00bb, \u0438&nbsp;\u043d\u0435&nbsp;\u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u0432&nbsp;\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-202234","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=202234"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/202234\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=202234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=202234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}